3 #ifndef _BCP_VECTOR_GENERAL_H 4 #define _BCP_VECTOR_GENERAL_H 90 BCP_vec(
const T* x,
const size_t num);
153 void assign(
const void* x,
const size_t num);
156 void insert(
iterator position,
const void* first,
const size_t num);
217 inline void keep_by_index(
const int * firstpos,
const int * lastpos);
239 inline void erase_by_index(
const int * firstpos,
const int * lastpos);
256 return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
271 while (first != last) {
276 pvec.
erase(origfirst, last);
302 while (first != last) {
321 const int pvec_size = pvec.
size();
324 for (i = 0; i < pvec_size && first != last; ++i) {
333 for ( ; i < pvec_size; ++i) {
void append(const BCP_vec< T > &x)
Append the entries in x to the end of the vector.
void unchecked_keep_by_index(const BCP_vec< int > &positions)
Same as the previous method but without the sanity checks.
iterator finish
Iterator pointing to right after the last entry in the vector.
void unchecked_update(const BCP_vec< int > &positions, const BCP_vec< T > &values)
Same as the previous method but without sanity checks.
iterator entry(const int i)
Return an iterator to the i-th entry.
const_iterator begin() const
Return a const iterator to the beginning of the object.
void assign(const void *x, const size_t num)
Copy num entries of type T starting at the memory location x into the object.
void erase_by_index(const BCP_vec< int > &positions)
Erase the entries indexed by indices.
size_t index(const_iterator pos) const
Return the index of the entry pointed to by pos.
void pop_back()
Delete the last entry.
void erase(iterator pos)
Erase the entry pointed to by pos.
bool empty() const
Test if there are any entries in the object.
void keep(iterator pos)
Keep only the entry pointed to by pos.
void clear()
Delete every entry.
BCP_vec()
The default constructor initializes the data members as 0 pointers.
void push_back(const_reference x)
Append x to the end of the vector.
const_reference operator[](const size_t i) const
Return a const reference to the i-th entry.
void keep_by_index(const BCP_vec< int > &positions)
Keep the entries indexed by indices.
const T & const_reference
void swap(BCP_vec< T > &x)
Exchange the contents of the object with that of x.
const_reference back() const
Return a const reference to the last entry.
const_iterator end() const
Return a const iterator to the end of the object.
virtual ~BCP_vec()
The destructor deallocates the memory allocated for the BCP_vec.
reference back()
Return a reference to the last entry.
const_reference front() const
Return a const reference to the first entry.
void append(const_iterator first, const_iterator last)
Append the entries [first,last) to the end of the vector.
iterator start
Iterator pointing to the beginning of the memory array where the vector is stored.
void insert(iterator position, const void *first, const size_t num)
Insert num entries starting from memory location first into the vector from position pos...
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
void update(const BCP_vec< int > &positions, const BCP_vec< T > &values)
Update those entries listed in positions to the given values.
void reserve(const size_t n)
Reallocate the object to make space for n entries.
void keep_ptr_vector_by_index(BCP_vec< T *> &pvec, typename BCP_vec< int >::const_iterator first, typename BCP_vec< int >::const_iterator last)
This function keeps only the entries indexed by [first,last) from the vector of pointers pvec...
iterator end()
Return an iterator to the end of the object.
const_iterator entry(const int i) const
Return a const iterator to the i-th entry.
size_t capacity() const
Return the capacity of the object (space allocated for this many entries).
void deallocate()
Destroy the entries in the vector and free the memory allocated for the vector.
size_t size() const
Return the current number of entries.
iterator end_of_storage
Iterator pointing to right after the last memory location usable by the vector without reallocation...
The class BCP_vec serves the same purpose as the vector class in the standard template library...
void purge_ptr_vector(BCP_vec< T *> &pvec, typename BCP_vec< T *>::iterator first, typename BCP_vec< T *>::iterator last)
This function purges the entries [first,last) from the vector of pointers pvec.
reference front()
Return a reference to the first entry.
void insert_aux(iterator position, const_reference x)
insert x into the given position in the vector.
reference operator[](const size_t i)
Return a reference to the i-th entry.
iterator begin()
Return an iterator to the beginning of the object.
BCP_vec< T > & operator=(const BCP_vec< T > &x)
Copy the contents of x into the object and return a reference the the object itself.
bool operator==(const BCP_vec< T > &x, const BCP_vec< T > &y)
void purge_ptr_vector_by_index(BCP_vec< T *> &pvec, typename BCP_vec< int >::const_iterator first, typename BCP_vec< int >::const_iterator last)
This function purges the entries indexed by [first,last) from the vector of pointers pvec...
void unchecked_erase_by_index(const BCP_vec< int > &positions)
Same as the previous method but without the sanity check.
iterator allocate(size_t len)
allocate raw, uninitialized memory for len entries.