dictionary Class Template Reference

#include <dictionary.hpp>

Inheritance diagram for dictionary:

Inheritance graph
[legend]
Collaboration diagram for dictionary:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<typename T, typename I>
class gsgl::data::dictionary< T, I >

A dictionary or map.

Type T can be any type; type I must implement '<', '>' and '=='.

Currently implemented by means of a simple unbalanced binary tree.

Todo:
Improve implementation.

Definition at line 65 of file dictionary.hpp.


Public Member Functions

 dictionary (const dictionary &)
 dictionary ()
virtual bool is_empty () const
 Returns true if the collection is empty.
dictionaryoperator= (const dictionary &)
T & operator[] (const I &index)
const T & operator[] (const I &index) const
virtual ~dictionary ()
Other Useful Functions
virtual void append (const iterable< T, IBase > &)
 Append all members of a collection to this one.
virtual iterator find_value (const T &)
virtual const_iterator find_value (const T &) const
 A generic find function that iterates over the collection to find a particular value.
Iterable Implementation
virtual void append (const T &item)
 Add an item to the end of the collection.
virtual void insert (const iterator &i, const T &item)
 Insert an item before the one specified by the iterator.
virtual void remove (const iterator &i)
 Remove the item specified by the iterator.
Countable Implementation
virtual void clear ()
 Clears the contents of the collection.
virtual gsgl::index_t size ()
Indexable Implementation
virtual bool contains_index (const I &index) const
virtual T & item (const I &index)
virtual const T & item (const I &index) const
Iterators
iterator iter ()
const_iterator iter () const
Dictionary Functionality
bool operator== (const dictionary< T, I > &) const
virtual void remove (const I &index)
Countable Implementation
virtual gsgl::index_t size () const
 A generic count function that iterates over the collection.

Private Member Functions

dict_nodefind_node (const I &index, dict_node ***link)
T & get_item (const I &index, bool create_new=true)
void remove_node (dict_node *cur, dict_node **link)

Private Attributes

gsgl::index_t count
dict_noderoot

Classes

struct  dict_node

Constructor & Destructor Documentation

dictionary (  )  [inline]

Definition at line 162 of file dictionary.hpp.

dictionary ( const dictionary< T, I > &  d  )  [inline]

Definition at line 170 of file dictionary.hpp.

References dictionary::dict_node::copy(), and dictionary::root.

~dictionary (  )  [inline, virtual]

Definition at line 191 of file dictionary.hpp.

References dictionary::clear().


Member Function Documentation

void append ( const iterable< T, IBase > &  a  )  [inline, virtual, inherited]

Append all members of a collection to this one.

Definition at line 145 of file iterable.hpp.

void append ( const T &   )  [inline, virtual]

Add an item to the end of the collection.

Implements iterable.

Definition at line 225 of file dictionary.hpp.

void clear (  )  [inline, virtual]

Clears the contents of the collection.

Implements countable.

Definition at line 216 of file dictionary.hpp.

References dictionary::count, and dictionary::root.

Referenced by dictionary::operator=(), cache::~cache(), and dictionary::~dictionary().

bool contains_index ( const I &  index  )  const [inline, virtual]

dictionary< T, I >::dict_node * find_node ( const I &  index,
dict_node ***  link 
) [inline, private]

iterable< T, IBase >::iterator find_value ( const T &  item  )  [inline, virtual, inherited]

Definition at line 168 of file iterable.hpp.

References iterable::iterator::is_valid().

iterable< T, IBase >::const_iterator find_value ( const T &  item  )  const [inline, virtual, inherited]

A generic find function that iterates over the collection to find a particular value.

Note:
Not efficient; should be overridden if possible.

Definition at line 153 of file iterable.hpp.

References iterable::const_iterator::is_valid().

Referenced by gsgl::data::global_unregister_resource_aux().

T & get_item ( const I &  index,
bool  create_new = true 
) [inline, private]

void insert ( const iterator ,
const T &   
) [inline, virtual]

Insert an item before the one specified by the iterator.

Implements iterable.

Definition at line 232 of file dictionary.hpp.

virtual bool is_empty (  )  const [inline, virtual, inherited]

T & item ( const I &  index  )  [inline, virtual]

Implements indexable.

Definition at line 288 of file dictionary.hpp.

References dictionary::get_item().

const T & item ( const I &  index  )  const [inline, virtual]

Implements indexable.

Definition at line 281 of file dictionary.hpp.

References dictionary::get_item().

iterator iter (  )  [inline, inherited]

Returns:
An iterator pointing to the first item in the collection.

Definition at line 101 of file iterable.hpp.

const_iterator iter (  )  const [inline, inherited]

dictionary< T, I > & operator= ( const dictionary< T, I > &  d  )  [inline]

bool operator== ( const dictionary< T, I > &  d  )  const [inline]

Definition at line 198 of file dictionary.hpp.

References iterable::const_iterator::is_valid(), and iterable::iter().

T& operator[] ( const I &  index  )  [inline, inherited]

Definition at line 58 of file indexable.hpp.

const T& operator[] ( const I &  index  )  const [inline, inherited]

Definition at line 57 of file indexable.hpp.

void remove ( const I &  index  )  [inline, virtual]

void remove ( const iterator  )  [inline, virtual]

Remove the item specified by the iterator.

Implements iterable.

Definition at line 239 of file dictionary.hpp.

Referenced by gsgl::data::global_unregister_resource_aux().

void remove_node ( dict_node cur,
dict_node **  link 
) [inline, private]

gsgl::index_t size (  )  const [inline, virtual, inherited]

A generic count function that iterates over the collection.

Note:
Not very efficient; should be overridden if possible.

Implements countable.

Reimplemented in simple_array, list, pqueue, string, simple_array< gsgl::string * >, simple_array< gsgl::platform::buffer_pool::bucket * >, simple_array< gsgl::framework::treebox_node * >, simple_array< float >, simple_array< gsgl::scenegraph::model_part * >, simple_array< unsigned int >, simple_array< gsgl::framework::widget * >, simple_array< gsgl::scenegraph::light * >, simple_array< gsgl::physics::vehicle_module * >, simple_array< unsigned char >, simple_array< gsgl::scenegraph::model * >, simple_array< wchar_t >, simple_array< gsgl::scenegraph::node * >, simple_array< char >, simple_array< gsgl::scenegraph::submesh * >, simple_array< gsgl::data::pair * >, simple_array< I >, simple_array< gsgl::platform::buffer_pool::object_record >, simple_array< gsgl::data::dictionary< T, I >::dict_node * >, list< gsgl::framework::treebox_node * >, list< gsgl::data::log_target * >, list< gsgl::io::file >, list< gsgl::string >, list< gsgl::framework::pkg_scenery * >, list< gsgl::platform::shader_base * >, list< gsgl::framework::pkg_library * >, list< gsgl::data::config_record >, list< gsgl::data_object * >, list< gsgl::io::directory >, list< gsgl::scenegraph::node * >, list< gsgl::platform::vertex_buffer * >, list< gsgl::framework::tabbox::tab_rec >, list< gsgl::framework::pkg_vehicle * >, list< gsgl::framework::package * >, pqueue< gsgl::scenegraph::light *, float >, and pqueue< gsgl::scenegraph::node *, float >.

Definition at line 135 of file iterable.hpp.

virtual gsgl::index_t size (  )  [inline, virtual]

Definition at line 98 of file dictionary.hpp.


Member Data Documentation

gsgl::index_t count [private]

dict_node* root [mutable, private]


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

Generated on Sat Mar 1 13:50:05 2008 for Periapsis Project by  doxygen 1.5.5