UCommon
linked.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
2 //
3 // This file is part of GNU uCommon C++.
4 //
5 // GNU uCommon C++ is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // GNU uCommon C++ is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
17 
32 #ifndef _UCOMMON_LINKED_H_
33 #define _UCOMMON_LINKED_H_
34 
35 #ifndef _UCOMMON_CONFIG_H_
36 #include <ucommon/platform.h>
37 #endif
38 
39 #ifndef _UCOMMON_OBJECT_H_
40 #include <ucommon/object.h>
41 #endif
42 
43 #ifdef nil
44 #undef nil
45 #endif
46 
47 namespace ucommon {
48 
49 class OrderedObject;
50 
58 class __EXPORT LinkedObject : public ObjectProtocol
59 {
60 protected:
61  friend class OrderedIndex;
62  friend class LinkedRing;
63  friend class NamedObject;
64  friend class ObjectStack;
65 
66  LinkedObject *Next;
67 
72  LinkedObject(LinkedObject **root);
73 
79  LinkedObject();
80 
81 public:
82  static const LinkedObject *nil;
83  static const LinkedObject *inv;
85  virtual ~LinkedObject();
86 
90  virtual void release(void);
91 
95  virtual void retain(void);
96 
103  void enlist(LinkedObject **root);
104 
111  void delist(LinkedObject **root);
112 
117  bool is_member(LinkedObject *list) const;
118 
123  static void purge(LinkedObject *root);
124 
129  static unsigned count(const LinkedObject *root);
130 
137  static LinkedObject *getIndexed(LinkedObject *root, unsigned index);
138 
143  inline LinkedObject *getNext(void) const
144  {return Next;}
145 };
146 
156 class __EXPORT ReusableObject : public LinkedObject
157 {
158  friend class ReusableAllocator;
159 
160 protected:
161  virtual void release(void);
162 
163 public:
168  inline ReusableObject *getNext(void)
169  {return static_cast<ReusableObject*>(LinkedObject::getNext());}
170 };
171 
179 class __EXPORT OrderedIndex
180 {
181 protected:
182  friend class OrderedObject;
183  friend class DLinkedObject;
184  friend class LinkedList;
185  friend class NamedObject;
186 
187  OrderedObject *head, *tail;
188 
189  void copy(const OrderedIndex& source);
190 
191 public:
195  OrderedIndex();
196 
197  inline OrderedIndex(const OrderedIndex& source)
198  {copy(source);}
199 
203  virtual ~OrderedIndex();
204 
209  LinkedObject *find(unsigned offset) const;
210 
215  unsigned count(void) const;
216 
220  void purge(void);
221 
225  void reset(void);
226 
231  virtual void lock_index(void);
232 
237  virtual void unlock_index(void);
238 
245  LinkedObject **index(void) const;
246 
252  LinkedObject *get(void);
253 
258  void add(OrderedObject *ordered);
259 
265  inline LinkedObject *getIndexed(unsigned index) const
266  {return LinkedObject::getIndexed((LinkedObject*)head, index);}
267 
272  inline LinkedObject *begin(void) const
273  {return (LinkedObject*)(head);}
274 
279  inline LinkedObject *end(void) const
280  {return (LinkedObject*)(tail);}
281 
286  inline LinkedObject *operator*() const
287  {return (LinkedObject*)(head);}
288 
294  {copy(object); return *this;}
295 
300  void operator*=(OrderedObject *object);
301 };
302 
309 class __EXPORT OrderedObject : public LinkedObject
310 {
311 protected:
312  friend class LinkedList;
313  friend class OrderedIndex;
314  friend class DLinkedObject;
315  friend class ObjectQueue;
316 
321  OrderedObject(OrderedIndex *index);
322 
326  OrderedObject();
327 
328 public:
333  void enlistTail(OrderedIndex *index);
334 
339  void enlistHead(OrderedIndex *index);
340 
346  virtual void enlist(OrderedIndex *index);
347 
352  void delist(OrderedIndex *index);
353 
358  inline OrderedObject *getNext(void) const
359  {return static_cast<OrderedObject *>(LinkedObject::getNext());}
360 };
361 
366 class __EXPORT DLinkedObject : public OrderedObject
367 {
368 public:
369  friend class ObjectQueue;
370 
374  DLinkedObject();
375 
376 protected:
380  void delist(void);
381 
382 private:
383  DLinkedObject *Prev;
384 };
385 
400 class __EXPORT NamedObject : public OrderedObject
401 {
402 protected:
403  char *Id;
404 
408  NamedObject();
409 
416  NamedObject(NamedObject **hash, char *name, unsigned size = 1);
417 
424  NamedObject(OrderedIndex *index, char *name);
425 
433  ~NamedObject();
434 
439  virtual void clearId(void);
440 
441 public:
448  void add(NamedObject **hash, char *name, unsigned size = 1);
449 
455  static void purge(NamedObject **hash, unsigned size);
456 
465  static NamedObject **index(NamedObject **hash, unsigned size);
466 
472  static unsigned count(NamedObject **hash, unsigned size);
473 
481  static NamedObject *find(NamedObject *root, const char *name);
482 
489  static NamedObject *remove(NamedObject **root, const char *name);
490 
498  static NamedObject *map(NamedObject **hash, const char *name, unsigned size);
499 
507  static NamedObject *remove(NamedObject **hash, const char *name, unsigned size);
508 
516  static NamedObject *skip(NamedObject **hash, NamedObject *current, unsigned size);
517 
523  static unsigned keyindex(const char *name, unsigned size);
524 
532  static NamedObject **sort(NamedObject **list, size_t count = 0);
533 
538  inline NamedObject *getNext(void) const
539  {return static_cast<NamedObject*>(LinkedObject::getNext());}
540 
545  inline char *getId(void) const
546  {return Id;};
547 
555  virtual int compare(const char *name) const;
556 
562  inline bool equal(const char *name) const
563  {return (compare(name) == 0);}
564 
570  inline bool operator==(const char *name) const
571  {return compare(name) == 0;}
572 
578  inline bool operator!=(const char *name) const
579  {return compare(name) != 0;}
580 };
581 
589 class __EXPORT NamedTree : public NamedObject
590 {
591 protected:
592  NamedTree *Parent;
593  OrderedIndex Child;
594 
599  NamedTree(char *name = NULL);
600 
606  NamedTree(NamedTree *parent, char *name);
607 
612  NamedTree(const NamedTree& source);
613 
619  virtual ~NamedTree();
620 
626  void purge(void);
627 
628 public:
637  NamedTree *find(const char *name) const;
638 
649  NamedTree *path(const char *path) const;
650 
658  NamedTree *leaf(const char *name) const;
659 
665  NamedTree *getChild(const char *name) const;
666 
673  NamedTree *getLeaf(const char *name) const;
674 
681  inline NamedTree *getFirst(void) const
682  {return static_cast<NamedTree *>(Child.begin());}
683 
688  inline NamedTree *getParent(void) const
689  {return Parent;};
690 
696  inline NamedTree *getIndexed(unsigned index) const
697  {return static_cast<NamedTree *>(Child.getIndexed(index));}
698 
703  inline OrderedIndex *getIndex(void) const
704  {return const_cast<OrderedIndex*>(&Child);}
705 
710  inline operator bool() const
711  {return (Id != NULL);}
712 
717  inline bool operator!() const
718  {return (Id == NULL);}
719 
725  void setId(char *name);
726 
731  void remove(void);
732 
737  inline bool is_leaf(void) const
738  {return (Child.begin() == NULL);}
739 
744  inline bool is_root(void) const
745  {return (Parent == NULL);}
746 
751  void relistTail(NamedTree *trunk);
752 
757  void relistHead(NamedTree *trunk);
758 
763  inline void relist(NamedTree *trunk = NULL)
764  {relistTail(trunk);}
765 };
766 
773 class __EXPORT LinkedList : public OrderedObject
774 {
775 protected:
776  friend class ObjectQueue;
777 
778  LinkedList *Prev;
779  OrderedIndex *Root;
780 
785  LinkedList(OrderedIndex *index);
786 
790  LinkedList();
791 
796  virtual ~LinkedList();
797 
798 public:
802  void delist(void);
803 
809  void enlistHead(OrderedIndex *index);
810 
816  void enlistTail(OrderedIndex *index);
817 
823  void enlist(OrderedIndex *index);
824 
829  inline bool is_head(void) const
830  {return Root->head == (OrderedObject *)this;}
831 
836  inline bool is_tail(void) const
837  {return Root->tail == (OrderedObject *)this;}
838 
843  inline LinkedList *getPrev(void) const
844  {return Prev;}
845 
850  inline LinkedList *getNext(void) const
851  {return static_cast<LinkedList*>(LinkedObject::getNext());}
852 
857  void insertTail(LinkedList *object);
858 
863  void insertHead(LinkedList *object);
864 
869  virtual void insert(LinkedList *object);
870 
875  inline void operator+=(LinkedList *object)
876  {insertTail(object);}
877 
882  inline void operator-=(LinkedList *object)
883  {insertHead(object);}
884 
889  inline void operator*=(LinkedList *object)
890  {insert(object);}
891 };
892 
898 class __EXPORT ObjectQueue : public OrderedIndex
899 {
900 public:
904  ObjectQueue();
905 
910  void add(DLinkedObject *object);
911 
916  void push(DLinkedObject *object);
917 
922  DLinkedObject *pull(void);
923 
928  DLinkedObject *pop(void);
929 };
930 
931 class __EXPORT ObjectStack
932 {
933 protected:
934  LinkedObject *root;
935 
936 public:
940  ObjectStack();
941 
946  ObjectStack(LinkedObject *list);
947 
952  void push(LinkedObject *object);
953 
958  LinkedObject *pull(void);
959 
964  inline LinkedObject *pop(void)
965  {return ObjectStack::pull();}
966 };
967 
968 
974 class __EXPORT MultiMap : public ReusableObject
975 {
976 private:
977  typedef struct {
978  const char *key;
979  size_t keysize;
980  MultiMap *next;
981  MultiMap **root;
982  } link_t;
983 
984  unsigned paths;
985  link_t *links;
986 
987 protected:
992  MultiMap(unsigned count);
993 
997  virtual ~MultiMap();
998 
1006  virtual bool equal(unsigned path, caddr_t key, size_t size) const;
1007 
1008 public:
1014  void enlist(unsigned path, MultiMap **root);
1015 
1024  void enlist(unsigned path, MultiMap **index, caddr_t key, unsigned size, size_t keysize = 0);
1025 
1030  void delist(unsigned path);
1031 
1036  MultiMap *next(unsigned path) const;
1037 
1045  static unsigned keyindex(caddr_t key, unsigned max, size_t size = 0);
1046 
1056  static MultiMap *find(unsigned path, MultiMap **index, caddr_t key, unsigned max, size_t size = 0);
1057 };
1058 
1066 template <typename T, class O=NamedObject>
1067 class named_value : public object_value<T, O>
1068 {
1069 public:
1075  inline named_value(LinkedObject **root, char *name)
1076  {LinkedObject::enlist(root); O::id = name;}
1077 
1082  inline void operator=(const T& typed_value)
1083  {this->set(typed_value);}
1084 
1091  inline static named_value find(named_value *first, const char *name)
1092  {return static_cast<named_value *>(NamedObject::find(first, name));}
1093 };
1094 
1103 template <typename T, class O=OrderedObject>
1104 class linked_value : public object_value<T, O>
1105 {
1106 public:
1110  inline linked_value() {}
1111 
1117  {LinkedObject::enlist(root);}
1118 
1124  {O::enlist(index);}
1125 
1131  inline linked_value(LinkedObject **root, const T& typed_value)
1132  {LinkedObject::enlist(root); this->set(typed_value);}
1133 
1139  inline linked_value(OrderedIndex *index, const T& typed_value)
1140  {O::enlist(index); this->set(typed_value);}
1141 
1146  inline void operator=(const T& typed_value)
1147  {this->set(typed_value);}
1148 };
1149 
1155 template <class T>
1156 class objstack : public ObjectStack
1157 {
1158 public:
1162  inline objstack() : ObjectStack() {}
1163 
1167  inline objstack(T *list) : ObjectStack(list) {}
1168 
1173  inline void push(T *object)
1174  {ObjectStack::push(object);}
1175 
1180  inline void add(T *object)
1181  {ObjectStack::push(object);}
1182 
1187  inline T *pull(void)
1188  {return (T *)ObjectStack::pull();}
1189 
1194  inline T *pop(void)
1195  {return (T *)ObjectStack::pull();}
1196 };
1197 
1204 template <class T>
1205 class objfifo : public OrderedIndex
1206 {
1207 public:
1211  inline objfifo() : OrderedIndex() {}
1212 
1217  inline void push(T *object)
1218  {OrderedIndex::add((OrderedObject *)object);}
1219 
1224  inline void add(T *object)
1225  {OrderedIndex::add((OrderedObject *)object);}
1226 
1231  inline T *pull(void)
1232  {return (T *)OrderedIndex::get();}
1233 
1238  inline T *pop(void)
1239  {return (T *)OrderedIndex::get();}
1240 };
1241 
1247 template <class T>
1248 class objqueue : public ObjectQueue
1249 {
1250 public:
1254  inline objqueue() : ObjectQueue() {}
1255 
1260  inline void push(T *object)
1261  {ObjectQueue::push((DLinkedObject *)object);}
1262 
1267  inline void add(T *object)
1268  {ObjectQueue::add((DLinkedObject *)object);}
1269 
1274  inline T *pull(void)
1275  {return (T *)ObjectQueue::pull();}
1276 
1281  inline T *pop(void)
1282  {return (T *)ObjectQueue::pop();}
1283 };
1284 
1291 template <class T>
1293 {
1294 private:
1295  T *ptr;
1296 
1297 public:
1303  {ptr = pointer;}
1304 
1310  {ptr = pointer.ptr;}
1311 
1317  {ptr = static_cast<T*>(pointer);}
1318 
1319  inline linked_pointer(const LinkedObject *pointer)
1320  {ptr = static_cast<T*>(pointer);}
1321 
1327  {ptr = static_cast<T*>(index->begin());}
1328 
1333  {ptr = NULL;}
1334 
1339  inline void operator=(T *pointer)
1340  {ptr = pointer;}
1341 
1347  {ptr = pointer.ptr;}
1348 
1353  inline void operator=(OrderedIndex *index)
1354  {ptr = static_cast<T*>(index->begin());}
1355 
1361  {ptr = static_cast<T*>(pointer);}
1362 
1367  inline T* operator->() const
1368  {return ptr;}
1369 
1374  inline T* operator*() const
1375  {return ptr;}
1376 
1381  inline operator T*() const
1382  {return ptr;}
1383 
1387  inline void prev(void)
1388  {ptr = static_cast<T*>(ptr->getPrev());}
1389 
1393  inline void next(void)
1394  {ptr = static_cast<T*>(ptr->getNext());}
1395 
1400  inline T *getNext(void) const
1401  {return static_cast<T*>(ptr->getNext());}
1402 
1408  inline T *getPrev(void) const
1409  {return static_cast<T*>(ptr->getPrev());}
1410 
1414  inline void operator++()
1415  {ptr = static_cast<T*>(ptr->getNext());}
1416 
1420  inline void operator--()
1421  {ptr = static_cast<T*>(ptr->getPrev());}
1422 
1427  inline bool is_next(void) const
1428  {return (ptr->getNext() != NULL);}
1429 
1434  inline bool is_prev(void) const
1435  {return (ptr->getPrev() != NULL);}
1436 
1441  inline operator bool() const
1442  {return (ptr != NULL);}
1443 
1448  inline bool operator!() const
1449  {return (ptr == NULL);}
1450 
1455  inline LinkedObject **root(void) const
1456  {T **r = &ptr; return (LinkedObject**)r;}
1457 };
1458 
1466 template <typename T, unsigned P>
1467 class multimap : public MultiMap
1468 {
1469 protected:
1470  T value;
1471 
1472 public:
1476  inline multimap() : MultiMap(P) {}
1477 
1481  inline ~multimap() {}
1482 
1487  inline T &get(void) const
1488  {return value;}
1489 
1495  inline multimap *next(unsigned path)
1496  {return static_cast<multimap*>(MultiMap::next(path));}
1497 
1502  inline T& operator*() const
1503  {return value;}
1504 
1509  inline void setPointer(const T pointer)
1510  {value = pointer;}
1511 
1516  inline void set(const T &reference)
1517  {value = reference;}
1518 
1523  inline void operator=(const T& data)
1524  {value = data;}
1525 
1535  inline static multimap *find(unsigned path, MultiMap **index, caddr_t key, unsigned size, unsigned keysize = 0)
1536  {return static_cast<multimap*>(MultiMap::find(path, index, key, size, keysize));}
1537 };
1538 
1556 template <typename T>
1557 class treemap : public NamedTree
1558 {
1559 protected:
1560  T value;
1561 
1562 public:
1568  inline treemap(char *name = NULL) : NamedTree(name) {}
1569 
1574  inline treemap(const treemap& source) : NamedTree(source)
1575  {value = source.value;};
1576 
1582  inline treemap(treemap *parent, char *name) : NamedTree(parent, name) {}
1583 
1590  inline treemap(treemap *parent, char *name, T& reference) :
1591  NamedTree(parent, name) {value = reference;}
1592 
1597  inline const T& get(void) const
1598  {return value;}
1599 
1604  inline const T& operator*() const
1605  {return value;}
1606 
1612  static inline T getPointer(treemap *node)
1613  {return (node == NULL) ? NULL : node->value;}
1614 
1619  inline bool is_attribute(void) const
1620  {return (!Child.begin() && value != NULL);}
1621 
1626  inline const T getPointer(void) const
1627  {return value;}
1628 
1633  inline const T& getData(void) const
1634  {return value;}
1635 
1640  inline void setPointer(const T pointer)
1641  {value = pointer;}
1642 
1647  inline void set(const T& reference)
1648  {value = reference;}
1649 
1654  inline void operator=(const T& data)
1655  {value = data;}
1656 
1662  inline treemap *getIndexed(unsigned index) const
1663  {return static_cast<treemap*>(Child.getIndexed(index));}
1664 
1669  inline treemap *getParent(void) const
1670  {return static_cast<treemap*>(Parent);}
1671 
1678  inline treemap *getChild(const char *name) const
1679  {return static_cast<treemap*>(NamedTree::getChild(name));}
1680 
1687  inline treemap *getLeaf(const char *name) const
1688  {return static_cast<treemap*>(NamedTree::getLeaf(name));}
1689 
1697  inline T getValue(const char *name) const
1698  {return getPointer(getLeaf(name));}
1699 
1706  inline treemap *find(const char *name) const
1707  {return static_cast<treemap*>(NamedTree::find(name));}
1708 
1715  inline treemap *path(const char *path) const
1716  {return static_cast<treemap*>(NamedTree::path(path));}
1717 
1724  inline treemap *leaf(const char *name) const
1725  {return static_cast<treemap*>(NamedTree::leaf(name));}
1726 
1731  inline treemap *getFirst(void) const
1732  {return static_cast<treemap*>(NamedTree::getFirst());}
1733 };
1734 
1742 template <class T, unsigned M = 177>
1743 class keymap
1744 {
1745 private:
1746  NamedObject *idx[M];
1747 
1748 public:
1752  inline ~keymap()
1753  {NamedObject::purge(idx, M);}
1754 
1759  inline NamedObject **root(void) const
1760  {return idx;}
1761 
1766  inline unsigned limit(void) const
1767  {return M;}
1768 
1774  inline T *get(const char *name) const
1775  {return static_cast<T*>(NamedObject::map(idx, name, M));}
1776 
1782  inline T& operator[](const char *name) const
1783  {return static_cast<T*>(NamedObject::map(idx, name, M));}
1784 
1790  inline void add(const char *name, T& object)
1791  {object.NamedObject::add(idx, name, M);}
1792 
1798  inline void add(const char *name, T *object)
1799  {object->NamedObject::add(idx, name, M);}
1800 
1806  inline T *remove(const char *name)
1807  {return static_cast<T*>(NamedObject::remove(idx, name, M));}
1808 
1813  inline T *begin(void) const
1814  {return static_cast<T*>(NamedObject::skip(idx, NULL, M));}
1815 
1821  inline T *next(T *current) const
1822  {return static_cast<T*>(NamedObject::skip(idx, current, M));}
1823 
1828  inline unsigned count(void) const
1829  {return NamedObject::count(idx, M);}
1830 
1837  inline T **index(void) const
1838  {return NamedObject::index(idx, M);}
1839 
1846  inline T **sort(void) const
1847  {return NamedObject::sort(NamedObject::index(idx, M));}
1848 
1853 };
1854 
1861 template <class T>
1862 class keylist : public OrderedIndex
1863 {
1864 public:
1869  inline NamedObject **root(void)
1870  {return static_cast<NamedObject**>(&head);}
1871 
1877  inline T *begin(void)
1878  {return static_cast<T*>(head);}
1879 
1885  inline T *end(void)
1886  {return static_cast<T*>(tail);}
1887 
1894  inline T *create(const char *name)
1895  {return new T(this, name);}
1896 
1902  inline T *next(LinkedObject *current)
1903  {return static_cast<T*>(current->getNext());}
1904 
1910  inline T *find(const char *name)
1911  {return static_cast<T*>(NamedObject::find(begin(), name));}
1912 
1913  inline T *offset(unsigned offset)
1914  {return static_cast<T*>(OrderedIndex::find(offset));}
1915 
1921  inline T& operator[](unsigned offset)
1922  {return static_cast<T&>(OrderedIndex::find(offset));}
1923 
1924  inline T& operator[](const char *name)
1925  {return static_cast<T&>(NamedObject::find(begin(), name));}
1926 
1933  inline T **index(void)
1934  {return static_cast<T**>(OrderedIndex::index());}
1935 
1942  inline T **sort(void)
1943  {return static_cast<T**>(NamedObject::sort(index()));}
1944 
1949 };
1950 
1955 
1959 typedef ObjectStack objstack_t;
1960 
1965 
1970 
1971 } // namespace ucommon
1972 
1973 #endif
T getValue(const char *name) const
Get the value pointer of a leaf node of a pointer tree.
Definition: linked.h:1697
void add(DLinkedObject *object)
Add an object to the end of the queue.
LinkedObject ** root(void) const
Return pointer to our linked pointer to use as root node of a chain.
Definition: linked.h:1455
bool equal(const char *name) const
Equal function which calls compare.
Definition: linked.h:562
static NamedObject ** sort(NamedObject **list, size_t count=0)
Sort an array of named objects in alphabetical order.
T * find(const char *name)
Find a specific object by name.
Definition: linked.h:1910
linked_pointer< T > iterator
Convenience typedef for iterative pointer.
Definition: linked.h:1852
void add(T *object)
Add an object onto the object fifo.
Definition: linked.h:1224
T ** index(void)
Convert our linked list into a linear object pointer array.
Definition: linked.h:1933
T ** index(void) const
Convert our hash map into a linear object pointer array.
Definition: linked.h:1837
void next(void)
Move (iterate) pointer to next member in linked list.
Definition: linked.h:1393
T * pull(void)
Pull an object from the start of the object queue.
Definition: linked.h:1274
A linked object base class with members found by name.
Definition: linked.h:400
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
Definition: linked.h:1509
void operator=(const T &typed_value)
Assign embedded value from related type.
Definition: linked.h:1082
void set(const T &reference)
Set the value of a data based value tree.
Definition: linked.h:1516
void operator=(linked_pointer &pointer)
Assign our pointer from another pointer.
Definition: linked.h:1346
void retain(ObjectProtocol *object)
Convenience function to access object retention.
Definition: object.h:465
T * operator->() const
Return member from typed object our pointer references.
Definition: linked.h:1367
NamedTree * getFirst(void) const
Get first child node in our ordered list of children.
Definition: linked.h:681
OrderedObject * getNext(void) const
Get next ordered member when iterating.
Definition: linked.h:358
objfifo()
Create a new object stack.
Definition: linked.h:1211
objqueue()
Create a new object stack.
Definition: linked.h:1254
bool is_root(void) const
Test if node is root node.
Definition: linked.h:744
static NamedObject * find(NamedObject *root, const char *name)
Find a named object from a simple list.
static NamedObject * skip(NamedObject **hash, NamedObject *current, unsigned size)
Iterate through a hash map table.
LinkedObject * get(void)
Get (pull) object off the list.
void push(T *object)
Push an object to start of queue.
Definition: linked.h:1260
LinkedObject * end(void) const
Return last object in list for iterators.
Definition: linked.h:279
void operator+=(LinkedList *object)
Insert object behind our object.
Definition: linked.h:875
T * next(LinkedObject *current)
Iterate next object in list.
Definition: linked.h:1902
A common base class for all managed objects.
Definition: protocols.h:544
treemap * leaf(const char *name) const
Search for a leaf node of our node.
Definition: linked.h:1724
LinkedObject * find(unsigned offset) const
Find a specific member in the ordered list.
T * begin(void) const
Find first typed object in hash map to iterate.
Definition: linked.h:1813
NamedObject ** root(void) const
Retrieve root of index to use in NamedObject constructors.
Definition: linked.h:1759
named_value(LinkedObject **root, char *name)
Construct embedded named object on a linked list.
Definition: linked.h:1075
Generic smart pointer class.
Definition: generics.h:56
DLinkedObject * pop(void)
Pop an object from the end of the queue.
char * getId(void) const
Get the named id string of this object.
Definition: linked.h:545
const T getPointer(void) const
Get the pointer of a pointer based value tree.
Definition: linked.h:1626
void operator=(OrderedIndex *index)
Assign our pointer from the start of an ordered index.
Definition: linked.h:1353
treemap * getIndexed(unsigned index) const
Get child member node by index.
Definition: linked.h:1662
A template class for a hash map.
Definition: linked.h:1743
T * getNext(void) const
Get the next member in linked list.
Definition: linked.h:1400
~multimap()
Destroy a multimap object.
Definition: linked.h:1481
linked_pointer(OrderedIndex *index)
Create a linked pointer to examine an ordered index.
Definition: linked.h:1326
treemap(treemap *parent, char *name)
Construct a child node on an existing tree.
Definition: linked.h:1582
NamedObject * getNext(void) const
Get next effective object when iterating.
Definition: linked.h:538
linked_pointer(LinkedObject *pointer)
Create a linked pointer assigned from a raw linked object pointer.
Definition: linked.h:1316
void push(DLinkedObject *object)
Push an object to the front of the queue.
NamedTree * find(const char *name) const
Find a child node of our object with the specified name.
linked_pointer< T > iterator
Convenience typedef for iterative pointer.
Definition: linked.h:1948
void add(OrderedObject *ordered)
Add an object into the ordered index.
const T & getData(void) const
Get the data value of a data based value tree.
Definition: linked.h:1633
treemap * path(const char *path) const
Find a subnode by pathname.
Definition: linked.h:1715
T * pull(void)
Pull an object from the object stack.
Definition: linked.h:1187
objstack()
Create a new object stack.
Definition: linked.h:1162
Common namespace for all ucommon objects.
bool operator==(const char *name) const
Comparison operator between our name and a string.
Definition: linked.h:570
void operator*=(LinkedList *object)
Insert object in list with our object.
Definition: linked.h:889
A linked object base class for ordered objects.
Definition: linked.h:309
bool operator!() const
Test if linked list is empty/we are at end of list.
Definition: linked.h:1448
T & operator[](unsigned offset)
Retrieve a specific object by position in list.
Definition: linked.h:1921
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
Definition: linked.h:1640
T * operator*() const
Return object we currently point to.
Definition: linked.h:1374
T ** sort(void) const
Convert our hash map into an alphabetically sorted linear object pointer array.
Definition: linked.h:1846
Template value class to embed data structure into a linked list.
Definition: linked.h:1104
void push(T *object)
Push an object onto the object stack.
Definition: linked.h:1173
linked_value(LinkedObject **root)
Construct embedded object on a linked list.
Definition: linked.h:1116
static const LinkedObject * nil
Marker for end of linked list.
Definition: linked.h:82
bool is_attribute(void) const
Test if this node is a leaf node for a tree pointer table.
Definition: linked.h:1619
A smart pointer template for iterating linked lists.
Definition: linked.h:1292
NamedTree * getParent(void) const
Get parent node we are listed as a child on.
Definition: linked.h:688
Template for typesafe basic object queue container.
Definition: linked.h:1248
void operator=(const T &typed_value)
Assign embedded value from related type.
Definition: linked.h:1146
bool is_leaf(void) const
Test if node has children.
Definition: linked.h:737
static NamedObject * map(NamedObject **hash, const char *name, unsigned size)
Find a named object through a hash map table.
treemap * getLeaf(const char *name) const
Find a direct typed leaf node on our node.
Definition: linked.h:1687
Common base class for all objects that can be formed into a linked list.
Definition: linked.h:58
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
Definition: access.h:260
linked_value(LinkedObject **root, const T &typed_value)
Assign embedded value from related type and link to list.
Definition: linked.h:1131
treemap(char *name=((void *) 0))
Construct a typed root node for the tree.
Definition: linked.h:1568
bool is_tail(void) const
Test if we are at the end of a list.
Definition: linked.h:836
objstack(T *list)
Create an object stack from a list of objects.
Definition: linked.h:1167
static void purge(NamedObject **hash, unsigned size)
Purge a hash indexed table of named objects.
A template for ordered index of typed name key mapped objects.
Definition: linked.h:1862
bool is_prev(void) const
Test for previous member in double linked list.
Definition: linked.h:1434
void operator--()
Move (iterate) pointer to previous member in double linked list.
Definition: linked.h:1420
NamedTree * getLeaf(const char *name) const
Find a direct leaf node on our node.
bool operator!() const
Test if this node is unnamed.
Definition: linked.h:717
Various miscellaneous platform specific headers and defines.
Template value class to embed data structure into a named list.
Definition: linked.h:1067
A double-linked Object, used for certain kinds of lists.
Definition: linked.h:366
void set(const T &reference)
Set the value of a data based value tree.
Definition: linked.h:1647
multimap * next(unsigned path)
Return next multimap typed object.
Definition: linked.h:1495
Template for embedding a data structure into a reference counted object.
Definition: object.h:315
LinkedList * getNext(void) const
Get next node in the list when iterating.
Definition: linked.h:850
treemap(const treemap &source)
Construct a copy of the treemap object.
Definition: linked.h:1574
OrderedIndex & operator=(const OrderedIndex &object)
Assign ordered index.
Definition: linked.h:293
treemap * getParent(void) const
Get the typed parent node for our node.
Definition: linked.h:1669
T * create(const char *name)
Create a new typed named object with default constructor.
Definition: linked.h:1894
T * pop(void)
Pull (pop) an object from the object stack.
Definition: linked.h:1194
ReusableObject * getNext(void)
Get next effective reusable object when iterating.
Definition: linked.h:168
T ** sort(void)
Convert our linked list into an alphabetically sorted linear object pointer array.
Definition: linked.h:1942
void add(T *object)
Add an object to the end of the object queue.
Definition: linked.h:1267
static LinkedObject * getIndexed(LinkedObject *root, unsigned index)
Get member by index.
Template for typesafe basic object fifo container.
Definition: linked.h:1205
void set(const T &object)
Assign our value from a typed data object.
Definition: object.h:322
Embed data objects into a multipap structured memory database.
Definition: linked.h:1467
linked_pointer()
Create a linked pointer not attached to a list.
Definition: linked.h:1332
static named_value find(named_value *first, const char *name)
Find embedded object in chain by name.
Definition: linked.h:1091
void operator++()
Move (iterate) pointer to next member in linked list.
Definition: linked.h:1414
linked_value(OrderedIndex *index, const T &typed_value)
Assign embedded value from related type and add to list.
Definition: linked.h:1139
An index container for maintaining an ordered list of objects.
Definition: linked.h:179
void relist(NamedTree *trunk=((void *) 0))
Default relist is by tail...
Definition: linked.h:763
Embed data objects into a tree structured memory database.
Definition: linked.h:1557
LinkedObject * begin(void) const
Return first object in list for iterators.
Definition: linked.h:272
T & operator[](const char *name) const
Find a typed object derived from NamedObject in the hash map by name.
Definition: linked.h:1782
T * getPrev(void) const
Get the previous member in double linked list.
Definition: linked.h:1408
T * pull(void)
Pull an object from the object stack.
Definition: linked.h:1231
Reusable objects for forming private heaps.
Definition: linked.h:156
NamedTree * getChild(const char *name) const
Find a direct child of our node which matches the specified name.
unsigned count(void) const
Count the number of typed objects in our hash map.
Definition: linked.h:1828
static unsigned count(NamedObject **hash, unsigned size)
Count the total named objects in a hash table.
LinkedObject * getNext(void) const
Get next effective object when iterating.
Definition: linked.h:143
const T & operator*() const
Return typed value of this node by pointer reference.
Definition: linked.h:1604
static T getPointer(treemap *node)
Return value from tree element when value is a pointer.
Definition: linked.h:1612
The named tree class is used to form a tree oriented list of associated objects.
Definition: linked.h:589
bool is_head(void) const
Test if we are at the head of a list.
Definition: linked.h:829
LinkedObject ** index(void) const
Return a pointer to the head of the list.
bool operator!=(const char *name) const
Comparison operator between our name and a string.
Definition: linked.h:578
ObjectStack objstack_t
Convenience type for a stack of linked objects.
Definition: linked.h:1959
A double linked list object.
Definition: linked.h:773
static MultiMap * find(unsigned path, MultiMap **index, caddr_t key, unsigned max, size_t size=0)
Find a multikey node.
void add(const char *name, T &object)
Add a typed object derived from NamedObject to the hash map by name.
Definition: linked.h:1790
treemap(treemap *parent, char *name, T &reference)
Construct a child node on an existing tree and assign it's value.
Definition: linked.h:1590
linked_value(OrderedIndex *index)
Construct embedded object on an ordered list.
Definition: linked.h:1123
linked_pointer(const linked_pointer &pointer)
Create a copy of an existing linked pointer.
Definition: linked.h:1309
DLinkedObject * pull(void)
Pull an object from the front of the queue.
LinkedList * getPrev(void) const
Get previous node in the list for reverse iteration.
Definition: linked.h:843
T &() max(T &o1, T &o2)
Convenience function to return max of two objects.
Definition: generics.h:543
~keymap()
Destroy the hash map by puring the index chains.
Definition: linked.h:1752
ObjectQueue objqueue_t
Convenience type for a queue of linked objects.
Definition: linked.h:1969
NamedObject ** root(void)
Return a root node pointer to use in NamedObject constructors.
Definition: linked.h:1869
LinkedObject * operator*() const
Return head object pointer.
Definition: linked.h:286
treemap * getChild(const char *name) const
Get direct typed child node of our node of specified name.
Definition: linked.h:1678
OrderedIndex objfifo_t
Convenience type for a fifo of linked objects.
Definition: linked.h:1964
LinkedObject * getIndexed(unsigned index) const
Get an indexed member from the ordered index.
Definition: linked.h:265
NamedTree * leaf(const char *name) const
Find a child leaf node of our object with the specified name.
linked_pointer(T *pointer)
Create a linked pointer and assign to start of a list.
Definition: linked.h:1302
unsigned limit(void) const
Retrieve key size to use in NamedObject constructors.
Definition: linked.h:1766
treemap * find(const char *name) const
Find a subnode from our node by name.
Definition: linked.h:1706
void enlist(LinkedObject **root)
Add our object to an existing linked list through a pointer.
T * pop(void)
Pull (pop) an object from the object stack.
Definition: linked.h:1238
static NamedObject ** index(NamedObject **hash, unsigned size)
Convert a hash index into a linear object pointer array.
NamedTree * getIndexed(unsigned index) const
Get child by index number.
Definition: linked.h:696
static NamedObject * remove(NamedObject **root, const char *name)
Remove a named object from a simple list.
void operator=(const T &data)
Assign the value of our node.
Definition: linked.h:1654
void operator=(LinkedObject *pointer)
Assign our pointer from a generic linked object pointer.
Definition: linked.h:1360
void push(T *object)
Push an object onto the object fifo.
Definition: linked.h:1217
OrderedIndex * getIndex(void) const
Get the ordered index of our child nodes.
Definition: linked.h:703
void operator-=(LinkedList *object)
Insert object in front of our object.
Definition: linked.h:882
T * next(T *current) const
Find next typed object in hash map for iteration.
Definition: linked.h:1821
T & operator*() const
Return typed value of this node by pointer reference.
Definition: linked.h:1502
treemap * getFirst(void) const
Get first child of our node.
Definition: linked.h:1731
A queue of double linked object.
Definition: linked.h:898
void operator=(const T &data)
Assign the value of our node.
Definition: linked.h:1523
A multipath linked list where membership is managed in multiple lists.
Definition: linked.h:974
T * end(void)
Return last item in ordered list.
Definition: linked.h:1885
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
Definition: object.h:479
LinkedObject * LinkedIndex
Convenience typedef for root pointers of single linked lists.
Definition: linked.h:1954
bool is_next(void) const
Test for next member in linked list.
Definition: linked.h:1427
NamedTree * path(const char *path) const
Find a subnode by a dot separated list of node names.
void add(const char *name, T *object)
Add a typed object derived from NamedObject to the hash map by name.
Definition: linked.h:1798
static const LinkedObject * inv
Marker for invalid list pointer.
Definition: linked.h:83
T * begin(void)
Return first item in ordered list.
Definition: linked.h:1877
T * pop(void)
Pop an object from the end of the object queue.
Definition: linked.h:1281
void prev(void)
Move (iterate) pointer to previous member in double linked list.
Definition: linked.h:1387
MultiMap * next(unsigned path) const
Get next node from single chain.
Template for typesafe basic object stack container.
Definition: linked.h:1156
static multimap * find(unsigned path, MultiMap **index, caddr_t key, unsigned size, unsigned keysize=0)
Find multimap key entry.
Definition: linked.h:1535
void operator=(T *pointer)
Assign our typed iterative pointer from a matching typed object.
Definition: linked.h:1339
linked_value()
Create embedded value object unlinked.
Definition: linked.h:1110
void add(T *object)
Add an object onto the object stack.
Definition: linked.h:1180
Class for resource bound memory pools between threads.
Definition: thread.h:708
A common object base class with auto-pointer support.
multimap()
Construct a multimap node.
Definition: linked.h:1476