author | terom@frrb.lan |
Fri, 19 Dec 2008 01:38:09 +0200 | |
changeset 10439 | 50f056aa3024 |
parent 9111 | 48ce04029fe4 |
permissions | -rw-r--r-- |
5633
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
1 |
/* $Id$ */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
2 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8037
diff
changeset
|
3 |
/** @file fixedsizearray.hpp A fixed size array that doesn't create items until needed. */ |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
5633
diff
changeset
|
4 |
|
5633
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
5 |
#ifndef FIXEDSIZEARRAY_HPP |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
6 |
#define FIXEDSIZEARRAY_HPP |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
7 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
8 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
9 |
/** fixed size array |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
10 |
* Upon construction it preallocates fixed size block of memory |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
11 |
* for all items, but doesn't construct them. Item's construction |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
12 |
* is delayed. */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
13 |
template <class Titem_, int Tcapacity_> |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
14 |
struct CFixedSizeArrayT { |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
15 |
/** the only member of fixed size array is pointer to the block |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
16 |
* of C array of items. Header can be found on the offset -sizeof(CHdr). */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
17 |
Titem_ *m_items; |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
18 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
19 |
/** header for fixed size array */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
20 |
struct CHdr |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
21 |
{ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
22 |
int m_num_items; ///< number of items in the array |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
23 |
int m_ref_cnt; ///< block reference counter (used by copy constructor and by destructor) |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
24 |
}; |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
25 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
26 |
// make types and constants visible from outside |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
27 |
typedef Titem_ Titem; // type of array item |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
28 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
29 |
static const int Tcapacity = Tcapacity_; // the array capacity (maximum size) |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
30 |
static const int TitemSize = sizeof(Titem_); // size of item |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
31 |
static const int ThdrSize = sizeof(CHdr); // size of header |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
32 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
33 |
/** Default constructor. Preallocate space for items and header, then initialize header. */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
34 |
CFixedSizeArrayT() |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
35 |
{ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
36 |
// allocate block for header + items (don't construct items) |
8037
8aa4ace04383
(svn r11597) -Change: replace all remaining instances of (re|m|c)alloc with (Re|M|C)allocT and add a check for out-of-memory situations to the *allocT functions.
rubidium
parents:
6481
diff
changeset
|
37 |
m_items = (Titem*)((MallocT<int8>(ThdrSize + Tcapacity * sizeof(Titem))) + ThdrSize); |
5633
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
38 |
SizeRef() = 0; // initial number of items |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
39 |
RefCnt() = 1; // initial reference counter |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
40 |
} |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
41 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
42 |
/** Copy constructor. Preallocate space for items and header, then initialize header. */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
43 |
CFixedSizeArrayT(const CFixedSizeArrayT<Titem_, Tcapacity_>& src) |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
44 |
{ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
45 |
// share block (header + items) with the source array |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
46 |
m_items = src.m_items; |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
47 |
RefCnt()++; // now we share block with the source |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
48 |
} |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
49 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
50 |
/** destroy remaining items and free the memory block */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
51 |
~CFixedSizeArrayT() |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
52 |
{ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
53 |
// release one reference to the shared block |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
54 |
if ((--RefCnt()) > 0) return; // and return if there is still some owner |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
55 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
56 |
Clear(); |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
57 |
// free the memory block occupied by items |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
58 |
free(((int8*)m_items) - ThdrSize); |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
59 |
m_items = NULL; |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
60 |
} |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
61 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
62 |
/** Clear (destroy) all items */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
63 |
FORCEINLINE void Clear() |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
64 |
{ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
65 |
// walk through all allocated items backward and destroy them |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
66 |
for (Titem* pItem = &m_items[Size() - 1]; pItem >= m_items; pItem--) { |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
67 |
pItem->~Titem_(); |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
68 |
} |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
69 |
// number of items become zero |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
70 |
SizeRef() = 0; |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
71 |
} |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
72 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
73 |
protected: |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
74 |
/** return reference to the array header (non-const) */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
75 |
FORCEINLINE CHdr& Hdr() { return *(CHdr*)(((int8*)m_items) - ThdrSize); } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
76 |
/** return reference to the array header (const) */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
77 |
FORCEINLINE const CHdr& Hdr() const { return *(CHdr*)(((int8*)m_items) - ThdrSize); } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
78 |
/** return reference to the block reference counter */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
79 |
FORCEINLINE int& RefCnt() { return Hdr().m_ref_cnt; } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
80 |
/** return reference to number of used items */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
81 |
FORCEINLINE int& SizeRef() { return Hdr().m_num_items; } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
82 |
public: |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
83 |
/** return number of used items */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
84 |
FORCEINLINE int Size() const { return Hdr().m_num_items; } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
85 |
/** return true if array is full */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
86 |
FORCEINLINE bool IsFull() const { return Size() >= Tcapacity; }; |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
87 |
/** return true if array is empty */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
88 |
FORCEINLINE bool IsEmpty() const { return Size() <= 0; }; |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
89 |
/** index validation */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
90 |
FORCEINLINE void CheckIdx(int idx) const { assert(idx >= 0); assert(idx < Size()); } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
91 |
/** add (allocate), but don't construct item */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
92 |
FORCEINLINE Titem& AddNC() { assert(!IsFull()); return m_items[SizeRef()++]; } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
93 |
/** add and construct item using default constructor */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
94 |
FORCEINLINE Titem& Add() { Titem& item = AddNC(); new(&item)Titem; return item; } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
95 |
/** return item by index (non-const version) */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
96 |
FORCEINLINE Titem& operator [] (int idx) { CheckIdx(idx); return m_items[idx]; } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
97 |
/** return item by index (const version) */ |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
98 |
FORCEINLINE const Titem& operator [] (int idx) const { CheckIdx(idx); return m_items[idx]; } |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
99 |
}; |
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
100 |
|
e1905dacc378
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff
changeset
|
101 |
#endif /* FIXEDSIZEARRAY_HPP */ |