cgma
|
#include <VGArray.hpp>
Public Member Functions | |
VGArray (int initial_size=0) | |
~VGArray () | |
int | size () const |
void | size (int new_size) |
void | size_end (int new_size) |
void | push (const T &entry) |
const T & | pop () |
T & | operator[] (int index) |
const T & | operator[] (int index) const |
void | remove (int index) |
void | insert (const T &entry, int index) |
int | find (const T &entry, int search_from=0) const |
void | reverse () |
Private Member Functions | |
const VGArray & | operator= (const VGArray< T > &) |
VGArray (const VGArray< T > &) | |
Static Private Member Functions | |
static int | storage (int size) |
Private Attributes | |
T * | data_ |
int | storage_ |
int | size_ |
Definition at line 16 of file VGArray.hpp.
T & VGArray< T >::operator[] | ( | int | index | ) | [inline] |
Definition at line 83 of file VGArray.hpp.
const T & VGArray< T >::operator[] | ( | int | index | ) | const [inline] |
Definition at line 90 of file VGArray.hpp.
Definition at line 97 of file VGArray.hpp.
Definition at line 156 of file VGArray.cpp.
Definition at line 79 of file VGArray.hpp.
{ return size_; }
Definition at line 32 of file VGArray.cpp.
{ if( new_size <= 0 ) { new_size = 0; } else if( new_size > storage_ ) { int new_stor = storage(new_size); assert( new_stor > storage_ ); T* new_array = new T[new_stor]; if( data_ ) { memcpy( new_array, data_, size_ * sizeof(T) ); delete [] data_; } data_ = new_array; storage_ = new_stor; } size_ = new_size; }
Definition at line 55 of file VGArray.cpp.
{ if( new_size <= 0 ) { new_size = 0; } else if( new_size > storage_ ) { int new_stor = storage(new_size); assert( new_stor > storage_ ); T* new_array = new T[new_stor]; if( data_ ) { memcpy( new_array + new_size - size_, data_, size_ * sizeof(T) ); delete [] data_; } data_ = new_array; storage_ = new_stor; } else if (new_size > size_) { T* read = data_ + size_; T* write = data_ + new_size; while ( read > data_ ) *(--write) = *(--read); } else if (new_size < size_) { T* read = data_ + size_ - new_size; T* write = data_; T* end = data_ + size_; while ( read < end ) *(write--) = *(read--); } size_ = new_size; }
Definition at line 93 of file VGArray.cpp.
Definition at line 71 of file VGArray.hpp.
Definition at line 73 of file VGArray.hpp.
Definition at line 72 of file VGArray.hpp.