1 #ifndef PHOOL_PHPOINTERLIST_H
2 #define PHOOL_PHPOINTERLIST_H
49 bool grow(
size_t = 0);
61 maxNItems = initialSize;
62 items =
new T*[maxNItems];
81 for (
size_t i = 0; i < nItems; ++i)
101 newSize = maxNItems * 2;
104 items =
new T*[newSize];
107 for (
size_t i = 0; i < maxNItems; ++i)
109 items[i] = buffer[i];
116 std::cout <<
"PHPointerList<T>::grow: Out of memory?" << std::endl;
132 std::cout <<
"PHPointerList<T>::operator[]: nItems exceeded" << std::endl;
141 if (nItems < maxNItems)
143 items[nItems] = item;
151 items[nItems] = item;
157 std::cout <<
"PHPointerList<T>::append: max nItems exceeded" << std::endl;
170 std::cout <<
"PHPointerList<T>::insertAt: insert beyond nItems" << std::endl;
178 for (
size_t i = nItems; i >
pos; --i)
180 items[i] = items[i - 1];
200 for (
size_t i = 0; i < nItems; ++i)
221 return items[nItems--];
225 std::cout <<
"PHPointerList<T>::removeLast: no items in list" << std::endl;
241 for (
size_t j = i; j < nItems - 1; ++j)
243 items[j] = items[j + 1];
253 operator<<(std::ostream& stream, const PHPointerList<T>& thislist)
255 for (
size_t i = 0; i < thislist.length(); ++i)
257 stream << *(thislist[i]) << std::endl;