1 #ifndef PHPOINTERLIST_H__
2 #define PHPOINTERLIST_H__
65 maxNItems = initialSize;
66 items =
new T*[maxNItems];
81 maxNItems = l.maxNItems;
84 for (
size_t i=0; i<nItems; ++i)
105 newSize = maxNItems * 2;
108 items =
new T*[newSize];
111 for (
size_t i=0; i<maxNItems; ++i)
113 items[i] = buffer[i];
120 std::cout <<
"PHPointerList<T>::grow: Out of memory?" << std::endl;
135 std::cout <<
"PHPointerList<T>::operator[]: nItems exceeded" << std::endl;
144 if (nItems < maxNItems)
146 items[nItems] = item;
154 items[nItems] = item;
160 std::cout <<
"PHPointerList<T>::append: max nItems exceeded" << std::endl;
173 std::cout <<
"PHPointerList<T>::insertAt: insert beyond nItems" << std::endl;
181 for (
size_t i=nItems; i>pos; --i)
183 items[i] = items[i-1];
203 for (
size_t i=0; i<nItems; ++i)
224 return items[nItems--];
228 std::cout <<
"PHPointerList<T>::removeLast: no items in list" << std::endl;
244 for (
size_t j=i; j<nItems-1; ++j)
246 items[j] = items[j+1];
258 for (
size_t i=0; i<thislist.
length(); ++i)
260 stream << *(thislist[i]) << std::endl;
std::ostream & operator<<(std::ostream &stream, const PHPointerList< T > &thislist)
T * operator[](size_t) const
PHPointerList(const PHPointerList< T > &)
PHBoolean insertAt(T *, size_t)
PHPointerList< T > & operator=(const PHPointerList< T > &)