ReactOS 0.4.16-dev-336-gb667d82
stl_bids.h
Go to the documentation of this file.
1// This is the STL wrapper for classlib/arrays.h from Borland's web site
2// It has been modified to be compatible with vc++ (Paul Branann 5/7/98)
3
4#pragma once
5
6#ifdef _MSC_VER
7#pragma warning(disable: 4786)
8#endif
9
10// #include <vector.h>
11// #include <algo.h>
12#include <vector>
13#include <algorithm>
14//#include <limits.h>
15using namespace std;
16
17template <class T>
18class TArrayAsVector : public vector<T> {
19private:
20 const unsigned int growable;
21 typedef size_t size_type;
24public:
26 size_type lower = 0,
27 int delta = 0) :
28 vector<T>( ),
29 growable(delta),
30 lowerbound(lower)
31 { vector<T>::reserve(upper-lower + 1);}
32
34 { // This call is unnecessary? (Paul Brannan 5/7/98)
35 // vector<T>::~vector( );
36 }
37
38 int Add(const T& item)
39 { if(!growable && vector<T>::size( ) == vector<T>::capacity( ))
40 return 0;
41 else
42 vector<T>::insert(vector<T>::end( ), item);
43 return 1; }
44
45 int AddAt(const T& item, size_type index)
46 { if(!growable &&
47 ((vector<T>::size( ) == vector<T>::capacity( )) ||
48 (ZeroBase(index > vector<T>::capacity( )) )))
49 return 0;
50 if(ZeroBase(index) > vector<T>::capacity( )) // out of bounds
51 { vector<T>::insert(vector<T>::end( ),
52 ZeroBase(index) - vector<T>::size( ), T( ));
53 vector<T>::insert(vector<T>::end( ), item); }
54 else
55 { vector<T>::insert(vector<T>::begin( ) + ZeroBase(index), item); }
56 return 1;
57 }
58
60 { return vector<T>::capacity( ); }
61
63 { if(location == UINT_MAX)
64 return INT_MAX;
65 else
66 return location + lowerbound; }
68 { vector<T>::erase(vector<T>::begin( ) + ZeroBase(index)); }
69
70 void Detach(const T& item)
71 { Destroy(Find(item)); }
72
74 { vector<T>::erase(vector<T>::begin( ) + ZeroBase(index)); }
75
76 void Destroy(const T& item)
77 { Destroy(Find(item)); }
78
79 size_type Find(const T& item) const
80 { const_iterator location = find(vector<T>::begin( ),
81 vector<T>::end( ), item);
82 if(location != vector<T>::end( ))
84 vector<T>::begin( )));
85 else
86 return INT_MAX; }
87
89 { return vector<T>::size( ); }
90
92 { if( index < lowerbound )
94 lowerbound));
95 else if( index >= BoundBase(vector<T>::size( )))
97
98 int HasMember(const T& item)
99 { if(Find(item) != INT_MAX)
100 return 1;
101 else
102 return 0; }
103
104 int IsEmpty( )
105 { return vector<T>::empty( ); }
106
107 int IsFull( )
108 { if(growable)
109 return 0;
110 if(vector<T>::size( ) == vector<T>::capacity( ))
111 return 1;
112 else
113 return 0; }
114
116 { return lowerbound; }
117
119 { return vector<T>::
121
123 { return vector<T>::
125
126 void Flush( )
127 {
129 }
130
132 size_type offset = 0)
133 { if(offset)
134 vector<T>::insert(vector<T>::begin( ), offset, T( ));
136 vector<T>::erase(vector<T>::end( ) - offset, vector<T>::end( )); }
137
139 { Detach(index); }
140
141 void SetData(size_type index, const T& item)
142 { (*this)[index] = item; }
143
145 { return BoundBase(vector<T>::capacity( )) - 1; }
146
148 { return index - lowerbound; }
149
150 // The assignment operator is not inherited (Paul Brannan 5/25/98)
153 // should growable and lowerbound be copied as well?
154 return *this;
155 }
156
157};
#define index(s, c)
Definition: various.h:29
void Detach(const T &item)
Definition: stl_bids.h:70
TArrayAsVector(size_type upper, size_type lower=0, int delta=0)
Definition: stl_bids.h:25
int IsEmpty()
Definition: stl_bids.h:104
size_type ArraySize()
Definition: stl_bids.h:59
const unsigned int growable
Definition: stl_bids.h:20
void Flush()
Definition: stl_bids.h:126
int Add(const T &item)
Definition: stl_bids.h:38
void SetData(size_type index, const T &item)
Definition: stl_bids.h:141
T & operator[](size_type index)
Definition: stl_bids.h:118
size_type BoundBase(size_type location) const
Definition: stl_bids.h:62
TArrayAsVector & operator=(const TArrayAsVector &v)
Definition: stl_bids.h:151
void RemoveEntry(size_type index)
Definition: stl_bids.h:138
void Destroy(size_type index)
Definition: stl_bids.h:73
size_t size_type
Definition: stl_bids.h:21
size_type UpperBound()
Definition: stl_bids.h:144
void Detach(size_type index)
Definition: stl_bids.h:67
size_type Find(const T &item) const
Definition: stl_bids.h:79
const size_type lowerbound
Definition: stl_bids.h:23
size_type LowerBound()
Definition: stl_bids.h:115
int AddAt(const T &item, size_type index)
Definition: stl_bids.h:45
void Reallocate(size_type sz, size_type offset=0)
Definition: stl_bids.h:131
void Destroy(const T &item)
Definition: stl_bids.h:76
size_type ZeroBase(size_type index) const
Definition: stl_bids.h:147
int HasMember(const T &item)
Definition: stl_bids.h:98
vector< T >::const_iterator const_iterator
Definition: stl_bids.h:22
int IsFull()
Definition: stl_bids.h:107
void Grow(size_type index)
Definition: stl_bids.h:91
size_type GetItemsInContainer()
Definition: stl_bids.h:88
static TAGID TAGID find
Definition: db.cpp:155
const GLdouble * v
Definition: gl.h:2040
GLuint index
Definition: glext.h:6031
GLintptr offset
Definition: glext.h:5920
#define INT_MAX
Definition: intsafe.h:150
#define UINT_MAX
Definition: intsafe.h:152
#define T
Definition: mbstring.h:31
static ATOM item
Definition: dde.c:856
Definition: features.h:417
iterator erase(iterator __pos)
Definition: _vector.h:623
void reserve(size_type __n)
Definition: _vector.c:62
size_type capacity() const
Definition: _vector.h:199
_Self & operator=(const _Self &__x)
Definition: _vector.c:182
reference operator[](size_type __n)
Definition: _vector.h:202
iterator insert(iterator __pos, const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.c:223
const value_type * const_iterator
Definition: _vector.h:125
size_type size() const
Definition: _vector.h:192
bool empty() const
Definition: _vector.h:200
void clear()
Definition: _vector.h:653