Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ResizeArrayRaw< Elem > Class Template Reference

#include <ResizeArrayRaw.h>

List of all members.

Public Member Functions

int size (void) const
Elem & operator[] (int index) const
 ResizeArrayRaw (void)
 ResizeArrayRaw (const ResizeArrayRaw< Elem > &rar)
 ResizeArrayRaw (Elem **const array, int arraySize, int allocSize)
 ~ResizeArrayRaw (void)
void setResizeParams (int min, float growth)
ResizeArrayRaw< Elem > & operator= (const ResizeArrayRaw< Elem > &rar)
void resize (int size)
void clear (void)
int del (int index, int number)
void ins (const Elem &e, int index)
int find (const Elem &e)

Friends

class ResizeArray<Elem>
class SortableResizeArray<Elem>
class ResizeArrayIter<Elem>

template<class Elem>
class ResizeArrayRaw< Elem >


Constructor & Destructor Documentation

template<class Elem>
ResizeArrayRaw< Elem >::ResizeArrayRaw void   )  [inline]
 

Definition at line 84 of file ResizeArrayRaw.h.

00084                          : 
00085       array((Elem *)0), varray((unsigned char *)0), arraySize(0), allocSize(0) { 
00086       growthFactor = GrowthFactor;
00087       minSize = MinSize;
00088     }

template<class Elem>
ResizeArrayRaw< Elem >::ResizeArrayRaw const ResizeArrayRaw< Elem > &  rar  )  [inline]
 

Definition at line 91 of file ResizeArrayRaw.h.

00091                                                      : 
00092       array((Elem *)0), varray((unsigned char *)0), arraySize(0), allocSize(0) {
00093       growthFactor = rar.growthFactor;
00094       minSize = rar.minSize;
00095       // We want rar.size() slots, but no constructor run on the elements
00096       resizeRaw(rar.size());
00097       CmiMemcpy((void*)array, (void*)rar.array, sizeof(Elem)*rar.size());
00098       arraySize = rar.size();
00099     }

template<class Elem>
ResizeArrayRaw< Elem >::ResizeArrayRaw Elem **const   array,
int  arraySize,
int  allocSize
[inline]
 

Definition at line 102 of file ResizeArrayRaw.h.

00102                                                                         {
00103       if (allocSize < arraySize) allocSize = arraySize;
00104       this->allocSize = allocSize;
00105       this->arraySize = arraySize;
00106       varray = (unsigned char *)*array;
00107       this->array = (Elem *)*array;
00108       *array = 0;
00109       growthFactor = GrowthFactor;
00110       minSize = MinSize;
00111     }

template<class Elem>
ResizeArrayRaw< Elem >::~ResizeArrayRaw void   )  [inline]
 

Definition at line 113 of file ResizeArrayRaw.h.

00113                           {
00114       for (int i=0; i < arraySize; i++) {
00115         array[i].~Elem();
00116       }
00117       delete[] varray;
00118     }


Member Function Documentation

template<class Elem>
void ResizeArrayRaw< Elem >::clear void   )  [inline]
 

Definition at line 162 of file ResizeArrayRaw.h.

Referenced by ResizeArray< AngleElem >::clear().

00162                      {
00163       for (int i=0; i<arraySize; i++) {
00164         array[i].~Elem();
00165       }
00166       delete [] varray;
00167       array = 0;
00168       varray = 0;
00169       arraySize = 0;
00170       allocSize = 0;
00171     }

template<class Elem>
int ResizeArrayRaw< Elem >::del int  index,
int  number
[inline]
 

Definition at line 173 of file ResizeArrayRaw.h.

Referenced by ResizeArray< AngleElem >::del().

00173                                           {
00174       int i;
00175   
00176       // Fix up number to delete if deletes off end of array
00177       if (index >= arraySize)
00178         number=0; // for inline sake, don't have multiple returns
00179       else if (index+number-1 > arraySize) {
00180         number = index-arraySize+1;
00181       }
00182   
00183       // Destruct objects to be deleted
00184       for (i=index; i < index+number; i++) {
00185         array[i].~Elem();
00186       }
00187   
00188       // Shift down
00189       memmove((void *)(array+index),
00190          (void *)(array+index+number),
00191          (arraySize-number-index)*sizeof(Elem));
00192       
00193       // fixup size of array
00194       arraySize -= number;
00195       return(number);
00196     }

template<class Elem>
int ResizeArrayRaw< Elem >::find const Elem &  e  )  [inline]
 

Definition at line 229 of file ResizeArrayRaw.h.

Referenced by ResizeArray< AngleElem >::find().

00229                                    {
00230       for (int i=0; i<arraySize; i++)
00231         if (array[i] == e) return i;
00232       return -1;
00233     }

template<class Elem>
void ResizeArrayRaw< Elem >::ins const Elem &  e,
int  index
[inline]
 

Definition at line 202 of file ResizeArrayRaw.h.

Referenced by ResizeArray< AngleElem >::add(), and ResizeArray< AngleElem >::insert().

00202                                               {
00203       // Size array depending if index is in current array or reaches beyond.
00204       if (index < arraySize) {
00205         resizeRaw(arraySize+1);
00206         // Shift up
00207         memmove((void *)(array+index+1),
00208           (void *)(array+index),
00209           (arraySize-index)*sizeof(Elem));
00210       } else {
00211         resizeRaw(index+1);
00212       }
00213       
00214       // Write in new element via assignment - allows any refcounting
00215       // etc. to take place correctly!
00216       new((void *)&array[index]) Elem;
00217       array[index] = e;
00218     
00219       // Take care of fill and setting correct arraySize 
00220       if (index > arraySize) {
00221         for (Elem *tmp = array+arraySize; tmp < array+index; tmp++) {
00222           new ((void *)tmp) Elem;
00223         }
00224         arraySize = index+1;
00225       } else
00226         arraySize++;
00227     }

template<class Elem>
ResizeArrayRaw<Elem>& ResizeArrayRaw< Elem >::operator= const ResizeArrayRaw< Elem > &  rar  )  [inline]
 

Definition at line 129 of file ResizeArrayRaw.h.

00129                                                                        {
00130       growthFactor = rar.growthFactor;
00131       minSize = rar.minSize;
00132   
00133       // Clean up this array
00134       resize(0);
00135       resizeRaw(rar.size());
00136   
00137       CmiMemcpy((void*)array, (void*)rar.array, sizeof(Elem)*rar.size());
00138       arraySize = rar.size();
00139       return *this;
00140     }

template<class Elem>
Elem& ResizeArrayRaw< Elem >::operator[] int  index  )  const [inline]
 

Definition at line 81 of file ResizeArrayRaw.h.

00081 { return array[index]; }

template<class Elem>
void ResizeArrayRaw< Elem >::resize int  size  )  [inline]
 

Definition at line 145 of file ResizeArrayRaw.h.

Referenced by ResizeArray< AngleElem >::resize(), and ResizeArray< AngleElem >::ResizeArray().

00145                           {
00146       int i;
00147   
00148       if (size < arraySize) {
00149         for (i=size; i<arraySize; i++) {
00150           array[i].~Elem();
00151         }
00152       } else if (size > arraySize) {
00153         resizeRaw(size);
00154         for (i=arraySize; i<size; i++) {
00155           new ((void *)&array[i]) Elem;
00156         }
00157       }
00158       arraySize = size;
00159     }

template<class Elem>
void ResizeArrayRaw< Elem >::setResizeParams int  min,
float  growth
[inline]
 

Definition at line 122 of file ResizeArrayRaw.h.

Referenced by ResizeArray< AngleElem >::setParams().

00122                                                 {
00123       minSize = min;
00124       growthFactor = growth;
00125     }

template<class Elem>
int ResizeArrayRaw< Elem >::size void   )  const [inline]
 

Definition at line 80 of file ResizeArrayRaw.h.

Referenced by ResizeArray< AngleElem >::add(), ResizeArrayRaw< AngleElem >::operator=(), ResizeArrayRaw< AngleElem >::ResizeArrayRaw(), and ResizeArray< AngleElem >::size().

00080 { return arraySize; }


Friends And Related Function Documentation

template<class Elem>
friend class ResizeArray<Elem> [friend]
 

Definition at line 76 of file ResizeArrayRaw.h.

template<class Elem>
friend class ResizeArrayIter<Elem> [friend]
 

Definition at line 78 of file ResizeArrayRaw.h.

template<class Elem>
friend class SortableResizeArray<Elem> [friend]
 

Definition at line 77 of file ResizeArrayRaw.h.


The documentation for this class was generated from the following file:
Generated on Fri May 25 04:07:24 2012 for NAMD by  doxygen 1.3.9.1