7
* Provides a non-STL alternative to the STL vector
9
template <typename FT_VECTOR_ITEM_TYPE>
10
class FTGL_EXPORT FTVector
13
typedef FT_VECTOR_ITEM_TYPE value_type;
14
typedef value_type& reference;
15
typedef const value_type& const_reference;
16
typedef value_type* iterator;
17
typedef const value_type* const_iterator;
18
typedef size_t size_type;
32
FTVector& operator =(const FTVector& v)
34
reserve(v.capacity());
36
iterator ptr = begin();
37
const_iterator vbegin = v.begin();
38
const_iterator vend = v.end();
40
while( vbegin != vend)
49
size_type size() const
54
size_type capacity() const
64
const_iterator begin() const
71
return begin() + size();
74
const_iterator end() const
76
return begin() + size();
84
reference operator [](size_type pos)
86
return( *(begin() + pos));
89
const_reference operator []( size_type pos) const
91
return( *(begin() + pos));
104
void reserve( size_type n)
112
void push_back(const value_type& x)
114
if( size() == capacity())
119
( *this)[size()] = x;
123
void resize(size_type n, value_type x)
136
end = this->begin() + n;
140
begin = this->begin() + n;
154
void expand(size_type capacity_hint = 0)
156
size_type new_capacity =( capacity() == 0) ? 256 : capacity()* 2;
159
while( new_capacity < capacity_hint)
165
value_type *new_items = new value_type[new_capacity];
167
iterator begin = this->begin();
168
iterator end = this->end();
169
value_type *ptr = new_items;
182
Capacity = new_capacity;
190
#endif // __FTVector__