author | skidd13 |
Sun, 22 Jun 2008 15:21:51 +0000 | |
changeset 11049 | f8bbc9635251 |
parent 11019 | 9c818b06c54d |
permissions | -rw-r--r-- |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
1 |
/* $Id$ */ |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
2 |
|
11019
9c818b06c54d
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13
parents:
11018
diff
changeset
|
3 |
/** @file smallvec_type.hpp Simple vector class that allows allocating an item without the need to copy this->data needlessly. */ |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
4 |
|
11019
9c818b06c54d
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13
parents:
11018
diff
changeset
|
5 |
#ifndef SMALLVEC_TYPE_HPP |
9c818b06c54d
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13
parents:
11018
diff
changeset
|
6 |
#define SMALLVEC_TYPE_HPP |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
7 |
|
11019
9c818b06c54d
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13
parents:
11018
diff
changeset
|
8 |
#include "alloc_func.hpp" |
9c818b06c54d
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13
parents:
11018
diff
changeset
|
9 |
#include "math_func.hpp" |
10791
0f3e94733e65
(svn r13342) -Fix: smallvec.h/sortlist_type.h didn't include everything they needed.
rubidium
parents:
10697
diff
changeset
|
10 |
|
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
11 |
/** |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
12 |
* Simple vector template class. |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
13 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
14 |
* @note There are no asserts in the class so you have |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
15 |
* to care about that you grab an item which is |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
16 |
* inside the list. |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
17 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
18 |
* @param T The type of the items stored |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
19 |
* @param S The steps of allocation |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
20 |
*/ |
10683 | 21 |
template <typename T, uint S> |
11019
9c818b06c54d
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13
parents:
11018
diff
changeset
|
22 |
class SmallVector { |
9c818b06c54d
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13
parents:
11018
diff
changeset
|
23 |
protected: |
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
24 |
T *data; ///< The pointer to the first item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
25 |
uint items; ///< The number of items stored |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
26 |
uint capacity; ///< The avalible space for storing items |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
27 |
|
11019
9c818b06c54d
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13
parents:
11018
diff
changeset
|
28 |
public: |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
29 |
SmallVector() : data(NULL), items(0), capacity(0) { } |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
30 |
|
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
31 |
~SmallVector() |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
32 |
{ |
10683 | 33 |
free(this->data); |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
34 |
} |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
35 |
|
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
36 |
/** |
10697
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
37 |
* Remove all items from the list. |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
38 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
39 |
FORCEINLINE void Clear() |
10697
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
40 |
{ |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
41 |
/* In fact we just reset the item counter avoiding the need to |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
42 |
* probably reallocate the same amount of memory the list was |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
43 |
* previously using. */ |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
44 |
this->items = 0; |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
45 |
} |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
46 |
|
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
47 |
/** |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
48 |
* Compact the list down to the smallest block size boundary. |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
49 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
50 |
FORCEINLINE void Compact() |
10697
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
51 |
{ |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
52 |
uint capacity = Align(this->items, S); |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
53 |
if (capacity >= this->capacity) return; |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
54 |
|
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
55 |
this->capacity = capacity; |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
56 |
this->data = ReallocT(this->data, this->capacity); |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
57 |
} |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
58 |
|
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
59 |
/** |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
60 |
* Append an item and return it. |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
61 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
62 |
FORCEINLINE T *Append() |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
63 |
{ |
10683 | 64 |
if (this->items == this->capacity) { |
65 |
this->capacity += S; |
|
66 |
this->data = ReallocT(this->data, this->capacity); |
|
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
67 |
} |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
68 |
|
10683 | 69 |
return &this->data[this->items++]; |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
70 |
} |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
71 |
|
10697
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
72 |
/** |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
73 |
* Get the number of items in the list. |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
74 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
75 |
FORCEINLINE uint Length() const |
10697
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
76 |
{ |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
77 |
return this->items; |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
78 |
} |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
79 |
|
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
80 |
/** |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
81 |
* Get the pointer to the first item (const) |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
82 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
83 |
* @return the pointer to the first item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
84 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
85 |
FORCEINLINE const T *Begin() const |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
86 |
{ |
10683 | 87 |
return this->data; |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
88 |
} |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
89 |
|
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
90 |
/** |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
91 |
* Get the pointer to the first item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
92 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
93 |
* @return the pointer to the first item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
94 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
95 |
FORCEINLINE T *Begin() |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10205
diff
changeset
|
96 |
{ |
10683 | 97 |
return this->data; |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10205
diff
changeset
|
98 |
} |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10205
diff
changeset
|
99 |
|
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
100 |
/** |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
101 |
* Get the pointer behind the last valid item (const) |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
102 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
103 |
* @return the pointer behind the last valid item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
104 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
105 |
FORCEINLINE const T *End() const |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
106 |
{ |
10683 | 107 |
return &this->data[this->items]; |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
108 |
} |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10205
diff
changeset
|
109 |
|
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
110 |
/** |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
111 |
* Get the pointer behind the last valid item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
112 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
113 |
* @return the pointer behind the last valid item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
114 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
115 |
FORCEINLINE T *End() |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10205
diff
changeset
|
116 |
{ |
10683 | 117 |
return &this->data[this->items]; |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10205
diff
changeset
|
118 |
} |
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
119 |
|
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
120 |
/** |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
121 |
* Get the pointer to item "number" (const) |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
122 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
123 |
* @param index the position of the item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
124 |
* @return the pointer to the item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
125 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
126 |
FORCEINLINE const T *Get(uint index) const |
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
127 |
{ |
10683 | 128 |
return &this->data[index]; |
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
129 |
} |
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
130 |
|
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
131 |
/** |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
132 |
* Get the pointer to item "number" |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
133 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
134 |
* @param index the position of the item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
135 |
* @return the pointer to the item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
136 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
137 |
FORCEINLINE T *Get(uint index) |
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
138 |
{ |
10683 | 139 |
return &this->data[index]; |
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
140 |
} |
10697
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
141 |
|
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
142 |
/** |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
143 |
* Get item "number" (const) |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
144 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
145 |
* @param index the positon of the item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
146 |
* @return the item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
147 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
148 |
FORCEINLINE const T &operator[](uint index) const |
10697
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
149 |
{ |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
150 |
return this->data[index]; |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
151 |
} |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
152 |
|
11018
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
153 |
/** |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
154 |
* Get item "number" |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
155 |
* |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
156 |
* @param index the positon of the item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
157 |
* @return the item |
830493d2f499
(svn r13574) -Doc: Document the small vector template class
skidd13
parents:
10791
diff
changeset
|
158 |
*/ |
11049
f8bbc9635251
(svn r13606) -Codechange: use "static FORCEINLINE" where possible as default for core functions (big functions use just inline instead)
skidd13
parents:
11019
diff
changeset
|
159 |
FORCEINLINE T &operator[](uint index) |
10697
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
160 |
{ |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
161 |
return this->data[index]; |
9ec651be998d
(svn r13245) -Codechange: Use SmallVectors for generating vehicle lists, simplifying calling code somewhat.
peter1138
parents:
10683
diff
changeset
|
162 |
} |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
163 |
}; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
diff
changeset
|
164 |
|
11019
9c818b06c54d
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13
parents:
11018
diff
changeset
|
165 |
#endif /* SMALLVEC_TYPE_HPP */ |