-
Notifications
You must be signed in to change notification settings - Fork 0
/
Array.h
94 lines (77 loc) · 1.97 KB
/
Array.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Honor Pledge:
//
// I pledge that I have neither given nor
// received any help on this assignment.
//
// blakbenn
#ifndef _ARRAY_H_
#define _ARRAY_H_
#include <cstring> // for size_t definition
#include "BaseArray.h"
/**
* @class Array
*
* Basic implementation of a standard array class for chars.
*/
template <typename T>
class Array : public BaseArray <T>
{
public:
/// Type definition of the element type.
typedef T type;
/// Default constructor.
Array (void);
/**
* Initializing constructor.
*
* @param[in] length Initial size
*/
Array (size_t length);
/**
* Initializing constructor.
*
* @param[in] length Initial size
* @param[in] fill Initial value for each element
*/
Array (size_t length, T fill);
/**
* Copy constructor
*
* @param[in] arr The source array.
*/
Array (const Array & arr);
/// Destructor.
~Array (void);
/**
* Retrieve the maximum size of the array.
*
* @return The maximum size
*/
size_t max_size (void) const;
/**
* Set a new size for the array. If \a new_size is less than the current
* size, then the array is truncated. If \a new_size if greater then the
* current size, then the array is made larger and the new elements are
* not initialized to anything. If \a new_size is the same as the current
* size, then nothing happens.
*
* The array's original contents are preserved regardless of whether the
* array's size is either increased or decreased.
*
* @param[in] new_size New size of the array
*/
void resize (size_t new_size);
/**
* Assignment operation
*
* @param[in] rhs Right-hand side of equal sign
* @return Reference to self
*/
const Array & operator = (const Array & rhs);
private:
/// Maximum size of the array.
size_t max_size_;
};
#include "Array.inl"
#include "Array.cpp"
#endif // !defined _ARRAY_H_