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 Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes
TArrayBase< T > Class Template Referenceabstract

Template array base class. More...

#include <tarray.h>

+ Inheritance diagram for TArrayBase< T >:

Public Member Functions

 TArrayBase (int32 initSize=0, int32 delta=kDefaultDelta)
 
 ~TArrayBase ()
 
TArrayBase< T > & operator= (const TArrayBase< T > &)
 
void delta (int32 d)
 Set delta value. More...
 
int32 delta () const
 Get delta value. More...
 
void enableExponentialGroth (bool state)
 Instead of using delta, always double the array size. More...
 
bool hasExponentialGroth () const
 
bool resize (int32 newSize)
 Resize the array. More...
 
virtual int32 total () const
 Return number of items. More...
 
virtual bool isEmpty () const
 Is container empty? More...
 
virtual bool add (const T &)
 Add item to container. More...
 
virtual bool remove (const T &)
 Remove equal item. More...
 
virtual bool remove (const TIterator< T > &)
 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...
 
bool removeRange (int32 from, int32 to)
 Remove items from index 'from' to index 'to'. More...
 
virtual T & at (int32) const
 Get item at 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...
 
virtual int32 shouldGo (const T &item) const =0
 Get index for potential item. More...
 
virtual int32 index (const T &item) const =0
 Get index of item. More...
 
T & first () const
 
T & last () const
 
- 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
 
virtual TContainer< T > * newInstance () const =0
 Create a copy of this container. More...
 
T & operator[] (int32) const
 "[]" indexing operator returns the item at the specified index. More...
 
virtual int32 size () const
 Returns the container size. 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...
 

Static Public Attributes

static const int32 kDefaultDelta = 10
 
static const int32 kExponentialDelta = -1
 

Protected Member Functions

int32 indexSorted (const T &) const
 
int32 indexUnsorted (const T &) const
 
int32 shouldGoSorted (const T &) const
 Get index for potential item. More...
 
int32 shouldGoUnsorted (const T &) const
 Get index for potential item. More...
 
void doQuickSort ()
 
bool doInsertAt (int32 index, const T &)
 Insert item at index. More...
 
- 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...
 

Static Protected Member Functions

static int cmpData (const void *, const void *)
 Quick sort compare function. More...
 

Protected Attributes

int32 _delta
 Delta value. More...
 
int32 _total
 Number of items. More...
 
T * _entries
 Array of "T" pointers. 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::TArrayBase< T >

Template array base class.

See also
TArray, TOrderedArray, TSortableArray, TArrayIterator

Constructor & Destructor Documentation

TArrayBase ( int32  sz = 0,
int32  dt = kDefaultDelta 
)

"TArrayBase" is the default constructor.

Parameters
sz: initial size of array
dt: initial delta value for automatic growing.
~TArrayBase ( )

Member Function Documentation

TArrayBase< T > & operator= ( const TArrayBase< T > &  arr)

"=" assignment operator copies the specified array into this array.

void delta ( int32  dt)

Set delta value.

"delta" sets a new delta value for automatic growing.

int32 delta ( ) const

Get delta value.

"delta" returns the current delta value.

void enableExponentialGroth ( bool  state)
inline

Instead of using delta, always double the array size.

bool hasExponentialGroth ( ) const
inline
bool resize ( int32  newsize)

Resize the array.

"resize" resizes the storage allocated for this array.

int32 total ( ) const
virtual

Return number of items.

"total" returns the number of items in this array.

Reimplemented from TContainer< T >.

bool isEmpty ( ) const
virtual

Is container empty?

"isEmpty" returns whether or not this array has any items in it.

Reimplemented from TContainer< T >.

bool add ( const T &  rObj)
virtual

Add item to container.

"add" appends the specified item to this array.

Implements TContainer< T >.

bool remove ( const T &  rObj)
virtual

Remove equal item.

"remove" removes the first occurrence of an item equal to the specified item in the array.

Implements TContainer< T >.

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

Remove item at current iterator position.

"remove" removes the item pointed to by the specified iterator.

Implements TContainer< T >.

bool removeAt ( int32  idx)
virtual

Remove item at given index.

"removeAt" removes the item at the specified index.

Implements TContainer< T >.

void removeAll ( )
virtual

Remove all items from list.

"removeAll" sets the number of items in this array to zero.

Implements TContainer< T >.

bool removeRange ( int32  from,
int32  to 
)

Remove items from index 'from' to index 'to'.

"removeRange" removes all items in the specified index range including the index boundaries

Parameters
from: start index
toend index
Returns
success
T & at ( int32  idx) const
virtual

Get item at index.

"at" returns the item at the specified index.

Returns
item found or error object

Reimplemented from TContainer< 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.

"lookup" returns the first occurrence of the item equal to the specified item in the array.

Returns
item found or error object

Reimplemented from TContainer< T >.

bool contains ( const T &  rObj) const
virtual

See if container has equal item.

"contains" checks the array for an item equal to the input.

Reimplemented from TContainer< T >.

int32 occurrences ( const T &  rObj) const
virtual

Count occurrences of equal items.

"occurrences" counts the number of occurrences of items equal to the specified item.

Reimplemented from TContainer< T >.

TIterator< T > * newIterator ( ) const
virtual

Create container iterator instance.

"newIterator" creates and returns a new array iterator.

Implements TContainer< T >.

virtual int32 shouldGo ( const T &  item) const
pure virtual
virtual int32 index ( const T &  item) const
pure virtual
T& first ( ) const
inline
T& last ( ) const
inline
int cmpData ( const void *  obj1,
const void *  obj2 
)
staticprotected

Quick sort compare function.

"cmpData" is called by the standard library qsort function for sorting the array into ascending order.

int32 indexSorted ( const T &  rObj) const
protected

"indexSorted" returns the index of the first occurrence of an item equal to the specified item.

Returns
index found or "-1" if not found
int32 indexUnsorted ( const T &  rObj) const
protected

"indexUnsorted" returns the index of the first occurrence of an item equal to the specified item.

Returns
index found or "-1" if not found
int32 shouldGoSorted ( const T &  rObj) const
protected

Get index for potential item.

"shouldGoSorted" returns the index for a potential insert/add operation using ">", "<", and "==" operators

Returns
index found
int32 shouldGoUnsorted ( const T &  ) const
protected

Get index for potential item.

"shouldGoUnsorted" returns the index for a potential insert/add operation

Returns
index of last event + 1 "append item"
void doQuickSort ( )
protected

"quickSort" uses the standard library to perform a quick sort on this array.

bool doInsertAt ( int32  idx,
const T &  rObj 
)
protected

Insert item at index.

inserts the specified item at the specified index shifting the other items to make room.

Field Documentation

const int32 kDefaultDelta = 10
static
const int32 kExponentialDelta = -1
static
int32 _delta
protected

Delta value.

int32 _total
protected

Number of items.

T* _entries
protected

Array of "T" pointers.

Empty

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