aboutsummaryrefslogtreecommitdiff
path: root/src/array.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-09-05 16:20:48 +0000
committerMike Buland <eichlan@xagasoft.com>2007-09-05 16:20:48 +0000
commitc4176c4dc172e8b30536a4eb90ae6f6f80f75436 (patch)
treefc49547f3c48ecb400fd9c972ee745beef7e0216 /src/array.h
parenta3cb276a2b048ce94b04e95b3ac87f323e075712 (diff)
downloadlibbu++-c4176c4dc172e8b30536a4eb90ae6f6f80f75436.tar.gz
libbu++-c4176c4dc172e8b30536a4eb90ae6f6f80f75436.tar.bz2
libbu++-c4176c4dc172e8b30536a4eb90ae6f6f80f75436.tar.xz
libbu++-c4176c4dc172e8b30536a4eb90ae6f6f80f75436.zip
This commit has part of an Array class, I'm just not sure I really need it
right now. Unfortunately it doesn't compile right now, if you want to build this version, just delete array. On the other hand, Bu::List now has enqueue/dequeue functions.
Diffstat (limited to 'src/array.h')
-rw-r--r--src/array.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/array.h b/src/array.h
new file mode 100644
index 0000000..cd0d7da
--- /dev/null
+++ b/src/array.h
@@ -0,0 +1,78 @@
1#ifndef BU_ARRAY_H
2#define BU_ARRAY_H
3
4#include <memory>
5#include "bu/exceptionbase.h"
6
7namespace Bu
8{
9 /**
10 * Array type container, just like a normal array only flexible and keeps
11 * track of your memory for you.
12 *
13 *@param value (typename) The type of data to store in your list
14 *@param valuealloc (typename) Memory Allocator for your value type
15 *@param linkalloc (typename) Memory Allocator for the list links.
16 */
17 template<typename value, int inc=10, typename valuealloc=std::allocator<value> >
18 class Array
19 {
20 private:
21 typedef class Array<value, inc, valuealloc> MyType;
22
23 public:
24 Array() :
25 pData( NULL ),
26 iSize( 0 ),
27 iCapacity( 0 )
28 {
29 }
30
31 Array( const MyType &src ) :
32 pData( NULL ),
33 iSize( 0 ),
34 iCapacity( 0 )
35 {
36 // for( Link *pCur = src.pFirst; pCur; pCur = pCur->pNext )
37 // {
38 // append( *pCur->pValue );
39 // }
40 }
41
42 ~Array()
43 {
44 clear();
45 }
46
47 /**
48 * Clear the data from the list.
49 */
50 void clear()
51 {
52 }
53
54 operator
55
56 /**
57 * Get the current size of the list.
58 *@returns (int) The current size of the list.
59 */
60 int getSize() const
61 {
62 return iSize;
63 }
64
65 int getCapacity() const
66 {
67 return iCapacity;
68 }
69
70 private:
71 valuealloc va;
72 value *pData;
73 int iSize;
74 int iCapacity;
75 };
76}
77
78#endif