00001 // rdValueArray.h 00002 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00003 // Copyright 2003 Realistic Dynamics, Inc. 00004 // All rights reserved. 00005 // 00006 // Please do not read, copy, distribute, or use without permission. 00007 // Contact: Frank C. Anderson, fca@RealisticDynamics.com 00008 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 #ifndef __rdValueArray_h__ 00010 #define __rdValueArray_h__ 00011 00012 00013 #include "rdTools.h" 00014 #include "rdObject.h" 00015 00016 #define rdValueArray_CAPMIN 1; 00017 00018 //============================================================================= 00019 //============================================================================= 00031 template <class T> class RDTOOLS_API rdValueArray : public rdObject 00032 { 00033 00034 //============================================================================= 00035 // DATA 00036 //============================================================================= 00037 public: 00039 static const int CAPMIN; 00040 private: 00042 int _firstEmpty; 00043 protected: 00045 char *_descrip; 00047 int _capacity; 00050 int _capacityIncrement; 00052 T *_array; 00053 00054 //============================================================================= 00055 // METHODS 00056 //============================================================================= 00057 public: 00058 rdValueArray(int aCapacity=128,const char *aName="UNKNOWN"); 00059 virtual ~rdValueArray(); 00060 private: 00061 void setNull(); 00062 public: 00063 00064 //-------------------------------------------------------------------------- 00065 // DESCRIPTION 00066 //-------------------------------------------------------------------------- 00067 void setDescription(const char *aDescrip=NULL); 00068 const char* getDescription() const; 00069 00070 //-------------------------------------------------------------------------- 00071 // CAPACITY 00072 //-------------------------------------------------------------------------- 00073 bool ensureCapacity(int aCapacity); 00074 int getCapacity() const; 00075 void setCapacityIncrement(int aIncrement=-1); 00076 int getCapacityIncrement() const; 00077 00078 //-------------------------------------------------------------------------- 00079 // STORAGE 00080 //-------------------------------------------------------------------------- 00081 void setFirstEmpty(int aIndex=0); 00082 int getFirstEmpty() const; 00083 int append(const T &aValue); 00084 int append(const rdValueArray<T> &aArray); 00085 void set(int aIndex,const T &aValue); 00086 T& get(int aIndex) const; 00087 T& getLast() const; 00088 void insert(int aIndex,const T &aValue); 00089 void remove(int aIndex); 00090 void remove(const T &aValue); 00091 int searchSequential(const T &aValue,int aStartIndex=0); 00092 int searchBinary(const T &aValue); 00093 00094 //-------------------------------------------------------------------------- 00095 // XML 00096 //-------------------------------------------------------------------------- 00097 virtual void updateObject(bool aDeep=true); 00098 virtual void updateNode(bool aDeep=true); 00099 00100 //============================================================================= 00101 }; // END of class rdValueArray 00102 //============================================================================= 00103 //============================================================================= 00104 00105 #endif //__rdValueArray_h__
1.3