UtilArray


A UtilArray<T> is a wrapper around ordinary C++ arrays. The main reason for having UtilArray is that it is not possible to have a UtilPtr to an ordinary array, but it is possible to have a UtilPtr to a UtilArray.

template <class T>
class UtilArray {
public:
  const int length;
  UtilArray(int);
  ~UtilArray();
  UtilArray<T>& operator=(const UtilArray<T>&);
  bool operator==(const UtilArray<T>&) const;
  T& operator[](int);
};

const int length
This member is the length of the array.
UtilArray(int l)
The contructor creates a UtilArray of size l; the elements are all initalized with their default constructor. If l is negative or zero, the size will be zero.
~UtilArray()
The destructor destroys the UtilArray, including destructing all of the elements.
UtilArray<T>& operator=(const UtilArray<T>& x)
This operator copies the elements of x into the UtilArray. If the arrays are different sizes, then the number of elements it copies is the size of the smaller array.
bool operator==(const UtilArray<T>& x)
This operator compares the elements of the array with the elements of x. If the arrays are of different sizes, they are always considered not equal.
T& operator[](int x)
This operator allows accessing element of the array, just as you would expect. Accessing elements less than zero or equal to or greater than length is guaranteed not to crash, but otherwise not defined.

Modified 21 October 1995 pepellet@mit.edu