|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2005-2007, Ingo Weinhold, bonefish@users.sf.net. All rights reserved.
|
|
|
|
|
* Copyright 2005-2007, Ingo Weinhold, bonefish@users.sf.net.
|
|
|
|
|
* Copyright 2006-2009, Axel Dörfler, axeld@pinc-software.de.
|
|
|
|
|
*
|
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
|
*/
|
|
|
|
|
#ifndef KERNEL_UTIL_DOUBLY_LINKED_LIST_H
|
|
|
|
@ -40,9 +42,9 @@ public:
|
|
|
|
|
DoublyLinkedListLinkImpl() : fDoublyLinkedListLink() {}
|
|
|
|
|
~DoublyLinkedListLinkImpl() {}
|
|
|
|
|
|
|
|
|
|
DLL_Link *GetDoublyLinkedListLink()
|
|
|
|
|
DLL_Link* GetDoublyLinkedListLink()
|
|
|
|
|
{ return &fDoublyLinkedListLink; }
|
|
|
|
|
const DLL_Link *GetDoublyLinkedListLink() const
|
|
|
|
|
const DLL_Link* GetDoublyLinkedListLink() const
|
|
|
|
|
{ return &fDoublyLinkedListLink; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
@ -56,12 +58,12 @@ private:
|
|
|
|
|
typedef DoublyLinkedListLink<Element> Link;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
inline Link *operator()(Element *element) const
|
|
|
|
|
inline Link* operator()(Element* element) const
|
|
|
|
|
{
|
|
|
|
|
return element->GetDoublyLinkedListLink();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline const Link *operator()(const Element *element) const
|
|
|
|
|
inline const Link* operator()(const Element* element) const
|
|
|
|
|
{
|
|
|
|
|
return element->GetDoublyLinkedListLink();
|
|
|
|
|
}
|
|
|
|
@ -75,12 +77,12 @@ private:
|
|
|
|
|
typedef DoublyLinkedListLink<Element> Link;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
inline Link *operator()(Element *element) const
|
|
|
|
|
inline Link* operator()(Element* element) const
|
|
|
|
|
{
|
|
|
|
|
return &(element->*LinkMember);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline const Link *operator()(const Element *element) const
|
|
|
|
|
inline const Link* operator()(const Element* element) const
|
|
|
|
|
{
|
|
|
|
|
return &(element->*LinkMember);
|
|
|
|
|
}
|
|
|
|
@ -93,14 +95,14 @@ class DoublyLinkedListCLink {
|
|
|
|
|
typedef DoublyLinkedListLink<Element> Link;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
inline Link *operator()(Element *element) const
|
|
|
|
|
inline Link* operator()(Element* element) const
|
|
|
|
|
{
|
|
|
|
|
return (Link *)&element->link;
|
|
|
|
|
return (Link*)&element->link;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline const Link *operator()(const Element *element) const
|
|
|
|
|
inline const Link* operator()(const Element* element) const
|
|
|
|
|
{
|
|
|
|
|
return (const Link *)&element->link;
|
|
|
|
|
return (const Link*)&element->link;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -120,7 +122,7 @@ private:
|
|
|
|
|
public:
|
|
|
|
|
class Iterator {
|
|
|
|
|
public:
|
|
|
|
|
Iterator(List *list)
|
|
|
|
|
Iterator(List* list)
|
|
|
|
|
:
|
|
|
|
|
fList(list)
|
|
|
|
|
{
|
|
|
|
@ -141,7 +143,7 @@ public:
|
|
|
|
|
return fNext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Element *Next()
|
|
|
|
|
Element* Next()
|
|
|
|
|
{
|
|
|
|
|
fCurrent = fNext;
|
|
|
|
|
if (fNext)
|
|
|
|
@ -149,14 +151,14 @@ public:
|
|
|
|
|
return fCurrent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Element *Current()
|
|
|
|
|
Element* Current()
|
|
|
|
|
{
|
|
|
|
|
return fCurrent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Element *Remove()
|
|
|
|
|
Element* Remove()
|
|
|
|
|
{
|
|
|
|
|
Element *element = fCurrent;
|
|
|
|
|
Element* element = fCurrent;
|
|
|
|
|
if (fCurrent) {
|
|
|
|
|
fList->Remove(fCurrent);
|
|
|
|
|
fCurrent = NULL;
|
|
|
|
@ -164,7 +166,7 @@ public:
|
|
|
|
|
return element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Iterator &operator=(const Iterator &other)
|
|
|
|
|
Iterator &operator=(const Iterator& other)
|
|
|
|
|
{
|
|
|
|
|
fList = other.fList;
|
|
|
|
|
fCurrent = other.fCurrent;
|
|
|
|
@ -179,21 +181,21 @@ public:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
List *fList;
|
|
|
|
|
Element *fCurrent;
|
|
|
|
|
Element *fNext;
|
|
|
|
|
List* fList;
|
|
|
|
|
Element* fCurrent;
|
|
|
|
|
Element* fNext;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ConstIterator {
|
|
|
|
|
public:
|
|
|
|
|
ConstIterator(const List *list)
|
|
|
|
|
ConstIterator(const List* list)
|
|
|
|
|
:
|
|
|
|
|
fList(list)
|
|
|
|
|
{
|
|
|
|
|
Rewind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConstIterator(const ConstIterator &other)
|
|
|
|
|
ConstIterator(const ConstIterator& other)
|
|
|
|
|
{
|
|
|
|
|
*this = other;
|
|
|
|
|
}
|
|
|
|
@ -203,15 +205,15 @@ public:
|
|
|
|
|
return fNext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Element *Next()
|
|
|
|
|
Element* Next()
|
|
|
|
|
{
|
|
|
|
|
Element *element = fNext;
|
|
|
|
|
Element* element = fNext;
|
|
|
|
|
if (fNext)
|
|
|
|
|
fNext = fList->GetNext(fNext);
|
|
|
|
|
return element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConstIterator &operator=(const ConstIterator &other)
|
|
|
|
|
ConstIterator& operator=(const ConstIterator& other)
|
|
|
|
|
{
|
|
|
|
|
fList = other.fList;
|
|
|
|
|
fNext = other.fNext;
|
|
|
|
@ -224,20 +226,20 @@ public:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const List *fList;
|
|
|
|
|
Element *fNext;
|
|
|
|
|
const List* fList;
|
|
|
|
|
Element* fNext;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ReverseIterator {
|
|
|
|
|
public:
|
|
|
|
|
ReverseIterator(List *list)
|
|
|
|
|
ReverseIterator(List* list)
|
|
|
|
|
:
|
|
|
|
|
fList(list)
|
|
|
|
|
{
|
|
|
|
|
Rewind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReverseIterator(const ReverseIterator &other)
|
|
|
|
|
ReverseIterator(const ReverseIterator& other)
|
|
|
|
|
{
|
|
|
|
|
*this = other;
|
|
|
|
|
}
|
|
|
|
@ -247,7 +249,7 @@ public:
|
|
|
|
|
return fNext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Element *Next()
|
|
|
|
|
Element* Next()
|
|
|
|
|
{
|
|
|
|
|
fCurrent = fNext;
|
|
|
|
|
if (fNext)
|
|
|
|
@ -255,9 +257,9 @@ public:
|
|
|
|
|
return fCurrent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Element *Remove()
|
|
|
|
|
Element* Remove()
|
|
|
|
|
{
|
|
|
|
|
Element *element = fCurrent;
|
|
|
|
|
Element* element = fCurrent;
|
|
|
|
|
if (fCurrent) {
|
|
|
|
|
fList->Remove(fCurrent);
|
|
|
|
|
fCurrent = NULL;
|
|
|
|
@ -265,7 +267,7 @@ public:
|
|
|
|
|
return element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReverseIterator &operator=(const ReverseIterator &other)
|
|
|
|
|
ReverseIterator &operator=(const ReverseIterator& other)
|
|
|
|
|
{
|
|
|
|
|
fList = other.fList;
|
|
|
|
|
fCurrent = other.fCurrent;
|
|
|
|
@ -280,21 +282,21 @@ public:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
List *fList;
|
|
|
|
|
Element *fCurrent;
|
|
|
|
|
Element *fNext;
|
|
|
|
|
List* fList;
|
|
|
|
|
Element* fCurrent;
|
|
|
|
|
Element* fNext;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ConstReverseIterator {
|
|
|
|
|
public:
|
|
|
|
|
ConstReverseIterator(const List *list)
|
|
|
|
|
ConstReverseIterator(const List* list)
|
|
|
|
|
:
|
|
|
|
|
fList(list)
|
|
|
|
|
{
|
|
|
|
|
Rewind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConstReverseIterator(const ConstReverseIterator &other)
|
|
|
|
|
ConstReverseIterator(const ConstReverseIterator& other)
|
|
|
|
|
{
|
|
|
|
|
*this = other;
|
|
|
|
|
}
|
|
|
|
@ -304,15 +306,15 @@ public:
|
|
|
|
|
return fNext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Element *Next()
|
|
|
|
|
Element* Next()
|
|
|
|
|
{
|
|
|
|
|
Element *element = fNext;
|
|
|
|
|
Element* element = fNext;
|
|
|
|
|
if (fNext)
|
|
|
|
|
fNext = fList->GetPrevious(fNext);
|
|
|
|
|
return element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConstReverseIterator &operator=(const ConstReverseIterator &other)
|
|
|
|
|
ConstReverseIterator& operator=(const ConstReverseIterator& other)
|
|
|
|
|
{
|
|
|
|
|
fList = other.fList;
|
|
|
|
|
fNext = other.fNext;
|
|
|
|
@ -325,8 +327,8 @@ public:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const List *fList;
|
|
|
|
|
Element *fNext;
|
|
|
|
|
const List* fList;
|
|
|
|
|
Element* fNext;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
@ -335,30 +337,31 @@ public:
|
|
|
|
|
|
|
|
|
|
inline bool IsEmpty() const { return (fFirst == NULL); }
|
|
|
|
|
|
|
|
|
|
inline void Insert(Element *element, bool back = true);
|
|
|
|
|
inline void Insert(Element *before, Element *element);
|
|
|
|
|
inline void Add(Element *element, bool back = true);
|
|
|
|
|
inline void Remove(Element *element);
|
|
|
|
|
inline void Insert(Element* element, bool back = true);
|
|
|
|
|
inline void Insert(Element* before, Element* element);
|
|
|
|
|
inline void Add(Element* element, bool back = true);
|
|
|
|
|
inline void Remove(Element* element);
|
|
|
|
|
|
|
|
|
|
inline void Swap(Element *a, Element *b);
|
|
|
|
|
inline void Swap(Element* a, Element* b);
|
|
|
|
|
|
|
|
|
|
inline void MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME *fromList);
|
|
|
|
|
inline void MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME* fromList);
|
|
|
|
|
|
|
|
|
|
inline void RemoveAll();
|
|
|
|
|
inline void MakeEmpty() { RemoveAll(); }
|
|
|
|
|
|
|
|
|
|
inline Element *First() const { return fFirst; }
|
|
|
|
|
inline Element *Last() const { return fLast; }
|
|
|
|
|
inline Element* First() const { return fFirst; }
|
|
|
|
|
inline Element* Last() const { return fLast; }
|
|
|
|
|
|
|
|
|
|
inline Element *Head() const { return fFirst; }
|
|
|
|
|
inline Element *Tail() const { return fLast; }
|
|
|
|
|
inline Element* Head() const { return fFirst; }
|
|
|
|
|
inline Element* Tail() const { return fLast; }
|
|
|
|
|
|
|
|
|
|
inline Element *RemoveHead();
|
|
|
|
|
inline Element* RemoveHead();
|
|
|
|
|
inline Element* RemoveTail();
|
|
|
|
|
|
|
|
|
|
inline Element *GetPrevious(Element *element) const;
|
|
|
|
|
inline Element *GetNext(Element *element) const;
|
|
|
|
|
inline Element* GetPrevious(Element* element) const;
|
|
|
|
|
inline Element* GetNext(Element* element) const;
|
|
|
|
|
|
|
|
|
|
inline int32 Size() const;
|
|
|
|
|
inline int32 Count() const;
|
|
|
|
|
// O(n)!
|
|
|
|
|
|
|
|
|
|
inline Iterator GetIterator() { return Iterator(this); }
|
|
|
|
@ -370,8 +373,8 @@ public:
|
|
|
|
|
{ return ConstReverseIterator(this); }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Element *fFirst;
|
|
|
|
|
Element *fLast;
|
|
|
|
|
Element* fFirst;
|
|
|
|
|
Element* fLast;
|
|
|
|
|
|
|
|
|
|
static GetLink sGetLink;
|
|
|
|
|
};
|
|
|
|
@ -382,7 +385,7 @@ private:
|
|
|
|
|
// Insert
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
void
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Insert(Element *element, bool back)
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Insert(Element* element, bool back)
|
|
|
|
|
{
|
|
|
|
|
if (element) {
|
|
|
|
|
#if DEBUG_DOUBLY_LINKED_LIST
|
|
|
|
@ -392,7 +395,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Insert(Element *element, bool back)
|
|
|
|
|
|
|
|
|
|
if (back) {
|
|
|
|
|
// append
|
|
|
|
|
Link *elLink = sGetLink(element);
|
|
|
|
|
Link* elLink = sGetLink(element);
|
|
|
|
|
elLink->previous = fLast;
|
|
|
|
|
elLink->next = NULL;
|
|
|
|
|
if (fLast)
|
|
|
|
@ -402,7 +405,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Insert(Element *element, bool back)
|
|
|
|
|
fLast = element;
|
|
|
|
|
} else {
|
|
|
|
|
// prepend
|
|
|
|
|
Link *elLink = sGetLink(element);
|
|
|
|
|
Link* elLink = sGetLink(element);
|
|
|
|
|
elLink->previous = NULL;
|
|
|
|
|
elLink->next = fFirst;
|
|
|
|
|
if (fFirst)
|
|
|
|
@ -417,7 +420,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Insert(Element *element, bool back)
|
|
|
|
|
// Insert
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
void
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Insert(Element *before, Element *element)
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Insert(Element* before, Element* element)
|
|
|
|
|
{
|
|
|
|
|
if (before == NULL) {
|
|
|
|
|
Insert(element);
|
|
|
|
@ -431,8 +434,8 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Insert(Element *before, Element *element)
|
|
|
|
|
"list: %p\n", this);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
Link *beforeLink = sGetLink(before);
|
|
|
|
|
Link *link = sGetLink(element);
|
|
|
|
|
Link* beforeLink = sGetLink(before);
|
|
|
|
|
Link* link = sGetLink(element);
|
|
|
|
|
|
|
|
|
|
link->next = before;
|
|
|
|
|
link->previous = beforeLink->previous;
|
|
|
|
@ -447,7 +450,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Insert(Element *before, Element *element)
|
|
|
|
|
// Add
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
void
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Add(Element *element, bool back)
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Add(Element* element, bool back)
|
|
|
|
|
{
|
|
|
|
|
Insert(element, back);
|
|
|
|
|
}
|
|
|
|
@ -455,7 +458,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Add(Element *element, bool back)
|
|
|
|
|
// Remove
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
void
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Remove(Element *element)
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Remove(Element* element)
|
|
|
|
|
{
|
|
|
|
|
if (element) {
|
|
|
|
|
#if DEBUG_DOUBLY_LINKED_LIST
|
|
|
|
@ -464,7 +467,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Remove(Element *element)
|
|
|
|
|
"list: %p, element: %p\n", this, element);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
Link *elLink = sGetLink(element);
|
|
|
|
|
Link* elLink = sGetLink(element);
|
|
|
|
|
if (elLink->previous)
|
|
|
|
|
sGetLink(elLink->previous)->next = elLink->next;
|
|
|
|
|
else
|
|
|
|
@ -481,11 +484,11 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Remove(Element *element)
|
|
|
|
|
// Swap
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
void
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Swap(Element *a, Element *b)
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Swap(Element* a, Element* b)
|
|
|
|
|
{
|
|
|
|
|
if (a && b && a != b) {
|
|
|
|
|
Element *aNext = sGetLink(a)->next;
|
|
|
|
|
Element *bNext = sGetLink(b)->next;
|
|
|
|
|
Element* aNext = sGetLink(a)->next;
|
|
|
|
|
Element* bNext = sGetLink(b)->next;
|
|
|
|
|
if (a == bNext) {
|
|
|
|
|
Remove(a);
|
|
|
|
|
Insert(b, a);
|
|
|
|
@ -504,7 +507,7 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Swap(Element *a, Element *b)
|
|
|
|
|
// MoveFrom
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
void
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME *fromList)
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME* fromList)
|
|
|
|
|
{
|
|
|
|
|
if (fromList && fromList->fFirst) {
|
|
|
|
|
if (fFirst) {
|
|
|
|
@ -525,9 +528,9 @@ DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
void
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::RemoveAll()
|
|
|
|
|
{
|
|
|
|
|
Element *element = fFirst;
|
|
|
|
|
Element* element = fFirst;
|
|
|
|
|
while (element) {
|
|
|
|
|
Link *elLink = sGetLink(element);
|
|
|
|
|
Link* elLink = sGetLink(element);
|
|
|
|
|
element = elLink->next;
|
|
|
|
|
elLink->previous = NULL;
|
|
|
|
|
elLink->next = NULL;
|
|
|
|
@ -538,20 +541,30 @@ DOUBLY_LINKED_LIST_CLASS_NAME::RemoveAll()
|
|
|
|
|
|
|
|
|
|
// RemoveHead
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
Element *
|
|
|
|
|
Element*
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::RemoveHead()
|
|
|
|
|
{
|
|
|
|
|
Element *element = Head();
|
|
|
|
|
Element* element = Head();
|
|
|
|
|
Remove(element);
|
|
|
|
|
return element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RemoveTail
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
Element*
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::RemoveTail()
|
|
|
|
|
{
|
|
|
|
|
Element* element = Tail();
|
|
|
|
|
Remove(element);
|
|
|
|
|
return element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetPrevious
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
Element *
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::GetPrevious(Element *element) const
|
|
|
|
|
Element*
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::GetPrevious(Element* element) const
|
|
|
|
|
{
|
|
|
|
|
Element *result = NULL;
|
|
|
|
|
Element* result = NULL;
|
|
|
|
|
if (element)
|
|
|
|
|
result = sGetLink(element)->previous;
|
|
|
|
|
return result;
|
|
|
|
@ -559,19 +572,19 @@ DOUBLY_LINKED_LIST_CLASS_NAME::GetPrevious(Element *element) const
|
|
|
|
|
|
|
|
|
|
// GetNext
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
Element *
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::GetNext(Element *element) const
|
|
|
|
|
Element*
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::GetNext(Element* element) const
|
|
|
|
|
{
|
|
|
|
|
Element *result = NULL;
|
|
|
|
|
Element* result = NULL;
|
|
|
|
|
if (element)
|
|
|
|
|
result = sGetLink(element)->next;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Size
|
|
|
|
|
// Count
|
|
|
|
|
DOUBLY_LINKED_LIST_TEMPLATE_LIST
|
|
|
|
|
int32
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Size() const
|
|
|
|
|
DOUBLY_LINKED_LIST_CLASS_NAME::Count() const
|
|
|
|
|
{
|
|
|
|
|
int32 count = 0;
|
|
|
|
|
for (Element* element = First(); element; element = GetNext(element))
|
|
|
|
|