31 #ifndef SYS_VECTOR_HH_
32 #define SYS_VECTOR_HH_
64 iter(cont_par.storage.end()) {}
68 FullIterator(
const Cont &cont_par,
const typename Cont::iterator it)
76 if (it == NULL)
iter = cont_par.storage.end();
77 else iter = cont_par.storage.begin() +
cont.index(it);
82 {
return this->
iter != this->
cont.storage.end(); }
89 {
if (this->
iter != this->
cont.storage.end())
return this->
iter -
cont.storage.begin();
101 ASSERT( (&(this->
cont) == &(orig.
cont)),
"Can not change container of FulIter.\n");
107 inline operator typename Cont::Iter ()
const
108 {
return &(*(this->
iter)); }
112 {
return *(this->
iter); }
116 {
return &(*(this->
iter)); }
119 { this->
iter+=shift;
return (*
this); }
122 { this->
iter-=shift;
return (*
this); }
134 ASSERT(
iter !=
cont.storage.end(),
"Can not advance iterator at the end.\n");
135 ++(this->
iter);
return *
this;
149 ASSERT(
iter !=
cont.storage.begin(),
"Can not advance iterator to previous of begin().\n");
150 this->
iter--;
return *
this;
166 typename Cont :: iterator
iter;
190 {
return this->
cont.id_storage[ this->
index() ]; }
262 "Wrong pointer %d to obtain its index (%d, %d).\n",pointer, &(
storage.front()), &(
storage.back()));
263 return ( pointer - &(
storage.front()) );
275 inline unsigned int size()
const
286 ASSERT( idx < this->
size(),
"Index %d outside of Vector of size %d\n",idx, this->
size());
293 ASSERT( idx < this->
size(),
"Index %d outside of Vector of size %d\n",idx, this->
size());
301 ASSERT( idx < this->
size(),
"Index %d outside of Vector of size %d\n",idx, this->
size());
309 ASSERT( size >= this->
size(),
"Vector can not be reallocated into space %d smaller then its size %d\n",size,this->
size());
381 ASSERT(
id_map.find(
id) ==
id_map.end(),
"Can not add item with id number %d since it already exists.", id);
394 inline unsigned int index(
const T * pointer)
const
397 "Wrong pointer %p to obtain its index (%p, %p).\n",pointer, &(
storage.front()), &(
storage.back()));
398 return ( pointer - &(
storage.front()) );
412 inline unsigned int size()
const
418 ASSERT( idx < this->
size(),
"Index %d outside of Vector of size %d\n",idx, this->
size());
426 ASSERT( idx < this->
size(),
"Index %d outside of Vector of size %d\n",idx, this->
size());
434 ASSERT( idx < this->
size(),
"Index %d outside of Vector of size %d\n",idx, this->
size());
441 ASSERT( idx < this->
size(),
"Index %d outside of Vector of size %d\n",idx, this->
size());
458 if ( iter ==
id_map.end() ) {
470 if ( iter ==
id_map.end() ) {
471 return &(*(this->
storage.end()));
473 return &(*(this->
storage.begin() + iter->second));
492 ASSERT( size >= this->
size(),
"Vector can not be reallocated into space %d smaller then its size %d\n",size,this->
size());