OpenNI 1.5.7
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
XnHash Class Reference

#include <XnHash.h>

Classes

class  ConstIterator
 
class  Iterator
 

Public Types

typedef XnHashValue(* XnHashFunction) (const XnKey &key)
 
typedef XnInt32(* XnCompareFunction) (const XnKey &key1, const XnKey &key2)
 

Public Member Functions

 XnHash ()
 
virtual ~XnHash ()
 
XnStatus GetInitStatus () const
 
XnStatus Set (const XnKey &key, const XnValue &value)
 
XnStatus Get (const XnKey &key, XnValue &value) const
 
XnStatus Remove (const XnKey &key, XnValue &value)
 
XnStatus Remove (ConstIterator iter, XnKey &key, XnValue &value)
 
virtual XnStatus Remove (ConstIterator iter)
 
XnStatus Clear ()
 
XnBool IsEmpty () const
 
XnUInt32 Size () const
 
XnStatus Find (const XnKey &key, ConstIterator &hiter) const
 
XnStatus Find (const XnKey &key, Iterator &hiter)
 
Iterator begin ()
 
ConstIterator begin () const
 
Iterator end ()
 
ConstIterator end () const
 
XnStatus SetHashFunction (XnHashFunction hashFunction)
 
XnStatus SetCompareFunction (XnCompareFunction compareFunction)
 

Protected Member Functions

XnStatus Init ()
 
XnStatus Find (const XnKey &key, XnHashValue hashValue, ConstIterator &hiter) const
 

Protected Attributes

XnList ** m_Bins
 
XnUInt16 m_nMinBin
 
XnStatus m_nInitStatus
 
XnHashFunction m_HashFunction
 
XnCompareFunction m_CompareFunction
 

Friends

class ConstIterator
 

Detailed Description

The hash - associative array

Member Typedef Documentation

◆ XnCompareFunction

typedef XnInt32(* XnHash::XnCompareFunction) (const XnKey &key1, const XnKey &key2)

Definition of comparison function - receives 2 keys, returns 0 on equality

◆ XnHashFunction

typedef XnHashValue(* XnHash::XnHashFunction) (const XnKey &key)

Definition of a hash function - receive key, and outputs HashValue

Constructor & Destructor Documentation

◆ XnHash()

XnHash::XnHash ( )
inline

Constructor. Initializes internal representations.

◆ ~XnHash()

virtual XnHash::~XnHash ( )
inlinevirtual

Destructor. Destroys internal representations.

Member Function Documentation

◆ begin() [1/2]

Iterator XnHash::begin ( )
inline

Get an iterator to the beginning of the XnHash (non-const version)

◆ begin() [2/2]

ConstIterator XnHash::begin ( ) const
inline

Get an iterator to the beginning of the XnHash (const version)

◆ Clear()

XnStatus XnHash::Clear ( )
inline

Remove all entries from the XnHash.

◆ end() [1/2]

Iterator XnHash::end ( )
inline

Get an iterator to the end of the XnHash (position is invalid) (non-const version)

◆ end() [2/2]

ConstIterator XnHash::end ( ) const
inline

Get an iterator to the end of the XnHash (position is invalid) (const version)

◆ Find() [1/3]

XnStatus XnHash::Find ( const XnKey key,
ConstIterator hiter 
) const
inline

Get an iterator pointing to the entry to which the key belongs

Parameters
key[in] The key of the entry
hiter[out] Iterator to the entry described by key
Returns
XN_STATUS_NO_MATCH No such key in the XnHash

◆ Find() [2/3]

XnStatus XnHash::Find ( const XnKey key,
Iterator hiter 
)
inline

Get an iterator pointing to the entry to which the key belongs

Parameters
key[in] The key of the entry
hiter[out] Iterator to the entry described by key
Returns
XN_STATUS_NO_MATCH No such key in the XnHash

◆ Find() [3/3]

XnStatus XnHash::Find ( const XnKey key,
XnHashValue  hashValue,
ConstIterator hiter 
) const
inlineprotected

Get an iterator pointing to the entry to which the key belongs

Parameters
key[in] The key of the entry
hashValue[in] The hash value of the key
hiter[out] Iterator to the entry described by key
Returns
XN_STATUS_NO_MATCH No such key in the XnHash

◆ Get()

XnStatus XnHash::Get ( const XnKey key,
XnValue value 
) const
inline

Get the value associated with the supplied key

Parameters
key[in] The key of the entry
value[out] The retrieved value
Returns
XN_STATUS_NO_MATCH if no such key exists

◆ GetInitStatus()

XnStatus XnHash::GetInitStatus ( ) const
inline

Returns the status of the initialization of the hash.

Returns
XN_STATUS_OK if the hash was initialized successfully, or an error code otherwise (e.g. if memory could not be allocated).

◆ Init()

XnStatus XnHash::Init ( )
inlineprotected

◆ IsEmpty()

XnBool XnHash::IsEmpty ( ) const
inline

Checks if hash is empty.

◆ Remove() [1/3]

XnStatus XnHash::Remove ( const XnKey key,
XnValue value 
)
inline

Remove a key-value entry from the XnHash

Parameters
key[in] The key of the entry
value[out] The value that was in the removed entry
Returns
XN_STATUS_NO_MATCH if no such key exists

◆ Remove() [2/3]

virtual XnStatus XnHash::Remove ( ConstIterator  iter)
inlinevirtual

Remove an entry from the XnHash by iterator

Parameters
iter[in] Iterator pointing to an entry in the hash
Returns
XN_STATUS_ILLEGAL_POSITION if iterator is invalid

◆ Remove() [3/3]

XnStatus XnHash::Remove ( ConstIterator  iter,
XnKey key,
XnValue value 
)
inline

Remove an entry from the XnHash by iterator

Parameters
iter[in] Iterator pointing to an entry in the hash
key[out] The key that was in the removed entry
value[out] The value that was in the removed entry
Returns
XN_STATUS_ILLEGAL_POSITION if iterator is invalid

◆ Set()

XnStatus XnHash::Set ( const XnKey key,
const XnValue value 
)
inline

Set a new key-value entry. If key exists, will replace value.

Parameters
key[in] The key to which to associate the value
value[in] The value to add to the XnHash

◆ SetCompareFunction()

XnStatus XnHash::SetCompareFunction ( XnCompareFunction  compareFunction)
inline

Change the comparison function. The XnHash must be empty for this to succeed.

Parameters
compareFunction[in] The new hash function
Returns
XN_STATUS_IS_NOT_EMPTY if the XnHash isn't empty

◆ SetHashFunction()

XnStatus XnHash::SetHashFunction ( XnHashFunction  hashFunction)
inline

Change the hash function. The XnHash must be empty for this to succeed.

Parameters
hashFunction[in] The new hash function
Returns
XN_STATUS_IS_NOT_EMPTY if the XnHash isn't empty

◆ Size()

XnUInt32 XnHash::Size ( ) const
inline

Gets the number of entries in the hash.

Friends And Related Function Documentation

◆ ConstIterator

friend class ConstIterator
friend

Member Data Documentation

◆ m_Bins

XnList** XnHash::m_Bins
protected

Each bin is a XnList

◆ m_CompareFunction

XnCompareFunction XnHash::m_CompareFunction
protected

The current comparison function

◆ m_HashFunction

XnHashFunction XnHash::m_HashFunction
protected

The current hash function

◆ m_nInitStatus

XnStatus XnHash::m_nInitStatus
protected

◆ m_nMinBin

XnUInt16 XnHash::m_nMinBin
protected

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