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);
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) {
bool operator==(const BCP_vec< T > &x, const BCP_vec< T > &y)
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.
bool operator<(BCP_vec< T > &x, BCP_vec< T > &y)
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.
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.
Abstract base class that defines members common to all types of variables.
The class BCP_vec serves the same purpose as the vector class in the standard template library.
const_iterator end() const
Return a const iterator to the end of the object.
void deallocate()
Destroy the entries in the vector and free the memory allocated for the vector.
void clear()
Delete every entry.
void unchecked_keep_by_index(const BCP_vec< int > &positions)
Same as the previous method but without the sanity checks.
bool empty() const
Test if there are any entries in the object.
void pop_back()
Delete the last entry.
const T & const_reference
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.
iterator end_of_storage
Iterator pointing to right after the last memory location usable by the vector without reallocation.
void append(const BCP_vec< T > &x)
Append the entries in x to the end of the vector.
void keep_by_index(const BCP_vec< int > &positions)
Keep the entries indexed by indices.
void unchecked_push_back(const_reference x)
Append x to the end of the vector.
void erase_by_index(const BCP_vec< int > &positions)
Erase the entries indexed by indices.
iterator end()
Return an iterator to the end of the object.
size_t size() const
Return the current number of entries.
void keep(iterator pos)
Keep only the entry pointed to by pos.
reference operator[](const size_t i)
Return a reference to the i-th entry.
const_iterator entry(const int i) const
Return a const iterator to the i-th entry.
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.
void keep_by_index(const int *firstpos, const int *lastpos)
Keep the entries indexed by the values in [firstpos,lastpos).
virtual ~BCP_vec()
The destructor deallocates the memory allocated for the BCP_vec.
void erase(iterator pos)
Erase the entry pointed to by pos.
size_t index(const_iterator pos) const
Return the index of the entry pointed to by pos.
iterator entry(const int i)
Return an iterator to the i-th entry.
reference back()
Return a reference to the last entry.
size_t capacity() const
Return the capacity of the object (space allocated for this many entries).
iterator start
Iterator pointing to the beginning of the memory array where the vector is stored.
void unchecked_keep_by_index(const int *firstpos, const int *lastpos)
Same as the previous method but without the sanity checks.
iterator finish
Iterator pointing to right after the last entry in the vector.
iterator begin()
Return an iterator to the beginning of the object.
reference front()
Return a reference to the first entry.
const_reference back() const
Return a const reference to the last entry.
void update(const BCP_vec< int > &positions, const BCP_vec< T > &values)
Update those entries listed in positions to the given values.
void unchecked_update(const BCP_vec< int > &positions, const BCP_vec< T > &values)
Same as the previous method but without sanity checks.
BCP_vec()
The default constructor initializes the data members as 0 pointers.
void reserve(const size_t n)
Reallocate the object to make space for n entries.
void append(const_iterator first, const_iterator last)
Append the entries [first,last) to the end of the vector.
void swap(BCP_vec< T > &x)
Exchange the contents of the object with that of x.
iterator allocate(size_t len)
allocate raw, uninitialized memory for len entries.
void unchecked_erase_by_index(const BCP_vec< int > &positions)
Same as the previous method but without the sanity check.
void erase_by_index(const int *firstpos, const int *lastpos)
Like the other erase_by_index method (including sanity checks), just the indices of the entries to be...
const_iterator begin() const
Return a const iterator to the beginning of the object.
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_erase_by_index(const int *firstpos, const int *lastpos)
Same as the previous method but without the sanity checks.
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 insert_aux(iterator position, const_reference x)
insert x into the given position in the vector.
const_reference front() const
Return a const reference to the first entry.