PtrVec< T > Class Template Reference

PtrVec< T > Class Template Reference

#include <ptrvec.h>

Class Description

template<class T>
class PtrVec< T >

See also
Class PtrVector

Description:
This template class represents a variable length array of pointers which can be stored and manipulated.
+ Inheritance diagram for PtrVec< T >:

Public Member Functions

 PtrVec ()
 
T * operator[] (int i) const
 
T *& operator[] (int i)
 
PtrVec< T > & operator= (const PtrVec< T > &v)
 
void append (T *ptr, int extra=10)
 
void insertAt (T *ptr, int at, int extra=10)
 
T * remove (int i)
 
T * removeLast ()
 
void deleteAll ()
 
- Public Member Functions inherited from PtrVector
UtilExport void reshape (int i)
 
UtilExport void setLength (int i)
 
UtilExport void clear ()
 
void shrink ()
 
int length () const
 
int capacity () const
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 
- Protected Member Functions inherited from PtrVector
 PtrVector ()
 
UtilExport ~PtrVector ()
 
UtilExport PtrVector (const PtrVector &v)
 
UtilExport PtrVectoroperator= (const PtrVector &v)
 
UtilExport void append (void *ptr, int extra)
 
UtilExport void insertAt (void *ptr, int at, int extra)
 
UtilExport voidremove (int i)
 
UtilExport voidremoveLast ()
 
voidoperator[] (int i) const
 
void *& operator[] (int i)
 
- Protected Attributes inherited from PtrVector
int size
 
int nused
 
void ** data
 

Constructor & Destructor Documentation

PtrVec ( )
inline
Remarks
Constructor.
Default Implementation:
{}
129 :PtrVector() {}
PtrVector()
Definition: ptrvec.h:37

Member Function Documentation

T* operator[] ( int  i) const
inline
Remarks
Indexing operator.
Default Implementation:
{ return (T*)PtrVector::operator[](i); }
133 { return (T*)PtrVector::operator[](i); }
void * operator[](int i) const
Definition: ptrvec.h:84
T*& operator[] ( int  i)
inline
Remarks
Indexing operator.
Default Implementation:
{ return (T*&)PtrVector::operator[](i); }
137 { return (T*&)PtrVector::operator[](i); }
void * operator[](int i) const
Definition: ptrvec.h:84
PtrVec<T>& operator= ( const PtrVec< T > &  v)
inline
Remarks
Assignment operator.
Default Implementation:
{ return (PtrVec<T>&)PtrVector::operator=(v); }
141 { return (PtrVec<T>&)PtrVector::operator=(v); }
Definition: ptrvec.h:123
UtilExport PtrVector & operator=(const PtrVector &v)
void append ( T *  ptr,
int  extra = 10 
)
inline
Remarks
This method allows you to append data to the array.
Parameters:
T *ptr

A pointer to the data.

int extra = 10

The amount of extra space you wish to allocate.
Default Implementation:
{ PtrVector::append(ptr,extra); }
150 { PtrVector::append(ptr,extra); }
UtilExport void append(void *ptr, int extra)
void insertAt ( T *  ptr,
int  at,
int  extra = 10 
)
inline
Remarks
This method allows you to insert data into the array at the specified location.
Parameters:
T* ptr

A pointer to the data to add.

int at

The index in the array you wish to insert at.

int extra = 10

The extra space you wish to reserve.
Default Implementation:
{ PtrVector::insertAt(ptr,at,extra); }
162 { PtrVector::insertAt(ptr,at,extra); }
UtilExport void insertAt(void *ptr, int at, int extra)
T* remove ( int  i)
inline
Remarks
This method allows you to remove an element from the array.
Parameters:
int i

The index into the array.
Default Implementation:
{ return (T *)PtrVector::remove(i); }
169 { return (T *)PtrVector::remove(i); }
UtilExport void * remove(int i)
T* removeLast ( )
inline
Remarks
This method will remove the last item in the array.
Returns
A pointer to the new last item.
Default Implementation:
{ return (T *)PtrVector::removeLast(); }
174 { return (T *)PtrVector::removeLast(); }
UtilExport void * removeLast()
void deleteAll ( )
Remarks
This method allows you to delete the entire array.
180 {
181  while (length()) {
182  T* p = removeLast();
183  delete p;
184  p = NULL;
185  }
186 }
#define NULL
Definition: autoptr.h:18
int length() const
Definition: ptrvec.h:112
T * removeLast()
Definition: ptrvec.h:174