Base Module  VST 3.6.6
SDK for developing VST Plug-in
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Types | Public Member Functions
THashTable< T > Class Template Reference

Hash Table templateA hash table is a list of buckets. More...

#include <thashtable.h>

+ Inheritance diagram for THashTable< T >:

Public Types

typedef uint32(* THashFunc )(const T &, uint32)
 Hash function type. More...
 

Public Member Functions

 THashTable (THashFunc, int32=10)
 Constructor with hash function. More...
 
 THashTable (const THashTable< T > &)
 Copy constructor. More...
 
 THashTable (THashFunc, const TContainer< T > &)
 Constructor with container. More...
 
 ~THashTable ()
 Destructor. More...
 
THashTable< T > & operator= (const THashTable< T > &)
 Assignment operator, uses copy. More...
 
void setHashFunction (THashFunc)
 Set hash function. More...
 
bool resize (int32)
 Resize the table, set number of hash buckets. More...
 
virtual TContainer< T > * newInstance () const
 Create a copy of this container. More...
 
virtual int32 total () const
 Return number of items. More...
 
virtual bool isEmpty () const
 Is container empty? More...
 
virtual bool add (const T &item)
 Add item to container. More...
 
virtual bool remove (const T &item)
 Remove equal item. More...
 
virtual bool remove (const TIterator< T > &iter)
 Remove item at current iterator position. More...
 
virtual bool removeAt (int32 index)
 Remove item at given index. More...
 
virtual void removeAll ()
 Remove all items from list. More...
 
virtual T & lookup (const T &item) const
 Searches for the item equal to the specified item in the list and returns the first occurrence. More...
 
virtual bool contains (const T &item) const
 See if container has equal item. More...
 
virtual int32 occurrences (const T &item) const
 Count occurrences of equal items. More...
 
virtual TIterator< T > * newIterator () const
 Create container iterator instance. More...
 
- Public Member Functions inherited from TContainer< T >
 TContainer ()
 
 TContainer (const TContainer< T > &)
 
virtual ~TContainer ()
 
bool operator== (const TContainer< T > &) const
 
bool operator!= (const TContainer< T > &) const
 
T & operator[] (int32) const
 "[]" indexing operator returns the item at the specified index. More...
 
virtual int32 size () const
 Returns the container size. More...
 
virtual T & at (int32 index) const
 Get item at index. More...
 
TContainer< T > * lookupAll (const T &item) const
 Allocate and returns a container with all items in this container equal to the specified item. More...
 
bool addAllFrom (const TContainer< T > &container)
 Adds all the items from the specified container to this container. More...
 
bool addNewFrom (const TContainer< T > &container)
 Adds the items from the specified container to this container that are not in this container already. More...
 
T & error () const
 Access error object. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TContainer< T >
void copy (const TContainer< T > &container)
 Internal copy method. Copies the contents of the specified container into this container. More...
 
- Protected Attributes inherited from TContainer< T >
errorObject
 Object used as return value when methods returning a T& fail. More...
 
int32 _size
 Container size. More...
 

Detailed Description

template<class T>
class Steinberg::THashTable< T >

Hash Table template

A hash table is a list of buckets.

It assigns values to items (template) using a hash function and puts them into the bucket, which table index equals the item's calculated value.

See also
TContainer, THashTableIterator, THashSet

Member Typedef Documentation

typedef uint32(* THashFunc)(const T &, uint32)

Hash function type.

Constructor & Destructor Documentation

THashTable ( THashFunc  func,
int32  size = 10 
)

Constructor with hash function.

Parameters
[in]funcHash function the table uses.
[in]sizeSize (number of buckets) of new table.
THashTable ( const THashTable< T > &  table)

Copy constructor.

Parameters
[in]tableHash table to copy.
THashTable ( THashFunc  func,
const TContainer< T > &  cont 
)

Constructor with container.

Parameters
[in]funcHash function the table uses.
[in]contContainer to construct the table from.
~THashTable ( )

Destructor.

Member Function Documentation

THashTable< T > & operator= ( const THashTable< T > &  table)

Assignment operator, uses copy.

Parameters
[in]tableAssign left side (this) to table.
Returns
Assigned hash table.
void setHashFunction ( THashFunc  func)

Set hash function.

Parameters
[in]funcNew hash function.
bool resize ( int32  newsize)

Resize the table, set number of hash buckets.

Parameters
[in]newsizeNew number of hash buckets.
Returns
true, if resized.
false, if failed.
TContainer< T > * newInstance ( ) const
virtual

Create a copy of this container.

Returns
New hash table instance.

Implements TContainer< T >.

int32 total ( ) const
virtual

Return number of items.

Returns
Total number of items in the table.

Reimplemented from TContainer< T >.

bool isEmpty ( ) const
virtual

Is container empty?

Returns
true, if empty.
false, if not empty.

Reimplemented from TContainer< T >.

bool add ( const T &  rObj)
virtual

Add item to container.

Parameters
[in]rObjItem to add.
Returns
true, if added.
false, if failed.

Implements TContainer< T >.

Reimplemented in THashSet< T >, and TBag< T >.

bool remove ( const T &  rObj)
virtual

Remove equal item.

Parameters
[in]rObjItem to remove.
Returns
true, if removed.
false, if failed.

Implements TContainer< T >.

Reimplemented in TBag< T >.

bool remove ( const TIterator< T > &  iter)
virtual

Remove item at current iterator position.

Parameters
[in]iterPoints to item to remove.
Returns
true, if removed.
false, if failed.

Implements TContainer< T >.

bool removeAt ( int32  idx)
virtual

Remove item at given index.

Parameters
[in]idxIndex of item to remove.
Returns
true, if removed.
false, if failed.

Implements TContainer< T >.

void removeAll ( )
virtual

Remove all items from list.

Implements TContainer< T >.

Reimplemented in TBag< T >.

T & lookup ( const T &  rObj) const
virtual

Searches for the item equal to the specified item in the list and returns the first occurrence.

Parameters
[in]rObjItem to look up.
Returns
true, if removed.
false, if failed.

Reimplemented from TContainer< T >.

bool contains ( const T &  rObj) const
virtual

See if container has equal item.

Parameters
[in]rObjItem to compare.
Returns
true, if equal item exists.
false, if no equal item exists.

Reimplemented from TContainer< T >.

int32 occurrences ( const T &  rObj) const
virtual

Count occurrences of equal items.

Parameters
[in]rObjItem to compare.
Returns
number of equal items.

Reimplemented from TContainer< T >.

TIterator< T > * newIterator ( ) const
virtual

Create container iterator instance.

Returns
New hash table iterator.

Implements TContainer< T >.

Empty

Copyright ©2016 Steinberg Media Technologies GmbH. All Rights Reserved.