sipxportlib  Version 3.3
Public Member Functions | Protected Attributes | Friends | List of all members
UtlChain Class Reference

#include <UtlLink.h>

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

Public Member Functions

 UtlChain ()
 Constructor initializes to unlinked. More...
 
 ~UtlChain ()
 Destructor. More...
 

Protected Member Functions

Chain Operations

These methods manipulate the forward and backward links within a chain. They do no do anything with respect to any header, so they can be used to implement chains that are linear (NULL terminated) or circular.

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...
 
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.

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

UtlChainprev
 backward chain pointer More...
 
UtlChainnext
 forward chain pointer More...
 

Friends

class UtlChainPool
 
class UtlLink
 
class UtlPair
 
class UtlContainer
 
class UtlList
 
class UtlHashMap
 
class UtlHashMapIterator
 
class UtlHashBag
 
class UtlHashBagIterator
 
class UtlChainTest
 
class UtlLinkTest
 

Detailed Description

UtlChain is the internal class that implements the linked list blocks for other Utl classes. It may not be used directly because by itself it is not thread safe. Use one of the lists types derived from UtlList.

Each UltLinkChain links forward (next) and backward (prev) in the chain of links; ends of a chain are indicated by NULL values. A UtlChain not in a chain, including a newly constructed instance, have NULL pointers in both directions.

A UtlChain can also be used as a list header whose links point to the ends of a NULL terminated list.

Constructor & Destructor Documentation

UtlChain ( )
inline

Constructor initializes to unlinked.

~UtlChain ( )
inline

Destructor.

Member Function Documentation

bool isUnLinked ( ) const
inlineprotected

Is this block not linked to anything?

void unchain ( )
inlineprotected

Take the link out of its chain.

void chainBefore ( UtlChain existing)
inlineprotected

Insert a new UtlChain before existing.

This may be called only on an unlinked UtlChain

void chainAfter ( UtlChain existing)
inlineprotected

Insert a new UtlChain after existing..

This may be called only on an unlinked UtlChain

UtlChain* listHead ( ) const
inlineprotected

Returns the head (first) UtlLink on the list (or NULL if the list is empty).

UtlChain* listTail ( ) const
inlineprotected

Returns the tail (last) UtlLink on the list (or NULL if the list is empty).

UtlLink* head ( ) const
inlineprotected

Returns the head (first) UtlLink on the list (or NULL if the list is empty).

UtlLink* tail ( ) const
inlineprotected

Returns the tail (last) UtlLink on the list (or NULL if the list is empty).

void listBefore ( UtlChain list,
UtlChain existing 
)
protected

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

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.
void listAfter ( UtlChain list,
UtlChain existing 
)
protected

Insert this link into a list after an existing entry (after NULL == at the head).

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.
UtlChain * detachFromList ( 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.

Friends And Related Function Documentation

friend class UtlChainPool
friend
friend class UtlLink
friend
friend class UtlPair
friend
friend class UtlContainer
friend
friend class UtlList
friend
friend class UtlHashMap
friend
friend class UtlHashMapIterator
friend
friend class UtlHashBag
friend
friend class UtlHashBagIterator
friend
friend class UtlChainTest
friend
friend class UtlLinkTest
friend

Member Data Documentation

UtlChain* prev
protected

backward chain pointer

UtlChain* next
protected

forward chain pointer