#include <ace/Array.h>
template<class T> class ACE_Array {
public:
typedef T TYPE;
ACE_Array (size_t size);
ACE_Array (size_t size, const T &default_value);
ACE_Array (const ACE_Array<T> &s);
void operator= (const ACE_Array<T> &s);
~ACE_Array (void);
T &operator [] (size_t index);
const T &operator [] (size_t index) const;
int set (const T &new_item, size_t index);
int get (T &item, size_t index) const;
size_t size (void) const;
int operator== (const ACE_Array<T> &s) const;
int operator!= (const ACE_Array<T> &s) const;
private:
int in_range (size_t index) const;
size_t max_size_;
size_t cur_size_;
T *array_;
friend class ACE_Array_Iterator<T>;
};
ACE_Array (size_t size);
ACE_Array (size_t size, const T &default_value);
default_value
.
ACE_Array (const ACE_Array<T> &s);
s
, i.e., *this == s will
return true.
void operator= (const ACE_Array<T> &s);
s
, i.e., *this == s will
return true. Note that if the max_size_
of array_
is = than
s.max_size_
we can copy it without reallocating. However, if
max_size_
is s.max_size_
we must delete the array_
,
reallocate a new array_
, and then copy the contents of s
.
~ACE_Array (void);
T &operator [] (size_t index);
index
. Doesn't
perform range checking.
const T &operator [] (size_t index) const;
index
. Doesn't
perform range checking.
int set (const T &new_item, size_t index);
index
. Returns
-1 if index
is not in range, else returns 0.
int get (T &item, size_t index) const;
index
. Returns -1 if
index
is not in range, else returns 0. Note that this function
copies the item. If you want to avoid the copy, you can use
the const operator [], but then you'll be responsible for range checking.
size_t size (void) const;
cur_size_
of the array.
int operator== (const ACE_Array<T> &s) const;
s
for equality. Two arrays are equal
if their size()'s are equal and all the elements from 0 .. size()
are equal.
int operator!= (const ACE_Array<T> &s) const;
s
for inequality such that *this
!=
s
is always the complement of the boolean return value of
*this
== s
.