class HashList

A hashed object list class. More...

Full nameTelEngine::HashList
Definition#include <yateclass.h>
InheritsTelEngine::GenObject [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

A hashed object list handling class. Objects placed in the list are distributed according to their String hash resulting in faster searches. On the other hand an object placed in a hashed list must never change its String value or it becomes unfindable.

explicit  HashList (unsigned int size = 17)

HashList

Creates a new, empty list.

Parameters:
sizeNumber of classes to divide the objects

 ~HashList ()

~HashList

[virtual]

Destroys the list and everything in it.

void*  getObject (const String& name)

getObject

[const virtual]

Get a pointer to a derived class given that class name

Parameters:
nameName of the class we are asking for

Returns: Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from GenObject.

inline unsigned int  length ()

length

[const]

Get the number of hash entries

Returns: Count of hash entries

unsigned int  count ()

count

[const]

Get the number of non-null objects in the list

Returns: Count of items

inline ObjList*  getList (unsigned int index)

getList

[const]

Retrieve one of the internal object lists. This method should be used only to iterate all objects in the list.

Parameters:
indexIndex of the internal list to retrieve

Returns: Pointer to the list or NULL

inline ObjList*  getHashList (unsigned int hash)

getHashList

[const]

Retrieve one of the internal object lists knowing the hash value.

Parameters:
hashHash of the internal list to retrieve

Returns: Pointer to the list or NULL if never filled

inline ObjList*  getHashList (const String& str)

getHashList

[const]

Retrieve one of the internal object lists knowing the String value.

Parameters:
strString whose hash internal list is to retrieve

Returns: Pointer to the list or NULL if never filled

GenObject*  operator[] (const String& str)

operator[]

[const]

Array-like indexing operator

Parameters:
strString value of the object to locate

Returns: Pointer to the first object or NULL

ObjList*  find (const GenObject* obj)

find

[const]

Get the item in the list that holds an object. The item is searched sequentially in the lists, not using it's String hash

Parameters:
objPointer to the object to search for

Returns: Pointer to the found item or NULL

ObjList*  find (const GenObject* obj, unsigned int hash)

find

[const]

Get the item in the list that holds an object

Parameters:
objPointer to the object to search for
hashObject hash used to identify the list it belongs to

Returns: Pointer to the found item or NULL

ObjList*  find (const String& str)

find

[const]

Get the item in the list that holds an object by String value

Parameters:
strString value (toString) of the object to search for

Returns: Pointer to the first found item or NULL

ObjList*  append (const GenObject* obj)

append

Appends an object to the hashed list

Parameters:
objPointer to the object to append

Returns: A pointer to the inserted list item

GenObject*  remove (GenObject* obj, bool delobj = true, bool useHash = false)

remove

Delete the list item that holds a given object

Parameters:
objObject to search in the list
delobjTrue to delete the object (default)
useHashTrue to use object hash to identify the list it belongs to

Returns: Pointer to the object if not destroyed

inline GenObject*  remove (const String& str, bool delobj = true)

remove

Delete the item in the list that holds an object by String value

Parameters:
strString value (toString) of the object to remove
delobjTrue to delete the object (default)

Returns: Pointer to the object if not destroyed

void  clear ()

clear

Clear the list and optionally delete all contained objects

bool  resync (GenObject* obj)

resync

Resync the list by checking if a stored object belongs to the list according to its hash

Parameters:
objObject to resync in the list

Returns: True if object was in the wrong list and had to be moved

bool  resync ()

resync

Resync the list by checking if all stored objects belong to the list according to their hash

Returns: True if at least one object had to be moved


Generated by: paulc on bussard on Thu Jul 24 18:41:02 2014, using kdoc 2.0a54.