summaryrefslogtreecommitdiff
path: root/common/array.h
diff options
context:
space:
mode:
authorleo2004-06-10 21:17:42 +0000
committerleo2004-06-10 21:17:42 +0000
commitc117a3dc16af7346d750475e648252f5dbffce9b (patch)
tree55fdb05f3a9995972d4b0e2ecd2660ec7c125218 /common/array.h
parentb6f4b5a61c74e319ebd627f14fb4fe0b56284b2b (diff)
Pointer Array class.
git-svn-id: http://svn.leocad.org/trunk@358 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/array.h')
-rwxr-xr-xcommon/array.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/common/array.h b/common/array.h
index 1c5d5a3..c8adfbf 100755
--- a/common/array.h
+++ b/common/array.h
@@ -10,7 +10,6 @@ class PtrArray
typedef int (*LC_PTRARRAY_COMPARE_FUNC) (T* a, T* b, void* data);
- void SetSize (int nSize);
int GetSize () const
{ return m_nLength; }
@@ -31,6 +30,35 @@ class PtrArray
int m_nAlloc;
};
+template <class T>
+class ObjArray
+{
+public:
+ ObjArray(int Size = 0, int Grow = 16);
+ ~ObjArray();
+
+ typedef int (*LC_OBJARRAY_COMPARE_FUNC)(const T& A, const T& B, void* SortData);
+
+ int GetSize() const
+ { return m_Length; }
+
+ void RemoveIndex(int Index);
+ void Add(const T& Obj);
+ void AddSorted(const T& Obj, LC_OBJARRAY_COMPARE_FUNC Func, void* SortData);
+ void InsertAt(int Index, const T& Obj);
+
+ T& operator [](int Index) const
+ { return m_Data[Index]; }
+
+protected:
+ void Expand(int Grow);
+
+ T* m_Data;
+ int m_Length;
+ int m_Alloc;
+ int m_Grow;
+};
+
#include "array.cpp"
#endif // _ARRAY_H_