class DictionaryBag

Dictionary Bag. More...

Definition#include <dictionarybag.h>
Template formDictionaryBag<templateclass K, class T>
Inherited byDictionarySet
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members

Protected Members


Detailed Description

This class implements the DictionaryBag datatype template.

DictionaryBag ()

Constructor.

~DictionaryBag ()

Destructor.

bool addHead (K key, T element)

Add element to head of bag.

Parameters:
keyKey of element to be added.
elementElement to be added.

Returns: true, if element has been added; false, if not.

bool addTail (K key, T element)

Add element to tail of bag.

Parameters:
keyKey of element to be added.
elementElement to be added.

Returns: true, if element has been added; false, if not.

void remove (const K& key)

Remove element from bag.

Parameters:
keyKey for element to be removed.

void remove (T element)

Remove element from bag.

Parameters:
elementElement to be removed.

void removeAll (const K& key)

Remove all elements with given key from bag.

Parameters:
keyKey.

inline void removeHead ()

Remove first element from bag.

inline void removeTail ()

Remove last element from bag.

inline bool contains (const T& element)
[const]

Check, if bag contains an element.

Parameters:
elementElement to be checked to be in the bag.

inline bool contains (const K& key)
[const]

Check, if bag contains an element.

Parameters:
keyKey of element to be checked to be in the bag.

inline T find (const K& key)
[const]

Find element.

Parameters:
keyKey for element to find.

Returns: Element.

inline cardinal getCount ()
[const]

Get number of elements in the bag.

Returns: Number of elements.

inline bool first (T& element)

Get first element. If true is returned, the given reference will be a reference to the element.

Parameters:
elementReference to hold the element's reference.

Returns: true, if the reference is valid.

inline bool last (T& element)

Get last element. If true is returned, the given reference will be a reference to the element.

Parameters:
elementReference to hold the element's reference.

Returns: true, if the reference is valid.

inline bool next (T& element)

Get next element. If true is returned, the given reference will be a reference to the element.

Parameters:
elementReference to hold the element's reference.

Returns: true, if the reference is valid.

inline bool prev (T& element)

Get previous element. If true is returned, the given reference will be a reference to the element.

Parameters:
elementReference to hold the element's reference.

Returns: true, if the reference is valid.

inline bool first (K& key, T& element)

Get first element. If true is returned, the given references will be references to the key and the element.

Parameters:
elementReference to hold the element's reference.

Returns: true, if the reference is valid.

inline bool last (K& key, T& element)

Get last element. If true is returned, the given references will be references to the key and the element.

Parameters:
elementReference to hold the element's reference.

Returns: true, if the reference is valid.

inline bool next (K& key, T& element)

Get next element. If true is returned, the given references will be references to the key and the element.

Parameters:
elementReference to hold the element's reference.

Returns: true, if the reference is valid.

inline bool prev (K& key, T& element)

Get previous element. If true is returned, the given references will be references to the key and the element.

Parameters:
elementReference to hold the element's reference.

Returns: true, if the reference is valid.

DictionaryBagNode<K,T>* findNode (const T& element)
[protected const]

Get DictionaryBagNode for an element.

Parameters:
elementElement.

Returns: Pointer to DictionaryBagNode or NULL, if element is not in the bag.

DictionaryBagNode<K,T>* findNode (const K& key)
[protected const]

Get DictionaryBagNode for an element.

Parameters:
keyElement's key.

Returns: Pointer to DictionaryBagNode or NULL, if element is not in the bag.

void removeNode (DictionaryBagNode<K,T>* node)
[protected]

Remove a DictionaryBagNode.

Parameters:
nodeDictionaryBagNode to be removed.