17using std::out_of_range;
21template <
typename T,
typename StringCompareT>
25 _current.first.clear();
31template <
typename T,
typename StringCompareT>
36 _current.first.clear();
42template <
typename T,
typename StringCompareT>
47 _index = inMappedVector._index;
48 _vector = inMappedVector._vector;
53template <
typename T,
typename StringCompareT>
62template <
typename T,
typename StringCompareT>
66 _vector.push_back(inT);
68 typename tIndex::value_type valuePair(inT, _vector.size() - 1);
70 _index.insert(valuePair);
73 _current.second = _vector.size() - 1;
78template <
typename T,
typename StringCompareT>
82 return(_vector.size());
87template <
typename T,
typename StringCompareT>
91 return(_vector.empty());
96template <
typename T,
typename StringCompareT>
101 _index = inMappedVector._index;
102 _vector = inMappedVector._vector;
107template <
typename T,
typename StringCompareT>
113 for (
unsigned int index = 0; index < inVector.size(); ++index)
115 push_back(inVector[index]);
121template <
typename T,
typename StringCompareT>
126 return(_vector == inMappedVector._vector);
131template <
typename T,
typename StringCompareT>
136 return(!
operator==(inMappedVector));
141template <
typename T,
typename StringCompareT>
147 throw out_of_range(
"Invalid index in mapped_vector::operator[]");
150 return(_vector[index]);
155template <
typename T,
typename StringCompareT>
164template <
typename T,
typename StringCompareT>
173template <
typename T,
typename StringCompareT>
177 unsigned int index = get_index(inT);
180 throw out_of_range(
"Element not found in mapped_vector::erase");
183 if (is_equal(_current.first, _vector[index]))
185 _current.first.clear();
189 _vector.erase(_vector.begin() + index);
193 for (
typename tIndex::iterator pos = _index.begin();
194 pos != _index.end(); ++pos)
196 if (pos->second >= index)
205template <
typename T,
typename StringCompareT>
210 unsigned int existingIndex = get_index(inT);
211 if (existingIndex != size())
213 throw out_of_range(
"Element exists in mapped_vector::insert");
216 _current.first = inT;
217 _current.second = index;
219 _vector.insert(_vector.begin() + index, inT);
221 for (
typename tIndex::iterator pos = _index.begin(); pos != _index.end();
224 if (pos->second >= index)
230 typename tIndex::value_type valuePair(inT, index);
232 _index.insert(valuePair);
237template <
typename T,
typename StringCompareT>
241 for (
unsigned int index = 0; index < _vector.size(); ++index)
243 typename tIndex::value_type valuePair(_vector[index], index);
245 _index.insert(valuePair);
251template <
typename T,
typename StringCompareT>
258 _current.first.clear();
264template <
typename T,
typename StringCompareT>
268 return(get_index(inT));
273template <
typename T,
typename StringCompareT>
277 if (is_equal(_current.first, inT))
279 return(_current.second);
283 typename tIndex::const_iterator pos = _index.
find(inT);
284 if (pos != _index.end())
287 _current.first = inT;
288 _current.second = pos->second;
295 return(_vector.size());
301template <
typename T,
typename StringCompareT>
303 const T& secondT)
const
306 typename tIndex::key_compare keyComp = _index.key_comp();
308 return(!(keyComp(firstT, secondT) || keyComp(secondT, firstT)));
Definition mapped_vector.h:22
const std::vector< T > & get_vector() const
Definition mapped_vector.C:156
void clear()
Definition mapped_vector.C:252
void index_it()
Definition mapped_vector.C:238
const T & operator[](unsigned int index) const
Definition mapped_vector.C:142
bool empty() const
Definition mapped_vector.C:88
unsigned int size() const
Definition mapped_vector.C:79
void erase(const T &inT)
Definition mapped_vector.C:174
void push_back(const T &inT)
Definition mapped_vector.C:63
void operator=(const mapped_vector &inMappedVector)
Definition mapped_vector.C:97
bool operator!=(const mapped_vector &inMappedVector)
Definition mapped_vector.C:132
mapped_vector()
Definition mapped_vector.C:22
~mapped_vector()
Definition mapped_vector.C:54
void insert(const unsigned int index, const T &inT)
Definition mapped_vector.C:206
bool operator==(const mapped_vector &inMappedVector)
Definition mapped_vector.C:122
unsigned int find(const T &inT) const
When not found, returns size()
Definition mapped_vector.C:265