blob: 1d1937be384983ad41c98c68e412375e39a62958 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// std.h --
// $Id$
// This is part of Metakit, see http://www.equi4.com/metakit/
/** @file
* Configuration header for STL-based builds
*/
#define q4_STD 1
#include "mk4str.h"
#include <vector>
/////////////////////////////////////////////////////////////////////////////
template<class T>
class c4_ArrayT
{
#ifdef _MSC_VER
d4_std::vector< T, d4_std::allocator<T> > _vector;
#else
d4_std::vector< T, d4_std::alloc > _vector;
#endif
public:
c4_ArrayT () { }
~c4_ArrayT () { }
int GetSize() const { return _vector.size(); }
void SetSize(int nNewSize, int =-1) { _vector.resize(nNewSize); }
T GetAt(int nIndex) const { return _vector[nIndex]; }
T& ElementAt(int nIndex) { return _vector[nIndex]; }
void SetAt(int nIndex, const T& newElement)
{
_vector[nIndex] = newElement;
}
int Add(const T& newElement)
{
int n = _vector.size();
_vector.push_back(newElement);
return n;
}
void InsertAt(int nIndex, const T& newElement, int nCount =1)
{
_vector.insert(&_vector[nIndex], nCount, newElement);
}
void RemoveAt(int nIndex, int nCount =1)
{
_vector.erase(&_vector[nIndex], &_vector[nIndex+nCount]);
}
};
typedef c4_ArrayT<t4_i32> c4_DWordArray;
typedef c4_ArrayT<void*> c4_PtrArray;
typedef c4_ArrayT<c4_String> c4_StringArray;
/////////////////////////////////////////////////////////////////////////////
|