89 template<
typename S,
typename E, E* S::*first, E* E::*next>
class EStack;
93 template<
typename L,
typename E,
int L::*numElem, E* L::*first, E* L::*last, E* E::*next, E* E::*prev>
class EList;
96 template<
typename S,
typename E, E* S::*first, E* E::*next>
101 static inline void init(S* pStack)
107 static inline void pop(S* pStack)
109 pStack->*first = pStack->*first->*next;
115 E* res = pStack->*first;
116 pStack->*first = pStack->*first->*next;
121 static inline void push(S* pStack, E* pElem)
123 pElem->*next = pStack->*first;
124 pStack->*first = pElem;
128 static inline E*
top(
const S* pStack)
130 return pStack->*first;
134 static inline bool empty(
const S* pStack)
136 return pStack->*first == 0;
142 template<
typename E, E* E::*prev, E* E::*next>
156 inline bool valid()
const {
return m_ptr !=
nullptr; }
171 E& operator*()
const {
return *m_ptr; }
188 m_ptr = m_ptr->*next;
196 m_ptr = m_ptr->*next;
203 m_ptr = m_ptr->*prev;
211 m_ptr = m_ptr->*prev;
238 static inline void init(L* pList)
246 static inline int size(
const L* pList) {
return pList->*numElem; }
249 static inline bool empty(
const L* pList) {
return pList->*first == 0; }
252 static inline E*
front(
const L* pList) {
return pList->*first; }
255 static inline E*
back(
const L* pList) {
return pList->*last; }
261 elem->*prev = pList->*last;
263 pList->*last = pList->*last->*next = elem;
265 pList->*last = pList->*first = elem;
274 elem->*next = pList->*first;
278 pList->*first = pList->*first->*prev = elem;
280 pList->*first = pList->*last = elem;
293 pPrev = pNext->*prev;
307 pList->*first = elem;
316 return insertBefore(pList, elem, (E*)(*itNext));
325 pNext = pPrev->*next;
339 pList->*first = elem;
348 return insertAfter(pList, elem, (E*)(*itPrev));
355 remove(pList, front(pList));
362 remove(pList, back(pList));
368 E* pPrev = elem->*prev;
369 E* pNext = elem->*next;
371 pPrev->*next = pNext;
373 pList->*first = pNext;
375 pNext->*prev = pPrev;
377 pList->*last = pPrev;
386 return remove(pList, (E*)(*it));
391 E* L_other::*other_first,
392 E* L_other::*other_last,
393 int L_other::*other_numElem
395 inline static void appendFrom( L* pList, L_other* pListOther )
397 if (!pListOther->*other_first)
402 pList->*first = pListOther->*other_first;
403 pList->*last = pListOther->*other_last;
407 pList->*last->*next = pListOther->*other_first;
408 pListOther->*other_first->*prev = pList->*last;
411 pList->*last = pListOther->*other_first;
415 pList->*numElem += pListOther->*other_numElem;
417 pListOther->*other_numElem = 0;
418 pListOther->*other_first = 0;
419 pListOther->*other_last = 0;
434 template<
typename Func>
435 static inline void forall(
const L* pList,
const Func& func)
443 template<
typename A1>
444 static inline void forall_call(
const L* pList,
void (E::*func)( A1 ),
const A1& a1)
453 inline EList(L* pList) : m_pList(pList) { }
477 inline iterator remove(E* elem) {
return remove(m_pList, elem); }
static E * front(const L *pList)
Returns a pointer to the first element.
iterator insertAfter(E *elem, E *pPrev)
The embedded list template.
EListIterator< E, prev, next > pred() const
Returns predecessor iterator.
EListIterator< E, prev, next > & operator--()
Decrement operator (prefix).
static iterator rbegin(const L *pList)
Returns a reverse iterator pointing at the last element of pList.
static bool empty(const L *pList)
Returns true if /a pList is empty.
static void forall(const L *pList, const Func &func)
EListIterator< E, prev, next > & operator=(const EListIterator< E, prev, next > &other)
Assignment operator.
static void popFront(L *pList)
Removes the first element of pList.
EListIterator< E, prev, next > & operator++()
Increment operator (prefix).
iterator insertAfter(E *elem, const iterator &it)
static iterator pushBack(L *pList, E *elem)
Appends the element elem to the end of pList.
static iterator insertBefore(L *pList, E *elem, const iterator &itNext)
Inserts elem into pList before position itNext.
EListIterator< E, prev, next > succ() const
Returns successor iterator.
static iterator pushFront(L *pList, E *elem)
Adds element elem at the begin of the list.
EListIterator(const EListIterator< E, prev, next > &other)
constructs an iterator pointing at the same element as other
EListIterator< E, prev, next > operator++(int)
Increment operator (postfix).
static void forall_call(const L *pList, void(E::*func)(A1), const A1 &a1)
static void pop(S *pStack)
Removes the top element from pStack without returning it.
static void init(S *pStack)
Initializes pStack as empty stack.
E * m_ptr
The pointer to the element the iterator is pointing at.
static E * back(const L *pList)
Returns a pointer to the last element.
static iterator insertBefore(L *pList, E *elem, E *pNext)
Inserts elem into pList before pNext.
static void init(L *pList)
Initializes pList as an empty embedded list.
static E * popRet(S *pStack)
Removes the top element and returns it.
EList(L *pList)
Constructor.
static E * top(const S *pStack)
Returns a pointer to the top element of pStack.
Implementation of an embedded list iterator used by ogdf::EList.
bool valid() const
returns false if the iterator points at nullptr
The embedded stack class template.
static iterator rend(const L *pList)
Returns a reverse iterator pointing at nullptr.
EListIterator()
Constructs an iterator pointing at nullptr.
static void popBack(L *pList)
Removes the last element of pList.
static bool empty(const S *pStack)
Returns true if pStack is empty.
iterator insertBefore(E *elem, const iterator &it)
bool operator==(const EListIterator< E, prev, next > &other) const
Equality operator.
iterator pushBack(E *elem)
static iterator begin(const L *pList)
Returns an iterator pointing at the first element of pList.
static iterator end(const L *pList)
Returns an iterator pointing at nullptr.
static iterator insertAfter(L *pList, E *elem, const iterator &itPrev)
Inserts elem into pList after position itPrev.
static void appendFrom(L *pList, L_other *pListOther)
static void push(S *pStack, E *pElem)
Pushes the new element pElem onto pStack.
iterator pushFront(E *elem)
The namespace for all OGDF objects.
iterator insertBefore(E *elem, E *pNext)
bool operator!=(const EListIterator< E, prev, next > &other) const
Inequality operator.
static int size(const L *pList)
Returns the number of elements in this embedded list by reading the numElem var.
EListIterator(E *ptr)
Constructs an iterator pointing at ptr.
E * operator*() const
Returns a pointer to the element.
static iterator insertAfter(L *pList, E *elem, E *pPrev)
Inserts elem into pList before pPrev.
EListIterator< E, prev, next > operator--(int)
Decrement operator (postfix).