PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lists.h
Go to the documentation of this file.
1 /*
2  * lists.h
3  *
4  * List Container Classes
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  */
29 
30 #ifndef PTLIB_LISTS_H
31 #define PTLIB_LISTS_H
32 
33 #ifdef P_USE_PRAGMA
34 #pragma interface
35 #endif
36 
37 
39 // PList container class
40 
42 {
43  PListElement(PObject * theData);
47 
49 };
50 
51 struct PListInfo
52 {
53  PListInfo() { head = tail = NULL; }
56 
58 };
59 
80 class PAbstractList : public PCollection
81 {
82  PCONTAINERINFO(PAbstractList, PCollection);
83 
84  public:
94 
95  // Overrides from class PObject
122  virtual Comparison Compare(
123  const PObject & obj
124  ) const;
125 
135  virtual PBoolean SetSize(
136  PINDEX newSize
137  );
139 
148  virtual PINDEX Append(
149  PObject * obj
150  );
151 
158  virtual void Prepend(
159  PObject * obj
160  );
161 
174  virtual PINDEX Insert(
175  const PObject & before,
176  PObject * obj
177  );
178 
186  P_DEPRECATED virtual PINDEX InsertAt(
187  PINDEX index,
188  PObject * obj
189  );
190 
197  virtual PBoolean Remove(
198  const PObject * obj
199  );
200 
207  virtual PObject * RemoveHead()
208  { return RemoveElement(m_info->head); }
209 
216  virtual PObject * RemoveTail()
217  { return RemoveElement(m_info->tail); }
218 
219 
229  P_DEPRECATED virtual PObject * RemoveAt(
230  PINDEX index
231  );
232 
244  P_DEPRECATED virtual PBoolean SetAt(
245  PINDEX index,
246  PObject * val
247  );
248 
260  PINDEX index,
261  PObject * val
262  );
263 
274  P_DEPRECATED virtual PObject * GetAt(
275  PINDEX index
276  ) const;
277 
285  virtual PINDEX GetObjectsIndex(
286  const PObject * obj
287  ) const;
288 
297  virtual PINDEX GetValuesIndex(
298  const PObject & obj
299  ) const;
301 
302 
303  protected:
304  PINLINE PObject & GetReferenceAt(PINDEX index) const;
305  PListElement * FindElement(PINDEX index) const;
306  PListElement * FindElement(const PObject & obj, PINDEX * index) const;
307  void InsertElement(PListElement * element, PObject * obj);
308  PObject * RemoveElement(PListElement * element);
309 
310  // The types below cannot be nested as DevStudio 2005 AUTOEXP.DAT doesn't like it
313 };
314 
315 
322 template <class T> class PList : public PAbstractList
323 {
324  PCLASSINFO(PList, PAbstractList);
325 
326  public:
335  : PAbstractList() { }
337 
343  virtual PObject * Clone() const
344  { return PNEW PList(0, this); }
346 
349  typedef T value_type;
350 
351  class iterator_base : public std::iterator<std::bidirectional_iterator_tag, value_type> {
352  protected:
355 
356  void Next() { this->element = PAssertNULL(this->element)->next; }
357  void Prev() { this->element = PAssertNULL(this->element)->prev; }
358  value_type * Ptr() const { return dynamic_cast<value_type *>(PAssertNULL(this->element)->data); }
359 
360  public:
361  bool operator==(const iterator_base & it) const { return this->element == it.element; }
362  bool operator!=(const iterator_base & it) const { return this->element != it.element; }
363 
364  friend class PList<T>;
365  };
366 
367  class iterator : public iterator_base {
368  public:
369  iterator(PListElement * e = NULL) : iterator_base(e) { }
370 
371  iterator operator++() { this->Next(); return *this; }
372  iterator operator--() { this->Prev(); return *this; }
373  iterator operator++(int) { iterator it = *this; this->Next(); return it; }
374  iterator operator--(int) { iterator it = *this; this->Prev(); return it; }
375 
376  value_type * operator->() const { return this->Ptr(); }
377  value_type & operator* () const { return *this->Ptr(); }
378  };
379 
380  iterator begin() { return this->m_info->head; }
381  iterator end() { return iterator(); }
382  iterator rbegin() { return this->m_info->tail; }
383  iterator rend() { return iterator(); }
384  iterator find(const value_type & obj) { return this->FindElement(obj, NULL); }
385  void insert(const iterator & pos, value_type * obj) { this->InsertElement(pos.element, obj); }
386  void insert(const iterator & pos, const value_type & obj) { this->InsertElement(pos.element, obj.Clone()); }
387 
388  class const_iterator : public iterator_base {
389  public:
391 
392  const_iterator operator++() { this->Next(); return *this; }
393  const_iterator operator--() { this->Prev(); return *this; }
394  const_iterator operator++(int) { const_iterator it = *this; this->Next(); return it; }
395  const_iterator operator--(int) { const_iterator it = *this; this->Prev(); return it; }
396 
397  const value_type * operator->() const { return this->Ptr(); }
398  const value_type & operator* () const { return *this->Ptr(); }
399  };
400 
401  const_iterator begin() const { return this->m_info->head; }
402  const_iterator end() const { return const_iterator(); }
403  const_iterator rbegin() const { return this->m_info->tail; }
404  const_iterator rend() const { return const_iterator(); }
405  const_iterator find(const value_type & obj) const { return this->FindElement(obj, NULL); }
406 
408  value_type & front() const { return dynamic_cast<value_type &>(*PAssertNULL(this->m_info->head)->data); }
409  value_type & back() const { return dynamic_cast<value_type &>(*PAssertNULL(this->m_info->tail)->data); }
411  __inline void erase(const iterator & it) { this->RemoveElement(it.element); }
412  __inline void erase(const const_iterator & it) { this->RemoveElement(it.element); }
413  __inline void push_front(const value_type & value) { this->InsertAt(0, new value_type(value)); }
414  __inline void push_back(const value_type & value) { this->Append(new value_type(value)); }
415  __inline void pop_front() { this->RemoveHead(); }
416  __inline void pop_back() { this->RemoveTail(); }
418 
433  PINDEX index
434  ) const { return dynamic_cast<T &>(this->GetReferenceAt(index)); }
436 
437  protected:
438  PList(int dummy, const PList * c)
439  : PAbstractList(dummy, c) { }
440 };
441 
442 
454 #define PLIST(cls, T) typedef PList<T> cls
455 
467 #define PDECLARE_LIST(cls, T) \
468  PLIST(cls##_PTemplate, T); \
469  PDECLARE_CLASS(cls, PList<T>) \
470  protected: \
471  cls(int dummy, const cls * c) \
472  : PList<T>(dummy, c) { } \
473  public: \
474  cls() \
475  : PList<T>() { } \
476  virtual PObject * Clone() const \
477  { return PNEW cls(0, this); } \
478 
479 
492 template <class T> class PQueue : public PAbstractList
493 {
494  PCLASSINFO(PQueue, PAbstractList);
495 
496  public:
508 
514  virtual PObject * Clone() const
515  { return PNEW PQueue(0, this); }
517 
523  virtual void Enqueue(
524  T * obj
525  ) { PAbstractList::Append(obj); }
531  virtual T * Dequeue()
532  { return dynamic_cast<T *>(PAbstractList::RemoveHead()); }
534 
535  protected:
536  PQueue(int dummy, const PQueue * c)
537  : PAbstractList(dummy, c)
539 };
540 
541 
554 #define PQUEUE(cls, T) typedef PQueue<T> cls
555 
556 
569 #define PDECLARE_QUEUE(cls, T) \
570  PQUEUE(cls##_PTemplate, T); \
571  PDECLARE_CLASS(cls, cls##_PTemplate) \
572  protected: \
573  cls(int dummy, const cls * c) \
574  : cls##_PTemplate(dummy, c) { } \
575  public: \
576  cls() \
577  : cls##_PTemplate() { } \
578  virtual PObject * Clone() const \
579  { return PNEW cls(0, this); } \
580 
581 
594 template <class T> class PStack : public PAbstractList
595 {
596  PCLASSINFO(PStack, PAbstractList);
597 
598  public:
610 
616  virtual PObject * Clone() const
617  { return PNEW PStack(0, this); }
619 
626  virtual void Push(
627  T * obj
628  ) { PAbstractList::Prepend(obj); }
629  __inline void push(T * obj) { Push(obj); }
630 
636  virtual T * Pop()
637  { return dynamic_cast<T *>(PAbstractList::RemoveHead()); }
638  __inline void pop() { Pop(); }
639 
646  virtual T & Top()
647  { PAssert(this->GetSize() > 0, PStackEmpty); return dynamic_cast<T &>(*this->m_info->head->data); }
648  __inline T & front() { Top(); }
650 
651  protected:
652  PStack(int dummy, const PStack * c)
653  : PAbstractList(dummy, c)
655 };
656 
657 
670 #define PSTACK(cls, T) typedef PStack<T> cls
671 
672 
685 #define PDECLARE_STACK(cls, T) \
686  PSTACK(cls##_PTemplate, T); \
687  PDECLARE_CLASS(cls, cls##_PTemplate) \
688  protected: \
689  cls(int dummy, const cls * c) \
690  : cls##_PTemplate(dummy, c) { } \
691  public: \
692  cls() \
693  : cls##_PTemplate() { } \
694  virtual PObject * Clone() const \
695  { return PNEW cls(0, this); } \
696 
697 
699 // Sorted List of PObjects
700 
702 {
703  PSortedListElement(PSortedListElement * nil = NULL, PObject * obj = NULL);
704 
710  enum { Red, Black } m_colour;
711 
713 };
714 
716 {
718 
721 
724  PSortedListElement * OrderSelect(PSortedListElement * node, PINDEX index) const;
725  PSortedListElement * OrderSelect(PINDEX index) const { return OrderSelect(m_root, index); }
726  PINDEX ValueSelect(PSortedListElement * node, const PObject & obj, PSortedListElement * & element) const;
727  PINDEX ValueSelect(const PObject & obj, PSortedListElement * & element) const { return ValueSelect(m_root, obj, element); }
728 
730 };
731 
759 {
760  PCONTAINERINFO(PAbstractSortedList, PCollection);
761 
762  public:
772 
801  virtual Comparison Compare(const PObject & obj) const;
803 
813  virtual PBoolean SetSize(
814  PINDEX newSize // New size for the sorted list, this is ignored.
815  );
817 
826  virtual PINDEX Append(
827  PObject * obj // New object to place into the collection.
828  );
829 
839  virtual PINDEX Insert(
840  const PObject & before, // Object value to insert before.
841  PObject * obj // New object to place into the collection.
842  );
843 
853  virtual PINDEX InsertAt(
854  PINDEX index, // Index position in collection to place the object.
855  PObject * obj // New object to place into the collection.
856  );
857 
868  virtual PBoolean Remove(
869  const PObject * obj // Existing object to remove from the collection.
870  );
871 
881  virtual PObject * RemoveAt(
882  PINDEX index // Index position in collection to place the object.
883  );
884 
891  virtual void RemoveAll();
892 
899  virtual PBoolean SetAt(
900  PINDEX index, // Index position in collection to set.
901  PObject * val // New value to place into the collection.
902  );
903 
910  virtual PObject * GetAt(
911  PINDEX index // Index position in the collection of the object.
912  ) const;
913 
925  virtual PINDEX GetObjectsIndex(
926  const PObject * obj
927  ) const;
928 
937  virtual PINDEX GetValuesIndex(
938  const PObject & obj
939  ) const;
941 
942  protected:
943 
944  // New functions for class
945  void RemoveElement(PSortedListElement * node);
946  void LeftRotate(PSortedListElement * node);
947  void RightRotate(PSortedListElement * node);
948  void DeleteSubTrees(PSortedListElement * node, bool deleteObject);
949  PSortedListElement * FindElement(const PObject & obj, PINDEX * index) const;
950  PSortedListElement * FindElement(const PObject * obj, PINDEX * index) const;
951 
952  // The type below cannot be nested as DevStudio 2005 AUTOEXP.DAT doesn't like it
954 };
955 
956 
964 template <class T> class PSortedList : public PAbstractSortedList
965 {
966  PCLASSINFO(PSortedList, PAbstractSortedList);
967 
968  public:
977  : PAbstractSortedList() { }
979 
985  virtual PObject * Clone() const
986  { return PNEW PSortedList(0, this); }
988 
1002  PINDEX index
1003  ) const { return dynamic_cast<T &>(*this->GetAt(index)); }
1005 
1008  typedef T value_type;
1009  friend class iterator_base;
1010 
1011  private:
1012  void NextElement(PSortedListElement * & element) const
1013  {
1014  element = this->m_info->Successor(element);
1015  if (element == &this->m_info->nil)
1016  element = NULL;
1017  }
1018 
1019  void PrevElement(PSortedListElement * & element) const
1020  {
1021  element = this->m_info->Predecessor(element);
1022  if (element == &this->m_info->nil)
1023  element = NULL;
1024  }
1025 
1026  class iterator_base : public std::iterator<std::bidirectional_iterator_tag, value_type> {
1027  protected:
1028  const PSortedList<T> * m_list;
1029  PSortedListElement * m_element;
1030 
1031  iterator_base(const PSortedList<T> * l, PSortedListElement * e) : m_list(l), m_element(e) { }
1032 
1033  bool Valid() const { return PAssert(this->m_list != NULL && this->m_element != NULL && this->m_element != &m_list->m_info->nil, PInvalidArrayIndex); }
1034  void Next() { if (Valid()) this->m_list->NextElement(this->m_element); }
1035  void Prev() { if (Valid()) this->m_list->PrevElement(this->m_element); }
1036  value_type * Ptr() const { return dynamic_cast<value_type *>(Valid() ? this->m_element->m_data : NULL); }
1037 
1038  public:
1039  bool operator==(const iterator_base & it) const { return this->m_element == it.m_element; }
1040  bool operator!=(const iterator_base & it) const { return this->m_element != it.m_element; }
1041 
1042  friend class PSortedList<T>;
1043  };
1044 
1045  public:
1046  class iterator : public iterator_base {
1047  public:
1048  iterator() : iterator_base(NULL, NULL) { }
1049  iterator(PSortedList<T> * l, PSortedListElement * e) : iterator_base(l, e) { }
1050 
1051  iterator operator++() { this->Next(); return *this; }
1052  iterator operator--() { this->Prev(); return *this; }
1053  iterator operator++(int) { iterator it = *this; this->Next(); return it; }
1054  iterator operator--(int) { iterator it = *this; this->Prev(); return it; }
1055 
1056  value_type * operator->() const { return this->Ptr(); }
1057  value_type & operator* () const { return *this->Ptr(); }
1058  };
1059 
1060  iterator begin() { return IsEmpty() ? iterator() : iterator(this, this->m_info->OrderSelect(1)); }
1061  iterator end() { return iterator(); }
1062  iterator rbegin() { return IsEmpty() ? iterator() : iterator(this, this->m_info->OrderSelect(this->GetSize())); }
1063  iterator rend() { return iterator(); }
1064 
1066  public:
1067  const_iterator() : iterator_base(NULL, NULL) { }
1068  const_iterator(const PSortedList<T> * l, PSortedListElement * e) : iterator_base(l, e) { }
1069 
1070  const_iterator operator++() { this->Next(); return *this; }
1071  const_iterator operator--() { this->Prev(); return *this; }
1072  const_iterator operator++(int) { const_iterator it = *this; this->Next(); return it; }
1073  const_iterator operator--(int) { const_iterator it = *this; this->Prev(); return it; }
1074 
1075  const value_type * operator->() const { return this->Ptr(); }
1076  const value_type & operator* () const { return *this->Ptr(); }
1077  };
1078 
1079  const_iterator begin() const { return IsEmpty() ? const_iterator() : const_iterator(this, this->m_info->OrderSelect(1)); }
1080  const_iterator end() const { return const_iterator(); }
1081  const_iterator rbegin() const { return IsEmpty() ? const_iterator() : const_iterator(this, this->m_info->OrderSelect(this->GetSize())); }
1082  const_iterator rend() const { return const_iterator(); }
1083 
1084  value_type & front() { return *this->begin(); }
1085  value_type & back() { return *this->rbegin(); }
1086  const value_type & front() const { return *this->begin(); }
1087  const value_type & back() const { return *this->rbegin(); }
1088 
1089  iterator find(const value_type & obj) { return iterator(this, this->FindElement(obj, NULL)); }
1090  const_iterator find(const value_type & obj) const { return const_iterator(this, this->FindElement(obj, NULL)); }
1091 
1092  void erase(const iterator & it) { PAssert(this == it.m_list, PLogicError); this->RemoveElement(it.m_element); }
1093  void erase(const const_iterator & it) { PAssert(this == it.m_list, PLogicError); this->RemoveElement(it.m_element); }
1094  __inline void insert(const value_type & value) { this->Append(new value_type(value)); }
1095  __inline void pop_front() { this->erase(this->begin()); }
1096  __inline void pop_back() { this->erase(this->rbegin()); }
1098 
1099  protected:
1100  PSortedList(int dummy, const PSortedList * c)
1101  : PAbstractSortedList(dummy, c) { }
1102 };
1103 
1104 
1116 #define PSORTED_LIST(cls, T) typedef PSortedList<T> cls
1117 
1118 
1131 #define PDECLARE_SORTED_LIST(cls, T) \
1132  PSORTED_LIST(cls##_PTemplate, T); \
1133  PDECLARE_CLASS(cls, PSortedList<T>) \
1134  protected: \
1135  cls(int dummy, const cls * c) \
1136  : PSortedList<T>(dummy, c) { } \
1137  public: \
1138  cls() \
1139  : PSortedList<T>() { } \
1140  virtual PObject * Clone() const \
1141  { return PNEW cls(0, this); } \
1142 
1143 
1144 #endif // PTLIB_LISTS_H
1145 
1146 
1147 // End Of File ///////////////////////////////////////////////////////////////
const value_type * operator->() const
Definition: lists.h:1075
virtual PBoolean IsEmpty() const
Determine if the container is empty.
__inline void pop()
Definition: lists.h:638
value_type & operator*() const
Definition: lists.h:377
virtual PObject * Clone() const
Make a complete duplicate of the list.
Definition: lists.h:985
virtual T & Top()
Get the element that is currently on top of the stack without removing it.
Definition: lists.h:646
iterator end()
Definition: lists.h:381
virtual PObject * Clone() const
Make a complete duplicate of the list.
Definition: lists.h:514
bool operator==(const iterator_base &it) const
Definition: lists.h:361
PQueue(int dummy, const PQueue *c)
Definition: lists.h:536
Definition: lists.h:701
__inline void erase(const const_iterator &it)
Definition: lists.h:412
PSortedListElement * Successor(PSortedListElement *node) const
iterator rbegin()
Definition: lists.h:382
virtual P_DEPRECATED PBoolean ReplaceAt(PINDEX index, PObject *val)
Set the object at the specified ordinal position to the new value.
iterator(PSortedList< T > *l, PSortedListElement *e)
Definition: lists.h:1049
const_iterator operator--()
Definition: lists.h:393
value_type & back()
Definition: lists.h:1085
PINLINE PObject & GetReferenceAt(PINDEX index) const
Definition: lists.h:41
iterator(PListElement *e=NULL)
Definition: lists.h:369
enum PSortedListElement::@5 m_colour
const_iterator rend() const
Definition: lists.h:1082
const_iterator()
Definition: lists.h:1067
PListElement * FindElement(PINDEX index) const
iterator rend()
Definition: lists.h:383
__inline void pop_back()
Definition: lists.h:416
PINDEX m_subTreeSize
Definition: lists.h:709
PSortedListElement * m_left
Definition: lists.h:706
virtual PBoolean SetSize(PINDEX newSize)
This function is meaningless for lists.
__inline void pop_back()
Definition: lists.h:1096
value_type * operator->() const
Definition: lists.h:1056
T value_type
Definition: lists.h:349
void erase(const iterator &it)
Definition: lists.h:1092
#define PINLINE
Definition: object.h:194
iterator operator++()
Definition: lists.h:371
const_iterator operator++(int)
Definition: lists.h:394
PSortedList()
Create a new, empty, sorted list.
Definition: lists.h:976
virtual PINDEX Insert(const PObject &before, PObject *obj)
Add a new object to the collection.
const_iterator(const PSortedList< T > *l, PSortedListElement *e)
Definition: lists.h:1068
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
virtual void RemoveAll()
Remove all of the elements in the collection.
virtual PINDEX GetValuesIndex(const PObject &obj) const
Search the collection for the specified value of the object.
iterator find(const value_type &obj)
Definition: lists.h:1089
PSortedList(int dummy, const PSortedList *c)
Definition: lists.h:1100
A Pop() was made of a stack with no elements.
Definition: object.h:376
iterator operator++()
Definition: lists.h:1051
PSortedListElement * m_right
Definition: lists.h:707
virtual PBoolean SetAt(PINDEX index, PObject *val)
This method simply returns false as the list order is mantained by the class.
PSortedListElement * OrderSelect(PINDEX index) const
Definition: lists.h:725
iterator_base(PListElement *e)
Definition: lists.h:353
iterator()
Definition: lists.h:1048
const_iterator(PListElement *e=NULL)
Definition: lists.h:390
bool operator!=(const PObject &obj) const
Compare the two objects.
Definition: object.h:2318
void insert(const iterator &pos, value_type *obj)
Definition: lists.h:385
virtual PObject * Clone() const
Make a complete duplicate of the stack.
Definition: lists.h:616
virtual PINDEX GetObjectsIndex(const PObject *obj) const
Search the collection for the specific instance of the object.
void Next()
Definition: lists.h:356
#define P_POP_MSVC_WARNINGS()
Definition: object.h:154
PListElement Element
Definition: lists.h:311
void InsertElement(PListElement *element, PObject *obj)
virtual PINDEX Append(PObject *obj)
Append a new object to the collection.
An index into an array was negative.
Definition: object.h:374
PQueue()
Create a new, empty, queue.
Definition: lists.h:505
const_iterator operator++(int)
Definition: lists.h:1072
virtual PBoolean Remove(const PObject *obj)
Remove the object from the collection.
const_iterator find(const value_type &obj) const
Definition: lists.h:1090
PList()
Create a new, empty, list.
Definition: lists.h:334
Definition: lists.h:367
const value_type & operator*() const
Definition: lists.h:398
value_type & back() const
Definition: lists.h:409
iterator operator--()
Definition: lists.h:1052
PSortedListElement * OrderSelect(PSortedListElement *node, PINDEX index) const
This template class maps the PAbstractList to a specific object type.
Definition: lists.h:322
iterator rbegin()
Definition: lists.h:1062
const_iterator begin() const
Definition: lists.h:401
PSortedListElement * m_root
Definition: lists.h:720
PINDEX ValueSelect(PSortedListElement *node, const PObject &obj, PSortedListElement *&element) const
void RemoveElement(PSortedListElement *node)
PListInfo()
Definition: lists.h:53
PINLINE PAbstractList()
Create a new, empty, list.
virtual T * Dequeue()
Remove an object that was added to the queue.
Definition: lists.h:531
iterator operator--()
Definition: lists.h:372
iterator find(const value_type &obj)
Definition: lists.h:384
virtual void Enqueue(T *obj)
Add a new object to the queue.
Definition: lists.h:523
friend class iterator_base
Definition: lists.h:1009
Definition: lists.h:710
virtual Comparison Compare(const PObject &obj) const
Get the relative rank of the two lists.
const_iterator operator--(int)
Definition: lists.h:395
virtual P_DEPRECATED PINDEX InsertAt(PINDEX index, PObject *obj)
Insert a new object at the specified ordinal index.
PList(int dummy, const PList *c)
Definition: lists.h:438
virtual PINDEX Append(PObject *obj)
Add a new object to the collection.
virtual T * Pop()
Remove the last object pushed onto the stack.
Definition: lists.h:636
void insert(const iterator &pos, const value_type &obj)
Definition: lists.h:386
PSortedListElement nil
Definition: lists.h:719
PSortedListElement(PSortedListElement *nil=NULL, PObject *obj=NULL)
__inline void erase(const iterator &it)
Definition: lists.h:411
iterator end()
Definition: lists.h:1061
virtual PObject * GetAt(PINDEX index) const
Get the object at the specified ordinal position.
virtual PObject * RemoveHead()
Remove the head object from the list.
Definition: lists.h:207
virtual P_DEPRECATED PObject * RemoveAt(PINDEX index)
Remove the object at the specified ordinal index from the collection.
PDECLARE_POOL_ALLOCATOR(PSortedListElement)
virtual PBoolean Remove(const PObject *obj)
Remove the object from the collection.
bool operator!=(const iterator_base &it) const
Definition: lists.h:362
void RightRotate(PSortedListElement *node)
void erase(const const_iterator &it)
Definition: lists.h:1093
#define PAssertNULL(ptr)
This macro is used to assert that a pointer must be non-null.
Definition: object.h:428
PObject * m_data
Definition: lists.h:708
virtual PINDEX GetSize() const
Get the current size of the container.
__inline void push_back(const value_type &value)
Definition: lists.h:414
virtual PINDEX GetObjectsIndex(const PObject *obj) const
Search the collection for the specific instance of the object.
PDECLARE_POOL_ALLOCATOR(PListElement)
bool operator==(const PObject &obj) const
Compare the two objects.
Definition: object.h:2309
bool PBoolean
Definition: object.h:174
virtual void Push(T *obj)
Add an object to the stack.
Definition: lists.h:626
PObject * RemoveElement(PListElement *element)
Definition: lists.h:51
virtual Comparison Compare(const PObject &obj) const
Get the relative rank of the two lists.
This class is a collection of objects which are descendents of the PObject class. ...
Definition: lists.h:80
value_type & front()
Definition: lists.h:1084
PObject * data
Definition: lists.h:46
iterator begin()
Definition: lists.h:380
virtual PObject * RemoveAt(PINDEX index)
Remove the object at the specified ordinal index from the collection.
virtual PINDEX GetValuesIndex(const PObject &obj) const
Search the collection for the specified value of the object.
The character string class.
Definition: pstring.h:108
const_iterator begin() const
Definition: lists.h:1079
PStack(int dummy, const PStack *c)
Definition: lists.h:652
#define P_PUSH_MSVC_WARNINGS(warnings)
Definition: object.h:153
value_type & operator*() const
Definition: lists.h:1057
This template class maps the PAbstractList to a specific object type, and adds functionality that all...
Definition: lists.h:492
const value_type & front() const
Definition: lists.h:1086
PListElement * prev
Definition: lists.h:44
Definition: lists.h:710
const_iterator operator++()
Definition: lists.h:1070
PSortedListElement * FindElement(const PObject &obj, PINDEX *index) const
bool deleteObjects
Definition: contain.h:67
const value_type & back() const
Definition: lists.h:1087
virtual PINDEX Insert(const PObject &before, PObject *obj)
Insert a new object immediately before the specified object.
T & operator[](PINDEX index) const
Retrieve a reference to the object in the list.
Definition: lists.h:432
iterator operator--(int)
Definition: lists.h:374
PAbstractSortedList()
Create a new, empty, sorted list.
virtual PINDEX InsertAt(PINDEX index, PObject *obj)
Add a new object to the collection.
T value_type
Definition: lists.h:1008
PDECLARE_POOL_ALLOCATOR(PSortedListInfo)
const_iterator rend() const
Definition: lists.h:404
virtual void Prepend(PObject *obj)
Append a new object to the collection.
Definition: lists.h:715
__inline void push(T *obj)
Definition: lists.h:629
value_type & front() const
Definition: lists.h:408
PStack()
Create a new, empty, stack.
Definition: lists.h:607
const_iterator operator--()
Definition: lists.h:1071
iterator operator++(int)
Definition: lists.h:373
virtual PObject * Clone() const
Make a complete duplicate of the list.
Definition: lists.h:343
PDECLARE_POOL_ALLOCATOR(PListInfo)
virtual PObject * RemoveTail()
Remove the tail object from the list.
Definition: lists.h:216
__inline void push_front(const value_type &value)
Definition: lists.h:413
const value_type * operator->() const
Definition: lists.h:397
PListElement(PObject *theData)
iterator operator++(int)
Definition: lists.h:1053
virtual P_DEPRECATED PBoolean SetAt(PINDEX index, PObject *val)
Set the object at the specified ordinal position to the new value.
const_iterator end() const
Definition: lists.h:1080
This template class maps the PAbstractSortedList to a specific object type.
Definition: lists.h:964
iterator rend()
Definition: lists.h:1063
This template class maps the PAbstractList to a specific object type, and adds functionality that all...
Definition: lists.h:594
PListElement * tail
Definition: lists.h:55
PListElement * head
Definition: lists.h:54
__inline void pop_front()
Definition: lists.h:415
value_type * Ptr() const
Definition: lists.h:358
#define PAssert(b, msg)
This macro is used to assert that a condition must be true.
Definition: object.h:400
PSortedListElement * Predecessor(PSortedListElement *node) const
const_iterator rbegin() const
Definition: lists.h:1081
virtual PObject * Clone() const
Create a copy of the class on the heap.
#define P_DEPRECATED
Definition: object.h:141
T & operator[](PINDEX index) const
Retrieve a reference to the object in the list.
Definition: lists.h:1001
const_iterator operator++()
Definition: lists.h:392
__inline void insert(const value_type &value)
Definition: lists.h:1094
This class is a collection of objects which are descendents of the PObject class. ...
Definition: lists.h:758
virtual P_DEPRECATED PObject * GetAt(PINDEX index) const
Get the object at the specified ordinal position.
iterator begin()
Definition: lists.h:1060
const value_type & operator*() const
Definition: lists.h:1076
virtual PBoolean SetSize(PINDEX newSize)
This function is meaningless for lists.
__inline T & front()
Definition: lists.h:648
void DeleteSubTrees(PSortedListElement *node, bool deleteObject)
PContainerReference * reference
Definition: contain.h:288
__inline void pop_front()
Definition: lists.h:1095
Definition: lists.h:351
PSortedListInfo()
Definition: lists.h:717
const_iterator operator--(int)
Definition: lists.h:1073
PListElement * next
Definition: lists.h:45
This object describes the information associated with one part of a multi-part body.
Definition: mime.h:294
Definition: lists.h:1065
Definition: lists.h:1046
void LeftRotate(PSortedListElement *node)
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
PSortedListInfo * m_info
Definition: lists.h:953
value_type * operator->() const
Definition: lists.h:376
A collection is a container that collects together descendents of the PObject class.
Definition: contain.h:392
A logic error occurred.
Definition: object.h:370
PListElement * element
Definition: lists.h:354
const_iterator find(const value_type &obj) const
Definition: lists.h:405
PListInfo * m_info
Definition: lists.h:312
const_iterator rbegin() const
Definition: lists.h:403
void DisallowDeleteObjects()
Disallow the deletion of the objects contained in the collection.
Definition: lists.h:388
void Prev()
Definition: lists.h:357
const_iterator end() const
Definition: lists.h:402
iterator operator--(int)
Definition: lists.h:1054
#define PNEW
Macro for overriding system default new operator.
Definition: object.h:1896
PINDEX ValueSelect(const PObject &obj, PSortedListElement *&element) const
Definition: lists.h:727
PSortedListElement * m_parent
Definition: lists.h:705