8 #include <GAListBASE.h>
16 extern GANodeBASE *_GAListTraverse(
unsigned int index,
unsigned int &cur,
33 auto *newnode =
new GANode<T>(node->contents);
34 GANode<T> *lasttmp = newnode, *newtmp =
nullptr;
36 while (tmp && tmp != head)
39 newtmp->prev = lasttmp;
40 lasttmp->next = newtmp;
47 newtmp->next = newnode;
48 newnode->prev = newtmp;
52 newnode->next = newnode;
53 newnode->prev = newnode;
108 delete GAListBASE::remove(DYN_CAST(
GANode<T> *, hd));
128 node = DYN_CAST(
GANode<T> *, _GAListTraverse(i, w, hd));
134 t->insert(newnode,
nullptr, GAListBASE::HEAD);
156 delete GAListBASE::remove(DYN_CAST(
GANode<T> *, hd));
157 hd = _GAListCopy(DYN_CAST(
GANode<T> *, orig.hd),
178 return GAListBASE::NO_ERR;
179 if (node->prev && node->prev != node)
181 iter.node = node->next;
183 iter.node = node->prev;
186 delete GAListBASE::remove(node);
187 return GAListBASE::NO_ERR;
199 int swap(
unsigned int a,
unsigned int b)
201 if (a == b || a > (
unsigned int)size() || b > (
unsigned int)size())
202 return GAListBASE::NO_ERR;
203 GANodeBASE *tmp = hd, *anode =
nullptr, *bnode =
nullptr;
204 unsigned int cur = 0;
205 while (tmp && tmp->next != hd)
218 return GAListBASE::swapnode(anode, bnode);
238 if (node->prev != node)
239 iter.node = node->prev;
242 node = DYN_CAST(
GANode<T> *, GAListBASE::remove(node));
243 T *contents =
new T(node->contents);
263 GAErr(GA_LOC,
"GAList",
"insert", GAError::CannotInsertIntoSelf);
264 return GAListBASE::ERR;
268 return GAListBASE::ERR;
270 iter.node = (t->hd ? t->hd : iter.node);
272 t->iter.node =
nullptr;
273 return GAListBASE::NO_ERR;
284 int insert(
const T &t, GAListBASE::Location where = GAListBASE::AFTER)
290 return GAListBASE::ERR;
293 return GAListBASE::NO_ERR;
299 T *head() {
return iter.head(); }
300 T *tail() {
return iter.tail(); }
301 T *current() {
return iter.current(); }
302 T *next() {
return iter.next(); }
303 T *prev() {
return iter.prev(); }
304 T *warp(
unsigned int i) {
return iter.warp(i); }
307 return ((i.list ==
this) ? iter.warp(i) :
nullptr);
309 T *operator[](
unsigned int i) {
return iter.warp(i); }
313 GAListBASE::Location where = GAListBASE::AFTER)
316 return GAListBASE::ERR;
318 return GAListBASE::NO_ERR;
342 template <
class T>
class GAList;
353 T *current() {
return (node ? &((
GANode<T> *)node)->contents :
nullptr); }
356 return (((node = GAListIterBASE::head()) !=
nullptr) ? &((
GANode<T> *)GAListIterBASE::head())->contents :
nullptr);
360 return (((node = GAListIterBASE::tail()) !=
nullptr) ? &((
GANode<T> *)GAListIterBASE::tail())->contents :
nullptr);
364 return ((node && node->next) ? &((
GANode<T> *)(node = node->next))->contents :
nullptr);
368 return ((node && node->prev) ? &((
GANode<T> *)(node = node->prev))->contents :
nullptr);
374 return (t.iter.node ? &((
GANode<T> *)(node = t.iter.node))->contents :
nullptr);
380 return (i.node ? &((
GANode<T> *)(node = i.node))->contents :
nullptr);
382 T *warp(
unsigned int i)
385 return (n !=
nullptr ? &((
GANode<T> *)(node = n))->contents :
nullptr);
Definition: GAListBASE.h:78
int insert(GANodeBASE *n, GANodeBASE *idx, Location where=AFTER)
Definition: GAListBASE.h:161
Definition: GAList.hpp:345
Container for nodes that have a list structure.
Definition: GAList.hpp:88
int destroy()
Remove the current node from the list and free the memory it was using.
Definition: GAList.hpp:174
int insert(GAList< T > *t, GAListBASE::Location where=GAListBASE::AFTER)
Inserts the contents of list in to the current list and removes it from the original list.
Definition: GAList.hpp:259
T * remove()
Remove the current node from the list.
Definition: GAList.hpp:232
int insert(const T &t, GAListBASE::Location where=GAListBASE::AFTER)
Insert the object into the list at the specified place relative to the current location of the embedd...
Definition: GAList.hpp:284
GAList< T > * clone(unsigned int i=0) const
Make a copy of a list and return the pointer to the new list.
Definition: GAList.hpp:120
int swap(unsigned int a, unsigned int b)
Swap two nodes in the list.
Definition: GAList.hpp:199
void copy(const GAList< T > &orig)
Make a complete copy of the list and return a pointer to the new list.
Definition: GAList.hpp:153
This is the basic node object.
Definition: GANode.h:18