UCommon
Public Types | Public Member Functions
ucommon::keylist< T > Class Template Reference

A template for ordered index of typed name key mapped objects. More...

#include <linked.h>

Inheritance diagram for ucommon::keylist< T >:
Inheritance graph
[legend]
Collaboration diagram for ucommon::keylist< T >:
Collaboration graph
[legend]

Public Types

typedef linked_pointer< T > iterator
 Convenience typedef for iterative pointer.
 

Public Member Functions

T * begin (void)
 Return first item in ordered list. More...
 
T * create (const char *name)
 Create a new typed named object with default constructor. More...
 
T * end (void)
 Return last item in ordered list. More...
 
T * find (const char *name)
 Find a specific object by name. More...
 
T ** index (void)
 Convert our linked list into a linear object pointer array. More...
 
T * next (LinkedObject *current)
 Iterate next object in list. More...
 
T * offset (unsigned offset)
 
T & operator[] (unsigned offset)
 Retrieve a specific object by position in list. More...
 
T & operator[] (const char *name)
 
NamedObject ** root (void)
 Return a root node pointer to use in NamedObject constructors. More...
 
T ** sort (void)
 Convert our linked list into an alphabetically sorted linear object pointer array. More...
 
- Public Member Functions inherited from ucommon::OrderedIndex
void add (OrderedObject *ordered)
 Add an object into the ordered index. More...
 
LinkedObjectbegin (void) const
 Return first object in list for iterators. More...
 
unsigned count (void) const
 Count of objects this list manages. More...
 
LinkedObjectend (void) const
 Return last object in list for iterators. More...
 
LinkedObjectfind (unsigned offset) const
 Find a specific member in the ordered list. More...
 
LinkedObjectget (void)
 Get (pull) object off the list. More...
 
LinkedObjectgetIndexed (unsigned index) const
 Get an indexed member from the ordered index. More...
 
LinkedObject ** index (void) const
 Return a pointer to the head of the list. More...
 
virtual void lock_index (void)
 Used to synchronize lists managed by multiple threads. More...
 
LinkedObjectoperator* () const
 Return head object pointer. More...
 
void operator*= (OrderedObject *object)
 Add object to our list. More...
 
OrderedIndexoperator= (const OrderedIndex &object)
 Assign ordered index. More...
 
 OrderedIndex ()
 Create and initialize an empty index.
 
 OrderedIndex (const OrderedIndex &source)
 
void purge (void)
 Purge the linked list and then set the index to empty.
 
void reset (void)
 Reset linked list to empty without purging.
 
virtual void unlock_index (void)
 Used to synchronize lists managed by multiple threads. More...
 
virtual ~OrderedIndex ()
 Destroy index.
 

Additional Inherited Members

- Protected Member Functions inherited from ucommon::OrderedIndex
void copy (const OrderedIndex &source)
 
- Protected Attributes inherited from ucommon::OrderedIndex
OrderedObjecthead
 
OrderedObjecttail
 

Detailed Description

template<class T>
class ucommon::keylist< T >

A template for ordered index of typed name key mapped objects.

This is used to hold an iterable linked list of typed named objects where we can find objects by their name as well as through iteration.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 1858 of file linked.h.

Member Function Documentation

template<class T >
T* ucommon::keylist< T >::begin ( void  )
inline

Return first item in ordered list.

This is commonly used to iterate the list.

Returns
first item in list or NULL if empty.

Definition at line 1873 of file linked.h.

template<class T >
T* ucommon::keylist< T >::create ( const char *  name)
inline

Create a new typed named object with default constructor.

This creates a new object which can be deleted.

Parameters
nameof object to create.
Returns
typed named object.

Definition at line 1890 of file linked.h.

template<class T >
T* ucommon::keylist< T >::end ( void  )
inline

Return last item in ordered list.

This is commonly used to determine end of list iteration.

Returns
last item in list or NULL if empty.

Definition at line 1881 of file linked.h.

template<class T >
T* ucommon::keylist< T >::find ( const char *  name)
inline

Find a specific object by name.

Parameters
nameto search for.
Returns
type named object that matches or NULL if not found.

Definition at line 1906 of file linked.h.

template<class T >
T** ucommon::keylist< T >::index ( void  )
inline

Convert our linked list into a linear object pointer array.

The object pointer array is created from the heap and must be deleted when no longer used.

Returns
array of typed named object pointers.

Definition at line 1929 of file linked.h.

template<class T >
T* ucommon::keylist< T >::next ( LinkedObject current)
inline

Iterate next object in list.

Parameters
currentobject we are referencing.
Returns
next logical object in linked list or NULL if end.

Definition at line 1898 of file linked.h.

Here is the call graph for this function:

template<class T >
T& ucommon::keylist< T >::operator[] ( unsigned  offset)
inline

Retrieve a specific object by position in list.

Parameters
offsetin list for object we want.
Returns
type named object or NULL if past end of list.

Definition at line 1917 of file linked.h.

template<class T >
NamedObject** ucommon::keylist< T >::root ( void  )
inline

Return a root node pointer to use in NamedObject constructors.

Returns
pointer to index root.

Definition at line 1865 of file linked.h.

template<class T >
T** ucommon::keylist< T >::sort ( void  )
inline

Convert our linked list into an alphabetically sorted linear object pointer array.

The object pointer array is created from the heap and must be deleted when no longer used.

Returns
array of typed named object pointers.

Definition at line 1938 of file linked.h.


The documentation for this class was generated from the following file: