iso::data::IndexHash< KeyType, ValueType > Class Template Reference

a dual data structure that allows to retrieve data both by key and index More...

#include <iso_data_indexhash.h>

List of all members.

Public Member Functions

 IndexHash ()
 default constructor
 ~IndexHash ()
 destructor
QVector< ValueType * > & vector ()
 return vector of data
QHash< KeyType, ValueType * > & hash ()
 return hash table of data
unsigned int size () const
 returns number of elements stored
bool contains (KeyType pKey) const
 check whether hash table contains key
unsigned int index (KeyType pKey) const throw (base::Exception)
 return index for key
const KeyType & key (unsigned int pIndex) const throw (base::Exception)
 return key
const ValueType & value (unsigned int pIndex) const throw (base::Exception)
 return value
ValueType & value (unsigned int pIndex) throw (base::Exception)
 return value
ValueType & operator[] (unsigned int pIndex) throw (base::Exception)
 access element
const ValueType & operator[] (unsigned int pIndex) const throw (base::Exception)
 access element
ValueType & operator[] (const KeyType &pKey) throw (base::Exception)
 access element
const ValueType & operator[] (const KeyType &pKey) const throw (base::Exception)
 access element
void add (const KeyType &pKey, ValueType &pValue) throw (base::Exception)
 add element
void insert (const KeyType &pKey, ValueType &pValue) throw (base::Exception)
 insert element
void insert (const KeyType &pKey, ValueType &pValue, unsigned int pIndex) throw (base::Exception)
 insert element
void move (unsigned int pFromIndex, unsigned int pToIndex) throw (base::Exception)
 move element
void replace (const KeyType &pKey, ValueType &pValue) throw (base::Exception)
 replace element
void replace (unsigned int pIndex, ValueType &pValue) throw (base::Exception)
 replace element
void set (const KeyType &pKey, ValueType &pValue)
 set element
void set (unsigned int pIndex, ValueType &pValue) throw (base::Exception)
 set element
void remove (const KeyType &pKey) throw (base::Exception)
 remove element
void remove (unsigned int pIndex) throw (base::Exception)
 remove element
void clear ()
 remove all elements

Protected Attributes

QVector< ValueType * > mValueVector
 vector of data
QVector< KeyType > mKeyVector
 vector of keys
QHash< KeyType, ValueType * > mHash
 hash table of data


Detailed Description

template<typename KeyType, typename ValueType>
class iso::data::IndexHash< KeyType, ValueType >

a dual data structure that allows to retrieve data both by key and index

data structure that allows to retrieve data both by key and index

data structure stores pointers only. It manages data both via a hash table and vector data structure.
the data structure is relatively slow in removing / replacing elements since it has to find the element in both the hash table and vector

Created by Daniel Bisig on 4/14/07.


Constructor & Destructor Documentation

template<typename KeyType, typename ValueType>
iso::data::IndexHash< KeyType, ValueType >::IndexHash (  ) 

default constructor

template<typename KeyType, typename ValueType>
iso::data::IndexHash< KeyType, ValueType >::~IndexHash (  ) 

destructor


Member Function Documentation

template<typename KeyType, typename ValueType>
QVector< ValueType * > & iso::data::IndexHash< KeyType, ValueType >::vector (  ) 

return vector of data

Returns:
vector of data

template<typename KeyType, typename ValueType>
QHash< KeyType, ValueType * > & iso::data::IndexHash< KeyType, ValueType >::hash (  ) 

return hash table of data

Returns:
hash table of data

template<typename KeyType, typename ValueType>
unsigned int iso::data::IndexHash< KeyType, ValueType >::size (  )  const

returns number of elements stored

Returns:
number of elements stored

template<typename KeyType, typename ValueType>
bool iso::data::IndexHash< KeyType, ValueType >::contains ( KeyType  pKey  )  const

check whether hash table contains key

Parameters:
pKey key to look for
Returns:
true if key is found, false otherwise

template<typename KeyType, typename ValueType>
unsigned int iso::data::IndexHash< KeyType, ValueType >::index ( KeyType  pKey  )  const throw (base::Exception)

return index for key

Parameters:
pKey key to look for
Returns:
index
Exceptions:
base::Exception key not found

template<typename KeyType, typename ValueType>
const KeyType & iso::data::IndexHash< KeyType, ValueType >::key ( unsigned int  pIndex  )  const throw (base::Exception) [inline]

return key

Parameters:
pIndex index of element
Returns:
key
Exceptions:
base::Exception index out of range

template<typename KeyType, typename ValueType>
const ValueType & iso::data::IndexHash< KeyType, ValueType >::value ( unsigned int  pIndex  )  const throw (base::Exception) [inline]

return value

Parameters:
pIndex index of element
Returns:
value
Exceptions:
base::Exception index out of range

template<typename KeyType, typename ValueType>
ValueType & iso::data::IndexHash< KeyType, ValueType >::value ( unsigned int  pIndex  )  throw (base::Exception) [inline]

return value

Parameters:
pIndex index of element
Returns:
value
Exceptions:
base::Exception index out of range

template<typename KeyType, typename ValueType>
ValueType & iso::data::IndexHash< KeyType, ValueType >::operator[] ( unsigned int  pIndex  )  throw (base::Exception) [inline]

access element

Parameters:
pIndex index of element
Returns:
element
Exceptions:
base::Exception index out of range

template<typename KeyType, typename ValueType>
const ValueType & iso::data::IndexHash< KeyType, ValueType >::operator[] ( unsigned int  pIndex  )  const throw (base::Exception) [inline]

access element

Parameters:
pIndex index of element
Returns:
element
Exceptions:
base::Exception index out of range

template<typename KeyType, typename ValueType>
ValueType & iso::data::IndexHash< KeyType, ValueType >::operator[] ( const KeyType &  pKey  )  throw (base::Exception) [inline]

access element

Parameters:
pKey key of element
Returns:
element
Exceptions:
base::Exception key not found

template<typename KeyType, typename ValueType>
const ValueType & iso::data::IndexHash< KeyType, ValueType >::operator[] ( const KeyType &  pKey  )  const throw (base::Exception) [inline]

access element

Parameters:
pKey key of element
Returns:
element
Exceptions:
base::Exception key not found

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::add ( const KeyType &  pKey,
ValueType &  pValue 
) throw (base::Exception)

add element

Parameters:
pKey storage key
pValue element value
Exceptions:
base::Exception key alreay stored

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::insert ( const KeyType &  pKey,
ValueType &  pValue 
) throw (base::Exception)

insert element

Parameters:
pKey storage key
pValue element value
Exceptions:
base::Exception key alreay stored
same as add

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::insert ( const KeyType &  pKey,
ValueType &  pValue,
unsigned int  pIndex 
) throw (base::Exception)

insert element

Parameters:
pKey storage key
pValue element value
pIndex insert position index
Exceptions:
base::Exception key alreay stored

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::move ( unsigned int  pFromIndex,
unsigned int  pToIndex 
) throw (base::Exception)

move element

Parameters:
pFromIndex from index position
pToIndex to indey position
Exceptions:
base::Exception index out of bounds

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::replace ( const KeyType &  pKey,
ValueType &  pValue 
) throw (base::Exception)

replace element

Parameters:
pKey storage key
pValue element value
Exceptions:
base::Exception key not found

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::replace ( unsigned int  pIndex,
ValueType &  pValue 
) throw (base::Exception)

replace element

Parameters:
pIndex index of element
pValue element value
Exceptions:
base::Exception index out of range

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::set ( const KeyType &  pKey,
ValueType &  pValue 
)

set element

Parameters:
pKey storage key
pValue element value
if key is found: element is replaced if key is not found: element is added

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::set ( unsigned int  pIndex,
ValueType &  pValue 
) throw (base::Exception)

set element

Parameters:
pIndex index of element
pValue element value
Exceptions:
base::Exception index out of range

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::remove ( const KeyType &  pKey  )  throw (base::Exception)

remove element

Parameters:
pKey storage key
Exceptions:
base::Exception key not found

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::remove ( unsigned int  pIndex  )  throw (base::Exception)

remove element

Parameters:
pIndex index of element
Exceptions:
base::Exception index out of range

template<typename KeyType, typename ValueType>
void iso::data::IndexHash< KeyType, ValueType >::clear (  ) 

remove all elements


Member Data Documentation

template<typename KeyType, typename ValueType>
QVector<ValueType*> iso::data::IndexHash< KeyType, ValueType >::mValueVector [protected]

vector of data

template<typename KeyType, typename ValueType>
QVector<KeyType> iso::data::IndexHash< KeyType, ValueType >::mKeyVector [protected]

vector of keys

template<typename KeyType, typename ValueType>
QHash<KeyType, ValueType*> iso::data::IndexHash< KeyType, ValueType >::mHash [protected]

hash table of data


The documentation for this class was generated from the following file:
Generated on Fri Feb 25 13:57:33 2011 for iso_data by  doxygen 1.5.1