32 : n (
n2), a ((n == 0) ? ((T*)
NULL)
60 for (i= 0; i < n; i++)
102 if (
N (a) !=
N (
b))
return false;
103 for (i= 0; i <
N (a); i++)
104 if (a[i] !=
b[i])
return false;
112 if (
N (a) !=
N (
b))
return true;
113 for (i= 0; i <
N (a); i++)
114 if (a[i] !=
b[i])
return true;
123 if (
N (a) == 0)
return out <<
"[ ]";
125 for (i= 0; i <
N (a) - 1; i++)
127 if (
N (a) != 0) out << a[i];
135 a->resize (
N (a) + 1);
144 a->resize (
N (a) +
N (
b));
145 for (i= 0; i <
N (
b); i++)
154 for (i= 0; i < l; i++)
155 if (a ==
b[i])
return true;
165 for (i= 0; i < l; i++)
173 int i,
k=
N (a), l=
N (
b);
175 for (i= 0; i <
k; i++)
177 for (i= 0; i < l; i++)
186 ASSERT (i >= 0 &&
j <=
N (a),
"out of range");
188 for (
k= i;
k <
j;
k++)
198 for (i= 0; i < n; i++)
206 int i, n=
N (a), h= 0;
207 for (i= 0; i < n; i++)
208 h=
hash (a[i]) ^ ((h << 7) + (h >> 25));
217 for (i= 0; i < n; i++)
227 for (i= 0; i < n; i++)
int N(array< T > a)
Get the length of the array.
int round_length(int n, size_t s)
array< T > reverse(array< T > a)
Reverse an array.
array< T > operator*(array< T > a, T c)
Multiply an array object by a scalar value of type T.
int hash(array< T > a)
This function computes the hash of an array object a.
array< T > range(array< T > a, int i, int j)
Get a subarray of an array.
array< t > append(t a, array< t > b)
bool operator!=(array< T > a, array< T > b)
Check if two arrays are not equal.
bool operator==(array< T > a, array< T > b)
Check if two arrays are equal.
bool contains(t a, array< t > b)
tm_ostream & operator<<(tm_ostream &out, array< T > a)
Output the array to an output stream.
array< T > operator/(array< T > a, T c)
Divide an array object by a scalar value of type T.
#define ASSERT(cond, msg)
Macro used to assert that a condition is true, and throw an exception with an error message if the co...
array_rep()
Construct a new array representation object with length 0.
void resize(int n)
Resize the array length to n.
array(int n=0)
Construct a new array object with length 0.
The list class represents a linked list.
list(T item)
Construct a new list object with a single item.
void tm_delete_array(C *Ptr)