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

Bag template. More...

#include <tbag.h>

+ Inheritance diagram for TBag< T >:

Public Types

typedef uint32(* THashFunc )(const T &, uint32)
 Hash function type. More...
 
- Public Types inherited from THashTable< T >
typedef uint32(* THashFunc )(const T &, uint32)
 Hash function type. More...
 

Public Member Functions

 TBag (int32 size=10)
 Bag constructor. More...
 
 TBag (THashFunc hashFunction, int32 size=10)
 Bag constructor with a specified hash function. More...
 
 TBag (THashTable< T > &hashTable)
 Bag copy constructor. More...
 
 TBag (THashFunc hashFunction, const TContainer< T > &container)
 Bag constructor with a specified hash function and a container. More...
 
TBag< T > & operator= (const THashTable< T > &hashTable)
 Assignment operator. More...
 
virtual bool add (const T &item)
 Adds a new item to the bag. More...
 
virtual bool add (const T &item, int32 numCopies)
 Adds a number of copies of a new item to the bag. More...
 
virtual bool remove (const T &item)
 Removes the first occurrence of an item from the bag. More...
 
virtual bool remove (const T &item, int32 numCopies)
 Removes a number of copies of an item from the bag. More...
 
virtual void removeAll (const T &item)
 Removes all occurrences of the specific item from the bag. More...
 
virtual void removeAll ()
 Removes all items from the bag. More...
 
int32 getCount (const T &item)
 Number of occurrences (cardinality) of the given item. More...
 
THashSet< T > * createUniqueSet ()
 Creates a hash set of unique items. More...
 
- Public Member Functions inherited from THashTable< T >
 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 remove (const TIterator< T > &iter)
 Remove item at current iterator position. More...
 
virtual bool removeAt (int32 index)
 Remove item at given index. 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::TBag< T >

Bag template.

A bag is a hash table that adds a few convenient functions to the super class, regarding the handling of identical items

See also
THashTable, THashSet

Member Typedef Documentation

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

Hash function type.

Constructor & Destructor Documentation

TBag ( int32  _size = 10)

Bag constructor.

Before using this bag, a hash function has to be assigned via the THashTable<T>::setHashFunction() method

Parameters
[in]_size- initial size of the container
TBag ( THashFunc  hashFunction,
int32  _size = 10 
)

Bag constructor with a specified hash function.

Parameters
[in]hashFunction- hash function
[in]_size- initial size of the container
TBag ( THashTable< T > &  hashTable)

Bag copy constructor.

Parameters
[in]hashTable- hashTable to copy (including the hash function)
TBag ( THashFunc  hashFunction,
const TContainer< T > &  container 
)

Bag constructor with a specified hash function and a container.

Parameters
[in]hashFunction- hash function
[in]container- container, which will be used to construct the bag

Member Function Documentation

TBag< T > & operator= ( const THashTable< T > &  hashTable)

Assignment operator.

Parameters
[in]hashTable- hashTable to copy (including the hash function)
bool add ( const T &  item)
virtual

Adds a new item to the bag.

Parameters
[in]item- item to add
Returns
true, if item was added successfully, else false

Reimplemented from THashTable< T >.

bool add ( const T &  item,
int32  numCopies 
)
virtual

Adds a number of copies of a new item to the bag.

Parameters
[in]item- item to add
[in]numCopies- number of copies
Returns
true, if items were added successfully, else false
bool remove ( const T &  item)
virtual

Removes the first occurrence of an item from the bag.

Parameters
[in]item- item to remove
Returns
true, if item was removed successfully, else false

Reimplemented from THashTable< T >.

bool remove ( const T &  item,
int32  numCopies 
)
virtual

Removes a number of copies of an item from the bag.

Parameters
[in]item- item to remove
[in]numCopies- number of copies
Returns
true, if items were removed successfully, else false
void removeAll ( const T &  item)
virtual

Removes all occurrences of the specific item from the bag.

Parameters
[in]item- item to remove
Returns
true, if all occurrences were removed successfully, else false
void removeAll ( )
virtual

Removes all items from the bag.

Reimplemented from THashTable< T >.

int32 getCount ( const T &  item)

Number of occurrences (cardinality) of the given item.

Parameters
[in]item- item to count
Returns
number of occurrences
THashSet< T > * createUniqueSet ( )

Creates a hash set of unique items.

The hash set contains exactly one copy of each item in the bag

Returns
hash set
Empty

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