SASC
DVBSoftCAM

cVector< T > Class Template Reference

#include <tools.h>

List of all members.

Public Member Functions

 cVector (int Allocated=10)
virtual ~cVector ()
T & At (int Index) const
const T & operator[] (int Index) const
T & operator[] (int Index)
int Size (void) const
virtual void Insert (T Data, int Before=0)
virtual void Append (T Data)
virtual void Clear (void)
void Sort (__compar_fn_t Compare)

Detailed Description

template<class T>
class cVector< T >

Definition at line 402 of file tools.h.


Constructor & Destructor Documentation

template<class T>
cVector< T >::cVector ( int  Allocated = 10) [inline]

Definition at line 419 of file tools.h.

  {
    allocated = 0;
    size = 0;
    data = NULL;
    Realloc(Allocated);
  }
template<class T>
virtual cVector< T >::~cVector ( ) [inline, virtual]

Definition at line 426 of file tools.h.

{ free(data); }

Member Function Documentation

template<class T>
virtual void cVector< T >::Append ( T  Data) [inline, virtual]

Definition at line 454 of file tools.h.

  {
    if (size >= allocated)
       Realloc(allocated * 4 / 2); // increase size by 50%
    data[size++] = Data;
  }
template<class T>
T& cVector< T >::At ( int  Index) const [inline]

Definition at line 427 of file tools.h.

  {
    Realloc(Index);
    if (Index >= size)
       size = Index + 1;
    return data[Index];
  }
template<class T>
virtual void cVector< T >::Clear ( void  ) [inline, virtual]

Reimplemented in cStringList.

Definition at line 460 of file tools.h.

{}
template<class T>
virtual void cVector< T >::Insert ( T  Data,
int  Before = 0 
) [inline, virtual]

Definition at line 443 of file tools.h.

  {
    if (Before < size) {
       Realloc(size);
       memmove(&data[Before + 1], &data[Before], (size - Before) * sizeof(T));
       size++;
       data[Before] = Data;
       }
    else
       Append(Data);
  }
template<class T>
const T& cVector< T >::operator[] ( int  Index) const [inline]

Definition at line 434 of file tools.h.

  {
    return At(Index);
  }
template<class T>
T& cVector< T >::operator[] ( int  Index) [inline]

Definition at line 438 of file tools.h.

  {
    return At(Index);
  }
template<class T>
int cVector< T >::Size ( void  ) const [inline]

Definition at line 442 of file tools.h.

{ return size; }
template<class T>
void cVector< T >::Sort ( __compar_fn_t  Compare) [inline]

Definition at line 461 of file tools.h.

  {
    qsort(data, size, sizeof(T), Compare);
  }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines