sipxportlib  Version 3.3
Friends | List of all members
UtlLink Class Reference

#include <UtlLink.h>

Inheritance diagram for UtlLink:
Inheritance graph
[legend]
Collaboration diagram for UtlLink:
Collaboration graph
[legend]

Friends

class UtlChainPool
 
class UtlContainer
 
class UtlList
 
class UtlListIterator
 
class UtlSList
 
class UtlSListIterator
 
class UtlSortedList
 
class UtlHashBag
 
class UtlHashBagIterator
 
class UtlLinkTest
 
class UtlInit
 

Traversal Operations

These methods move forward and back in a chain of UtlLinks.

UtlContainabledata
 The containable object whose place in the list this UtlLink is tracking. More...
 
unsigned hash
 The hash code for the containable object whose place in the list this UtlLink is tracking. More...
 
UtlLinknext () const
 Returns the next UtlLink forward in a chain (or NULL for the end). More...
 
UtlLinkprev () const
 Returns the next UtlLink backward in a chain (or NULL for the end). More...
 
UtlLinkfindDataRef (UtlContainable *target) const
 Linear search starting at this link for a matching data value. More...
 
UtlLinkfindNextHash (unsigned targetHash) const
 Linear search starting at this link for a matching data value. More...
 

Memory Management

static size_t totalAllocated ()
 Get the total number of UtlLink blocks allocated. More...
 

Link Manipulation in a Chain

These methods insert and remove this UtlLink in a chain. They do not do any special handling for the ends of a chain, so they can be used in either NULL-terminated or circular chains.

UtlContainableunlink ()
 Take the link block out of its list, and return the data pointer. More...
 
static UtlLinkbefore (UtlChain *existing, UtlContainable *newData)
 Insert a new UtlLink to newData before existing, returning the new UtlLink. More...
 
static UtlLinkafter (UtlChain *existing, UtlContainable *newData)
 Insert a new UtlLink to newData after existing, returning the new UtlLink. More...
 

List Operations

These methods do the special handling for using a UtlChain as a list header. The UtlChain.next points to the head (first) UtlLink on the list. The UtlChain.prev points to the tail (last) UtlLink.

The UtlLink objects on the list form a NULL-terminated chain - they do not point to the UtlChain that serves as the header.

UtlContainabledetachFrom (UtlChain *listHead)
 Remove a link from a list. More...
 
static UtlLinklistBefore (UtlChain *list, UtlChain *existing, UtlContainable *newData)
 Insert a new item into a list before an existing entry (before NULL == at the tail). More...
 
static UtlLinklistAfter (UtlChain *list, UtlChain *existing, UtlContainable *newData)
 Insert a new item into a list before an existing entry (after NULL == at the head). More...
 
static UtlLinkfindData (UtlChain *list, UtlContainable *target)
 Find the first matching target in the list by reference. More...
 

Constructor and Destructor

See also
UtlLinkPool for how a UtlLink is allocated and freed.
 UtlLink ()
 The UtlLink constructor is protected. More...
 
 ~UtlLink ()
 Destructor. More...
 
void release ()
 Return a UtlLink to the pool. More...
 
void rehash ()
 Recalculate the hash for this item. More...
 
static UtlLinkget ()
 Get a UtlLink from the pool. More...
 

Additional Inherited Members

- Public Member Functions inherited from UtlChain
 UtlChain ()
 Constructor initializes to unlinked. More...
 
 ~UtlChain ()
 Destructor. More...
 
- Protected Member Functions inherited from UtlChain
bool isUnLinked () const
 Is this block not linked to anything? More...
 
void unchain ()
 Take the link out of its chain. More...
 
void chainBefore (UtlChain *existing)
 Insert a new UtlChain before existing. More...
 
void chainAfter (UtlChain *existing)
 Insert a new UtlChain after existing.. More...
 
UtlChainlistHead () const
 Returns the head (first) UtlLink on the list (or NULL if the list is empty). More...
 
UtlChainlistTail () const
 Returns the tail (last) UtlLink on the list (or NULL if the list is empty). More...
 
UtlLinkhead () const
 Returns the head (first) UtlLink on the list (or NULL if the list is empty). More...
 
UtlLinktail () const
 Returns the tail (last) UtlLink on the list (or NULL if the list is empty). More...
 
void listBefore (UtlChain *list, UtlChain *existing)
 Insert this link into a list before an existing entry (before NULL == at the tail). More...
 
void listAfter (UtlChain *list, UtlChain *existing)
 Insert this link into a list after an existing entry (after NULL == at the head). More...
 
UtlChaindetachFromList (UtlChain *listHead)
 Remove a link from a list. More...
 
- Protected Attributes inherited from UtlChain
UtlChainprev
 backward chain pointer More...
 
UtlChainnext
 forward chain pointer More...
 

Detailed Description

UtlLink implements linked lists of data blocks. It may not be used directly because it is not thread safe; use one of the classes derived from UtlList.

In addition to the links forward (next) and backward (prev) provided by the parent UtlChain, a UtlLink also points to an item whose place it implements in the list (data).

Constructor & Destructor Documentation

UtlLink ( )
inlineprotected

The UtlLink constructor is protected.

A UtlLink should only be instantiated by a call to UtlLinkPool::get because the UtlLinkPool recycles them rather than allocating and deallocating from the system heap.

~UtlLink ( )
inlineprotected

Destructor.

A UtlLink is only destructed when the UtlLinkPool destructor is invoked.

Member Function Documentation

UtlLink* next ( ) const
inline

Returns the next UtlLink forward in a chain (or NULL for the end).

UtlLink* prev ( ) const
inline

Returns the next UtlLink backward in a chain (or NULL for the end).

UtlLink* findDataRef ( UtlContainable target) const
inline

Linear search starting at this link for a matching data value.

UtlLink* findNextHash ( unsigned  targetHash) const
inline

Linear search starting at this link for a matching data value.

size_t totalAllocated ( )
static

Get the total number of UtlLink blocks allocated.

Because the underlying UtlLinkPool implementation allocates UtlLinks in blocks, this number will usually be slightly higher than the maximum number ever in use (rounded up to the nearest UTLLINK_BLOCK_SIZE)

UtlContainable * unlink ( )
protected

Take the link block out of its list, and return the data pointer.

Note
After this call, the UtlLink has been released, and the pointer to it may not be used.
UtlLink * before ( UtlChain existing,
UtlContainable newData 
)
staticprotected

Insert a new UtlLink to newData before existing, returning the new UtlLink.

UtlLink * after ( UtlChain existing,
UtlContainable newData 
)
staticprotected

Insert a new UtlLink to newData after existing, returning the new UtlLink.

UtlLink * listBefore ( UtlChain list,
UtlChain existing,
UtlContainable newData 
)
staticprotected

Insert a new item into a list before an existing entry (before NULL == at the tail).

Note
This method does not verify that the existing element is actually on the list; doing so is the responsibility of the caller. If the list is empty, existing must be NULL.
Parameters
listthe list to insert into
existingthe UtlLink for the position in the list to insert before. NULL means at the end of the list.
newDatathe new data item to be inserted.
UtlLink * listAfter ( UtlChain list,
UtlChain existing,
UtlContainable newData 
)
staticprotected

Insert a new item into a list before an existing entry (after NULL == at the head).

Note
This method does not verify that the existing element is actually on the list; doing so is the responsibility of the caller. If the list is empty, existing must be NULL.
Parameters
listthe list to insert into
existingthe UtlLink for the position in the list to insert after. NULL means at the beginning of the list.
newDatathe new data item to be inserted.
UtlContainable * detachFrom ( UtlChain listHead)
protected

Remove a link from a list.

Note
This method does not verify that the UtlLink object being detached is actually on the specified list; doing so is the responsibility of the caller.
static UtlLink* findData ( UtlChain list,
UtlContainable target 
)
inlinestaticprotected

Find the first matching target in the list by reference.

UtlLink * get ( )
staticprotected

Get a UtlLink from the pool.

void release ( void  )
protected

Return a UtlLink to the pool.

void rehash ( )
protected

Recalculate the hash for this item.

Friends And Related Function Documentation

friend class UtlChainPool
friend
friend class UtlContainer
friend
friend class UtlList
friend
friend class UtlListIterator
friend
friend class UtlSList
friend
friend class UtlSListIterator
friend
friend class UtlSortedList
friend
friend class UtlHashBag
friend
friend class UtlHashBagIterator
friend
friend class UtlLinkTest
friend
friend class UtlInit
friend

Member Data Documentation

The containable object whose place in the list this UtlLink is tracking.

unsigned hash

The hash code for the containable object whose place in the list this UtlLink is tracking.