14 const NoneType None = None;
16 template <
typename Object,
size_t N>
21 : theSize(initSize), theCapacity(N) {
22 assert(initSize <= N);
41 int capacity()
const {
45 Object & operator[](
int index) {
47 assert(index < theSize);
49 return objects[ index ];
52 const Object & operator[](
int index)
const {
54 assert(index < theSize);
56 return objects[ index ];
61 std::memset(&objects, 0, N);
63 theCapacity = rhs.theCapacity;
65 for (
int k = 0; k < size(); k++)
66 objects[ k ] = rhs.objects[ k ];
75 void push_back(
const Object & x) {
76 assert(theSize < (N));
77 objects[ theSize++ ] = x;
85 const Object & back()
const {
88 return objects[ theSize - 1 ];
92 typedef Object * iterator;
93 typedef const Object * const_iterator;
99 const_iterator begin()
const {
100 return &objects[ 0 ];
104 return &objects[ size() ];
107 const_iterator end()
const {
108 return &objects[ size() ];
112 std::memset(&objects, 0, N);
124 template <
typename T,
unsigned N = 5,
typename C = std::less<T> >
134 typedef size_t size_type;
143 const_iterator begin()
const {
151 const_iterator end()
const {
159 size_type size()
const {
164 size_type contains(
const T &V)
const {
166 return vfind(V) == data.end() ? 0 : 1;
169 std::pair<NoneType, bool> insert(
const T &V) {
171 const_iterator I = vfind(V);
173 return std::make_pair(None,
false);
174 if (data.size() < N) {
176 return std::make_pair(None,
true);
181 return std::make_pair(None,
true);
184 template <
typename IterT>
185 void insert(IterT I, IterT E) {
191 bool erase(
const T &V) {
193 for (iterator I = data.begin(), E = data.end(); I != E; ++I)
208 const_iterator vfind(
const T &V)
const {
209 for (const_iterator I = data.begin(), E = data.end(); I != E; ++I)
Definition: Combinations.hpp:17
Definition: small_set.hpp:125
Definition: small_set.hpp:17