Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

BCP_vec< T > Class Template Reference

#include <BCP_vector.hpp>

List of all members.

Public Types

Type definitions (needed for using the STL)
typedef size_t size_type
typedef T value_type
typedef T * iterator
typedef const T * const_iterator
typedef T & reference
typedef const T & const_reference

Public Member Functions

Constructors / Destructor
 BCP_vec ()
 BCP_vec (const BCP_vec< T > &x)
 BCP_vec (const size_t n, const_reference value=T())
 BCP_vec (const_iterator first, const_iterator last)
 BCP_vec (const T *x, const size_t num)
virtual ~BCP_vec ()
Query methods
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
iterator entry (const int i)
const_iterator entry (const int i) const
size_t index (const_iterator pos) const
size_t size () const
size_t capacity () const
bool empty () const
reference operator[] (const size_t i)
const_reference operator[] (const size_t i) const
reference front ()
const_reference front () const
reference back ()
const_reference back () const
General modifying methods
void reserve (const size_t n)
void swap (BCP_vec< T > &x)
BCP_vec< T > & operator= (const BCP_vec< T > &x)
void assign (const void *x, const size_t num)
void insert (iterator position, const void *first, const size_t num)
void insert (iterator position, const_iterator first, const_iterator last)
void insert (iterator position, const size_t n, const_reference x)
iterator insert (iterator position, const_reference x)
void append (const BCP_vec< T > &x)
void append (const_iterator first, const_iterator last)
void push_back (const_reference x)
void unchecked_push_back (const_reference x)
void pop_back ()
void clear ()
void update (const BCP_vec< int > &positions, const BCP_vec< T > &values)
void unchecked_update (const BCP_vec< int > &positions, const BCP_vec< T > &values)
Methods for selectively keeping entries
void keep (iterator pos)
void keep (iterator first, iterator last)
void keep_by_index (const BCP_vec< int > &positions)
void unchecked_keep_by_index (const BCP_vec< int > &positions)
void keep_by_index (const int *firstpos, const int *lastpos)
void unchecked_keep_by_index (const int *firstpos, const int *lastpos)
Methods for selectively erasing entries
void erase (iterator pos)
void erase (iterator first, iterator last)
void erase_by_index (const BCP_vec< int > &positions)
void unchecked_erase_by_index (const BCP_vec< int > &positions)
void erase_by_index (const int *firstpos, const int *lastpos)
void unchecked_erase_by_index (const int *firstpos, const int *lastpos)

Protected Member Functions

Internal methods
void insert_aux (iterator position, const_reference x)
iterator allocate (size_t len)
void deallocate ()

Protected Attributes

Data members
iterator start
iterator finish
iterator end_of_storage


Detailed Description

template<class T>
class BCP_vec< T >

The class BCP_vec serves the same purpose as the vector class in the standard template library. The main difference is that while the vector class is likely to be implemented as a memory array, BCP_vec is implemented that way. Also, BCP_vec has a number of extra member methods, most of them exist to speed up operations (e.g., there are unchecked versions of the insert member methods, i.e., the method does not check whether there is enough space allocated to fit the new elements).

Definition at line 23 of file BCP_vector.hpp.


Constructor & Destructor Documentation

template<class T>
BCP_vec< T >::BCP_vec  )  [inline]
 

The default constructor initializes the data members as 0 pointers.

Definition at line 73 of file BCP_vector.hpp.

00073 : start(0), finish(0), end_of_storage(0) {}

template<class T>
BCP_vec< T >::BCP_vec const BCP_vec< T > &  x  )  [inline]
 

The copy constructor copies over the content of x.

Definition at line 75 of file BCP_vector.hpp.

00075                                 : start(0), finish(0), end_of_storage(0) {
00076       operator=(x);
00077    }

BCP_vec<>::BCP_vec const size_t  n,
const_reference  value = T()
 

Construct a BCP_vec with n elements, all initialized with the second argument (or initialized with the default constructor of T if the second argument is missing).

Definition at line 45 of file BCP_vector_bool.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, and BCP_vec< T >::start.

00045                                                             :
00046    start(0), finish(0), end_of_storage(0)
00047 {
00048    if (n > 0) {
00049       start = finish = allocate(n);
00050       end_of_storage = start + n;
00051       while (finish != end_of_storage)
00052          *finish++ = value;
00053    }
00054 }

BCP_vec<>::BCP_vec const_iterator  first,
const_iterator  last
 

Construct a BCP_vec by copying the elements from first to last-1.

Definition at line 57 of file BCP_vector_bool.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, and BCP_vec< T >::start.

00057                                                                 :
00058    start(0), finish(0), end_of_storage(0)
00059 {
00060    const size_t len = last - first;
00061    if (len > 0) {
00062       start = allocate(len);
00063       memcpy(start, first, len * sizeof(bool));
00064       end_of_storage = finish = start + len;
00065    }
00066 }

template<class T>
BCP_vec< T >::BCP_vec const T *  x,
const size_t  num
 

Construct a BCP_vec by copying num objects of type T from the memory starting at x.

Definition at line 69 of file BCP_vector_general.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, and BCP_vec< T >::start.

00069                                                 :
00070    start(0), finish(0), end_of_storage(0)
00071 {
00072    if (num > 0) {
00073       finish = start = allocate(num);
00074       const T* const lastx = x + num;
00075       while (x != lastx)
00076          BCP_CONSTRUCT(finish++, *x++);
00077       end_of_storage = finish;
00078    }
00079 }

template<class T>
virtual BCP_vec< T >::~BCP_vec  )  [inline, virtual]
 

The destructor deallocates the memory allocated for the BCP_vec.

Definition at line 90 of file BCP_vector.hpp.

00090 { deallocate(); }


Member Function Documentation

template<class T>
iterator BCP_vec< T >::allocate size_t  len  )  [inline, protected]
 

allocate raw, uninitialized memory for len entries.

Definition at line 48 of file BCP_vector.hpp.

Referenced by BCP_vec< int >::assign(), BCP_vec< double >::assign(), BCP_vec< char >::assign(), BCP_vec< T >::assign(), BCP_vec< int >::BCP_vec(), BCP_vec< double >::BCP_vec(), BCP_vec< char >::BCP_vec(), BCP_vec< T >::BCP_vec(), BCP_vec< int >::insert(), BCP_vec< double >::insert(), BCP_vec< char >::insert(), BCP_vec< T >::insert(), BCP_vec< int >::insert_aux(), BCP_vec< double >::insert_aux(), BCP_vec< char >::insert_aux(), BCP_vec< T >::insert_aux(), BCP_vec< int >::operator=(), BCP_vec< T >::operator=(), BCP_vec< double >::operator=(), BCP_vec< char >::operator=(), BCP_vec< int >::reserve(), BCP_vec< double >::reserve(), BCP_vec< char >::reserve(), and BCP_vec< T >::reserve().

00048                                         {
00049       return static_cast<iterator>(::operator new(len * sizeof(T)));
00050    }

template<class T>
void BCP_vec< T >::append const_iterator  first,
const_iterator  last
[inline]
 

Append the entries [first,last) to the end of the vector.

Definition at line 170 of file BCP_vector.hpp.

00170                                                           {
00171       insert(end(), first, last); }

template<class T>
void BCP_vec< T >::append const BCP_vec< T > &  x  )  [inline]
 

Append the entries in x to the end of the vector.

Reimplemented in BCP_cut_set, and BCP_var_set.

Definition at line 166 of file BCP_vector.hpp.

Referenced by BCP_var_set::append(), and BCP_cut_set::append().

00166                                     {
00167       insert(end(), x.begin(), x.end()); }

void BCP_vec<>::assign const void *  x,
const size_t  num
 

Copy num entries of type T starting at the memory location x into the object. (x is a void pointer since it might be located somewhere in a buffer and therefore might not be aligned for type T entries.)

Definition at line 178 of file BCP_vector_bool.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::capacity(), BCP_vec< T >::deallocate(), BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, and BCP_vec< T >::start.

00178                                                     {
00179    if (num > capacity()){
00180       deallocate();
00181       start = allocate(num);
00182       end_of_storage = start + num;
00183    }
00184    memcpy(start, x, num * sizeof(bool));
00185    finish = start + num;
00186 }

template<class T>
const_reference BCP_vec< T >::back  )  const [inline]
 

Return a const reference to the last entry.

Definition at line 132 of file BCP_vector.hpp.

00132 { return *(finish - 1); }

template<class T>
reference BCP_vec< T >::back  )  [inline]
 

Return a reference to the last entry.

Definition at line 130 of file BCP_vector.hpp.

00130 { return *(finish - 1); }

template<class T>
const_iterator BCP_vec< T >::begin  )  const [inline]
 

Return a const iterator to the beginning of the object.

Definition at line 98 of file BCP_vector.hpp.

00098 { return start; }

template<class T>
iterator BCP_vec< T >::begin  )  [inline]
 

Return an iterator to the beginning of the object.

Definition at line 96 of file BCP_vector.hpp.

Referenced by BCP_vec< BCP_lp_result * >::append(), BCP_lp_user::append_branching_vars(), BCP_lp_relax::BCP_lp_relax(), BCP_lp_user::branch_close_to_half(), BCP_lp_user::branch_close_to_one(), BCP_lp_user::compare_branching_candidates(), BCP_warmstart_dual::convert_to_CoinWarmStart(), BCP_warmstart_basis::convert_to_CoinWarmStart(), BCP_vec< int >::erase_by_index(), BCP_vec< T >::erase_by_index(), BCP_vec< double >::erase_by_index(), BCP_vec< char >::erase_by_index(), BCP_lp_relax::erase_col_set(), BCP_lp_relax::erase_row_set(), BCP_vec< int >::keep_by_index(), BCP_vec< T >::keep_by_index(), BCP_vec< double >::keep_by_index(), BCP_vec< char >::keep_by_index(), BCP_cut_set::move_deletable_to_pool(), BCP_vec< T >::operator=(), BCP_buffer::pack(), BCP_lp_user::pack_dual_solution(), BCP_lp_user::pack_primal_solution(), BCP_lp_user::reduced_cost_fixing(), BCP_lp_user::select_branching_candidates(), BCP_var_set::set_lb_ub(), BCP_cut_set::set_lb_ub(), BCP_var_set::set_lb_ub_st(), BCP_cut_set::set_lb_ub_st(), BCP_vec< int >::unchecked_erase_by_index(), BCP_vec< T >::unchecked_erase_by_index(), BCP_vec< double >::unchecked_erase_by_index(), BCP_vec< char >::unchecked_erase_by_index(), BCP_vec< int >::unchecked_keep_by_index(), BCP_vec< T >::unchecked_keep_by_index(), BCP_vec< double >::unchecked_keep_by_index(), BCP_vec< char >::unchecked_keep_by_index(), BCP_vec< int >::unchecked_update(), BCP_vec< T >::unchecked_update(), BCP_vec< double >::unchecked_update(), BCP_vec< char >::unchecked_update(), BCP_vec< int >::update(), BCP_vec< T >::update(), BCP_vec< double >::update(), and BCP_vec< char >::update().

00096 { return start; }

template<class T>
size_t BCP_vec< T >::capacity  )  const [inline]
 

Return the capacity of the object (space allocated for this many entries).

Definition at line 116 of file BCP_vector.hpp.

Referenced by BCP_vec< int >::assign(), BCP_vec< double >::assign(), BCP_vec< char >::assign(), BCP_vec< T >::assign(), BCP_vec< int >::operator=(), BCP_vec< T >::operator=(), BCP_vec< double >::operator=(), BCP_vec< char >::operator=(), BCP_vec< int >::reserve(), BCP_vec< double >::reserve(), BCP_vec< char >::reserve(), and BCP_vec< T >::reserve().

00116 { return end_of_storage - start;}

template<class T>
void BCP_vec< T >::clear  )  [inline]
 

Delete every entry.

Definition at line 192 of file BCP_vector.hpp.

Referenced by BCP_lp_user::branch_close_to_half(), BCP_var_set::deletable(), BCP_presolved_lp_brobj::get_lower_bounds(), and BCP_buffer::unpack().

00192                 {
00193       if (start) erase(start, finish);
00194    }

void BCP_vec<>::deallocate  )  [protected]
 

Destroy the entries in the vector and free the memory allocated for the vector.

Definition at line 12 of file BCP_vector_bool.cpp.

References BCP_vec< T >::start.

Referenced by BCP_vec< int >::assign(), BCP_vec< double >::assign(), BCP_vec< char >::assign(), BCP_vec< T >::assign(), BCP_vec< int >::insert(), BCP_vec< double >::insert(), BCP_vec< char >::insert(), BCP_vec< T >::insert(), BCP_vec< int >::insert_aux(), BCP_vec< double >::insert_aux(), BCP_vec< char >::insert_aux(), BCP_vec< T >::insert_aux(), BCP_vec< int >::operator=(), BCP_vec< T >::operator=(), BCP_vec< double >::operator=(), BCP_vec< char >::operator=(), BCP_vec< int >::reserve(), BCP_vec< double >::reserve(), BCP_vec< char >::reserve(), BCP_vec< T >::reserve(), and BCP_vec< BCP_lp_result * >::~BCP_vec().

00012                           {
00013    if (start) {
00014       ::operator delete(start);
00015    }
00016 }

template<class T>
bool BCP_vec< T >::empty  )  const [inline]
 

Test if there are any entries in the object.

Definition at line 118 of file BCP_vector.hpp.

00118 { return start == finish; }

template<class T>
const_iterator BCP_vec< T >::end  )  const [inline]
 

Return a const iterator to the end of the object.

Definition at line 103 of file BCP_vector.hpp.

00103 { return finish; }

template<class T>
iterator BCP_vec< T >::end  )  [inline]
 

Return an iterator to the end of the object.

Definition at line 101 of file BCP_vector.hpp.

Referenced by BCP_vec< BCP_lp_result * >::append(), BCP_lp_user::append_branching_vars(), BCP_vec_change< char >::BCP_vec_change(), BCP_lp_user::branch_close_to_half(), BCP_lp_user::branch_close_to_one(), BCP_lp_user::compare_branching_candidates(), BCP_vec< int >::erase_by_index(), BCP_vec< T >::erase_by_index(), BCP_vec< double >::erase_by_index(), BCP_vec< char >::erase_by_index(), BCP_vec< int >::keep_by_index(), BCP_vec< T >::keep_by_index(), BCP_vec< double >::keep_by_index(), BCP_vec< char >::keep_by_index(), BCP_cut_set::move_deletable_to_pool(), BCP_vec< T >::operator=(), BCP_lp_user::pack_dual_solution(), BCP_lp_user::pack_primal_solution(), BCP_lp_user::reduced_cost_fixing(), BCP_lp_user::select_branching_candidates(), BCP_var_set::set_lb_ub(), BCP_cut_set::set_lb_ub(), BCP_var_set::set_lb_ub_st(), BCP_cut_set::set_lb_ub_st(), BCP_vec< int >::unchecked_erase_by_index(), BCP_vec< T >::unchecked_erase_by_index(), BCP_vec< double >::unchecked_erase_by_index(), BCP_vec< char >::unchecked_erase_by_index(), BCP_vec< int >::unchecked_keep_by_index(), BCP_vec< T >::unchecked_keep_by_index(), BCP_vec< double >::unchecked_keep_by_index(), BCP_vec< char >::unchecked_keep_by_index(), BCP_vec< int >::unchecked_update(), BCP_vec< T >::unchecked_update(), BCP_vec< double >::unchecked_update(), BCP_vec< char >::unchecked_update(), BCP_buffer::unpack(), BCP_vec< int >::update(), BCP_vec< T >::update(), BCP_vec< double >::update(), and BCP_vec< char >::update().

00101 { return finish; }

template<class T>
const_iterator BCP_vec< T >::entry const int  i  )  const [inline]
 

Return a const iterator to the i-th entry.

Definition at line 108 of file BCP_vector.hpp.

00108 { return start + i; }

template<class T>
iterator BCP_vec< T >::entry const int  i  )  [inline]
 

Return an iterator to the i-th entry.

Definition at line 106 of file BCP_vector.hpp.

Referenced by BCP_vec_change< char >::BCP_vec_change(), BCP_lp_user::branch_close_to_half(), BCP_lp_user::branch_close_to_one(), and BCP_vec< T >::operator=().

00106 { return start + i; }

void BCP_vec<>::erase iterator  first,
iterator  last
 

Erase the entries [first,last).

Definition at line 124 of file BCP_vector_bool.cpp.

References BCP_vec< T >::finish.

00124                                                   {
00125    if (first != last && last != finish)
00126       memmove(first, last, (finish - last) * sizeof(bool));
00127    finish -= (last - first);
00128 }

void BCP_vec<>::erase iterator  pos  ) 
 

Erase the entry pointed to by pos.

Definition at line 117 of file BCP_vector_bool.cpp.

References BCP_vec< T >::finish.

Referenced by BCP_lp_user::branch_close_to_half(), and BCP_vec< BCP_lp_result * >::clear().

00117                                       {
00118    if (position + 1 != finish)
00119       memmove(position, position + 1, ((finish-position) - 1) * sizeof(bool));
00120    --finish;
00121 }

template<class T>
void BCP_vec< T >::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 erased are given in [firstpos,lastpos).

void BCP_vec<>::erase_by_index const BCP_vec< int > &  positions  ) 
 

Erase the entries indexed by indices. Abort if the indices are not in increasing order, if there are duplicate indices or if any of the indices is outside of the range [0,size()).

Definition at line 328 of file BCP_vector_general.cpp.

References BCP_vec< T >::begin(), BCP_vec< T >::end(), BCP_vec< T >::size(), and BCP_vec< T >::unchecked_erase_by_index().

00328                                                        {
00329    BCP_vec_sanity_check(positions.begin(), positions.end(), size());
00330    unchecked_erase_by_index(positions.begin(), positions.end());
00331 }

template<class T>
const_reference BCP_vec< T >::front  )  const [inline]
 

Return a const reference to the first entry.

Definition at line 128 of file BCP_vector.hpp.

00128 { return *start; }

template<class T>
reference BCP_vec< T >::front  )  [inline]
 

Return a reference to the first entry.

Definition at line 126 of file BCP_vector.hpp.

00126 { return *start; }

template<class T>
size_t BCP_vec< T >::index const_iterator  pos  )  const [inline]
 

Return the index of the entry pointed to by pos.

Definition at line 111 of file BCP_vector.hpp.

Referenced by BCP_lp_user::branch_close_to_half(), BCP_lp_user::branch_close_to_one(), and BCP_lp_user::compare_branching_candidates().

00111 { return size_t(pos - start); }

BCP_vec< short >::iterator BCP_vec<>::insert iterator  position,
const_reference  x
 

Insert x (a single entry) into the vector at position pos. Return an iterator to the newly inserted entry.

Definition at line 268 of file BCP_vector_bool.cpp.

References BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, BCP_vec< T >::insert_aux(), and BCP_vec< T >::start.

00268                                                          {
00269    const size_t n = position - start;
00270    if (finish != end_of_storage && position == finish) {
00271       *finish++ = x;
00272    } else
00273       insert_aux(position, x);
00274    return start + n;
00275 }

void BCP_vec<>::insert iterator  position,
const size_t  n,
const_reference  x
 

Insert n copies of x into the vector from position pos.

Definition at line 241 of file BCP_vector_bool.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::deallocate(), BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, BCP_vec< T >::size(), and BCP_vec< T >::start.

00241                                                                           {
00242    if (n == 0) return;
00243    if ((size_t) (end_of_storage - finish) >= n) {
00244       memmove(position + n, position, (finish - position) * sizeof(bool));
00245       finish += n;
00246       for (int i = n; i > 0; --i)
00247          *position++ = x;
00248    } else {
00249       const size_t new_size = (2*size() + n) * sizeof(bool);
00250       iterator tmp = allocate(new_size);
00251       const size_t after_pos = finish - position;
00252       const size_t until_pos = position - start;
00253       memcpy(tmp, start, until_pos * sizeof(bool));
00254       memcpy(tmp + (until_pos + n), position, after_pos * sizeof(bool));
00255       deallocate();
00256       start = tmp;
00257       finish = start + (until_pos + n + after_pos);
00258       end_of_storage = tmp + new_size;
00259       position = tmp + until_pos;
00260       for (int i = n; i > 0; --i)
00261          *position++ = x;
00262    }
00263 }

void BCP_vec<>::insert iterator  position,
const_iterator  first,
const_iterator  last
 

Insert the entries [first,last) into the vector from position pos.

Definition at line 215 of file BCP_vector_bool.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::deallocate(), BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, BCP_vec< T >::size(), and BCP_vec< T >::start.

00216                                                                   {
00217    if (first == last) return;
00218    const size_t n = last - first;
00219    if ((size_t) (end_of_storage - finish) >= n) {
00220       memmove(position + n, position, (finish - position) * sizeof(bool));
00221       memcpy(position, first, n * sizeof(bool));
00222       finish += n;
00223    } else {
00224       const size_t new_size = (2*size() + n) * sizeof(bool);
00225       iterator tmp = allocate(new_size);
00226       const size_t after_pos = finish - position;
00227       const size_t until_pos = position - start;
00228       memcpy(tmp, start, until_pos * sizeof(bool));
00229       memcpy(tmp + until_pos, first, n * sizeof(bool));
00230       memcpy(tmp + (until_pos + n), position, after_pos * sizeof(bool));
00231       deallocate();
00232       start = tmp;
00233       finish = start + (until_pos + n + after_pos);
00234       end_of_storage = tmp + new_size;
00235    }
00236 }

template<class T>
void BCP_vec< T >::insert iterator  position,
const void *  first,
const size_t  num
 

Insert num entries starting from memory location first into the vector from position pos.

Definition at line 187 of file BCP_vector_general.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::deallocate(), BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, and BCP_vec< T >::size().

Referenced by BCP_vec< BCP_lp_result * >::append(), BCP_lp_user::branch_close_to_half(), BCP_lp_user::branch_close_to_one(), and BCP_buffer::unpack().

00187                                                                       {
00188    if (n == 0) return;
00189    T entry;
00190    const char* charx = static_cast<const char*>(first);
00191    if ((size_t) (end_of_storage - finish) >= n) {
00192       const size_t to_move = finish - position;
00193       if (to_move <= n) {
00194          std::uninitialized_copy(position, finish, position + n);
00195          finish += n;
00196          size_t i = n;
00197          for ( ; i > to_move; --i) {
00198             memcpy(&entry, charx, sizeof(T));
00199             BCP_CONSTRUCT(position++, entry);
00200             charx += sizeof(T);
00201          }
00202          for ( ; i > 0; --i) {
00203             memcpy(&entry, charx, sizeof(T));
00204             *position++ = entry; 
00205             charx += sizeof(T);
00206          }
00207       } else {
00208          std::uninitialized_copy(finish - n, finish, finish);
00209          std::copy_backward(position, finish - n, finish);
00210          finish += n;
00211          for (int i = n; i > 0; --i) {
00212             memcpy(&entry, charx, sizeof(T));
00213             *position++ = entry; 
00214             charx += sizeof(T);
00215          }
00216       }
00217    } else {
00218       const size_t new_size = (2*size() + n) * sizeof(T);
00219       iterator tmp = allocate(new_size);
00220       iterator tmp_finish = std::uninitialized_copy(start, position, tmp);
00221       for (int i = n; i > 0; --i) {
00222          memcpy(&entry, charx, sizeof(T));
00223          BCP_CONSTRUCT(tmp_finish++, entry);
00224          charx += sizeof(T);
00225       }
00226       tmp_finish = std::uninitialized_copy(position, finish, tmp_finish);
00227       deallocate();
00228       start = tmp;
00229       finish = tmp_finish;
00230       end_of_storage = tmp + new_size;
00231    }
00232 }

void BCP_vec<>::insert_aux iterator  position,
const_reference  x
[protected]
 

insert x into the given position in the vector. Reallocate the vector if necessary.

Definition at line 21 of file BCP_vector_bool.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::deallocate(), BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, BCP_vec< T >::size(), and BCP_vec< T >::start.

Referenced by BCP_vec< int >::insert(), BCP_vec< double >::insert(), BCP_vec< char >::insert(), BCP_vec< T >::insert(), and BCP_vec< BCP_lp_result * >::push_back().

00021                                                              {
00022    const size_t after_pos = finish - position;
00023    if (finish != end_of_storage) {
00024       memmove(position+1, position, after_pos * sizeof(bool));
00025       *position = x;
00026       ++finish;
00027    } else {
00028       const size_t len = (2*size() + 0x1000) * sizeof(bool);
00029       iterator tmp = allocate(len);
00030       const size_t until_pos = position - start;
00031       memmove(tmp, start, until_pos * sizeof(bool));
00032       iterator tmp_finish = tmp + until_pos;
00033       *tmp_finish++ = x;
00034       memmove(tmp_finish, position, after_pos * sizeof(bool));
00035       deallocate();
00036       start = tmp;
00037       finish = start + (until_pos + 1 + after_pos);
00038       end_of_storage = tmp + len;
00039    }
00040 }

void BCP_vec<>::keep iterator  first,
iterator  last
 

Keep the entries [first,last).

Definition at line 108 of file BCP_vector_bool.cpp.

References BCP_vec< T >::finish, and BCP_vec< T >::start.

00108                                                  {
00109    const size_t len = last - first;
00110    memmove(start, first, len * sizeof(bool));
00111    finish = start + len;
00112 }

void BCP_vec<>::keep iterator  pos  ) 
 

Keep only the entry pointed to by pos.

Definition at line 102 of file BCP_vector_bool.cpp.

References BCP_vec< T >::finish, and BCP_vec< T >::start.

00102                                 {
00103    *start = *pos;
00104    finish = start + 1;
00105 }

template<class T>
void BCP_vec< T >::keep_by_index const int *  firstpos,
const int *  lastpos
 

Like the other keep_by_index method (including sanity checks), just the indices of the entries to be kept are given in [firstpos,lastpos).

void BCP_vec<>::keep_by_index const BCP_vec< int > &  positions  ) 
 

Keep the entries indexed by indices. Abort if the indices are not in increasing order, if there are duplicate indices or if any of the indices is outside of the range [0,size()).

Definition at line 314 of file BCP_vector_general.cpp.

References BCP_vec< T >::begin(), BCP_vec< T >::end(), BCP_vec< T >::size(), and BCP_vec< T >::unchecked_keep_by_index().

00314                                                       {
00315    BCP_vec_sanity_check(positions.begin(), positions.end(), size());
00316    unchecked_keep_by_index(positions.begin(), positions.end());
00317 }

template<class T>
BCP_vec< T > & 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.

Definition at line 140 of file BCP_vector_general.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::begin(), BCP_vec< T >::capacity(), BCP_vec< T >::deallocate(), BCP_vec< T >::end(), BCP_vec< T >::end_of_storage, BCP_vec< T >::entry(), BCP_vec< T >::finish, BCP_vec< T >::size(), and BCP_vec< T >::start.

Referenced by BCP_vec< BCP_lp_result * >::BCP_vec().

00140                                         {
00141    if (&x != this) {
00142       const size_t x_size = x.size();
00143       if (x_size > capacity()) {
00144          deallocate();
00145          start = allocate(x_size);
00146          end_of_storage = start + x_size;
00147          finish = std::uninitialized_copy(x.begin(), x.end(), start);
00148       } else {
00149          if (x_size < size()) {
00150             iterator oldfinish = finish;
00151             finish = std::copy(x.begin(), x.end(), start);
00152             BCP_DESTROY_RANGE(finish, oldfinish);
00153          } else {
00154             std::copy(x.begin(), x.entry(size()), start);
00155             finish = std::uninitialized_copy(x.entry(size()), x.end(), finish);
00156          }
00157       }
00158    }
00159    return *this;
00160 }

template<class T>
const_reference BCP_vec< T >::operator[] const size_t  i  )  const [inline]
 

Return a const reference to the i-th entry.

Definition at line 123 of file BCP_vector.hpp.

00123 { return *(start + i); }

template<class T>
reference BCP_vec< T >::operator[] const size_t  i  )  [inline]
 

Return a reference to the i-th entry.

Definition at line 121 of file BCP_vector.hpp.

Referenced by BCP_vec< int >::unchecked_update(), BCP_vec< T >::unchecked_update(), BCP_vec< double >::unchecked_update(), and BCP_vec< char >::unchecked_update().

00121 { return *(start + i); }

void BCP_vec<>::pop_back  )  [inline]
 

Delete the last entry.

Definition at line 187 of file BCP_vector.hpp.

Referenced by BCP_lp_user::branch_close_to_half(), and BCP_lp_user::branch_close_to_one().

00187                           {
00188       BCP_DESTROY(--finish);
00189    }

void BCP_vec<>::push_back const_reference  x  )  [inline]
 

Append x to the end of the vector. Check if enough space is allocated (reallocate if necessary).

Definition at line 175 of file BCP_vector.hpp.

Referenced by BCP_lp_user::append_branching_vars().

00175                                             {
00176       if (finish != end_of_storage) {
00177          BCP_CONSTRUCT(finish++, x);
00178       } else
00179          insert_aux(finish, x);
00180    }

void BCP_vec<>::reserve const size_t  n  ) 
 

Reallocate the object to make space for n entries.

Definition at line 134 of file BCP_vector_bool.cpp.

References BCP_vec< T >::allocate(), BCP_vec< T >::capacity(), BCP_vec< T >::deallocate(), BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, BCP_vec< T >::size(), and BCP_vec< T >::start.

Referenced by BCP_lp_user::branch_close_to_half(), BCP_lp_user::branch_close_to_one(), BCP_var_set::deletable(), BCP_presolved_lp_brobj::get_lower_bounds(), BCP_problem_core_change::make_wrtcore_if_shorter(), BCP_cut_set::move_deletable_to_pool(), BCP_lp_user::pack_dual_solution(), BCP_lp_user::pack_primal_solution(), BCP_lp_user::purge_slack_pool(), BCP_lp_user::reduced_cost_fixing(), BCP_lp_user::select_branching_candidates(), BCP_lp_user::select_fractions(), BCP_lp_user::select_nonzeros(), BCP_lp_user::select_positives(), BCP_lp_user::select_zeros(), and BCP_buffer::unpack().

00134                                     {
00135    if (capacity() < n) {
00136       iterator tmp = allocate(n);
00137       const size_t oldsize = size();
00138       if (oldsize > 0)
00139          memcpy(tmp, start, oldsize * sizeof(bool));
00140       deallocate();
00141       start = tmp;
00142       finish = start + oldsize;
00143       end_of_storage = start + n;
00144    }
00145 }

template<class T>
size_t BCP_vec< T >::size  )  const [inline]
 

Return the current number of entries.

Definition at line 113 of file BCP_vector.hpp.

Referenced by BCP_lp_branching_object::BCP_lp_branching_object(), BCP_lp_relax::BCP_lp_relax(), BCP_vec_change< char >::BCP_vec_change(), BCP_lp_user::branch_close_to_half(), BCP_lp_user::branch_close_to_one(), BCP_warmstart_dual::convert_to_CoinWarmStart(), BCP_warmstart_basis::convert_to_CoinWarmStart(), BCP_lp_user::display_lp_solution(), BCP_vec< int >::erase_by_index(), BCP_vec< T >::erase_by_index(), BCP_vec< double >::erase_by_index(), BCP_vec< char >::erase_by_index(), BCP_lp_relax::erase_col_set(), BCP_lp_relax::erase_row_set(), BCP_vec< int >::insert(), BCP_vec< double >::insert(), BCP_vec< char >::insert(), BCP_vec< T >::insert(), BCP_vec< int >::insert_aux(), BCP_vec< double >::insert_aux(), BCP_vec< char >::insert_aux(), BCP_vec< T >::insert_aux(), BCP_vec< int >::keep_by_index(), BCP_vec< T >::keep_by_index(), BCP_vec< double >::keep_by_index(), BCP_vec< char >::keep_by_index(), BCP_problem_core_change::make_wrtcore_if_shorter(), BCP_cut_set::move_deletable_to_pool(), BCP_vec< int >::operator=(), BCP_vec< T >::operator=(), BCP_vec< double >::operator=(), BCP_vec< char >::operator=(), BCP_buffer::pack(), BCP_lp_user::pack_dual_solution(), BCP_lp_user::pack_feasible_solution(), BCP_lp_user::pack_primal_solution(), BCP_lp_user::purge_slack_pool(), BCP_lp_user::reduced_cost_fixing(), BCP_vec< int >::reserve(), BCP_vec< double >::reserve(), BCP_vec< char >::reserve(), BCP_vec< T >::reserve(), BCP_lp_user::select_branching_candidates(), BCP_lp_user::test_binary(), BCP_lp_user::test_full(), BCP_lp_user::test_integral(), BCP_vec< int >::unchecked_update(), BCP_vec< T >::unchecked_update(), BCP_vec< double >::unchecked_update(), BCP_vec< char >::unchecked_update(), BCP_vec< int >::update(), BCP_vec< T >::update(), BCP_vec< double >::update(), and BCP_vec< char >::update().

00113 { return finish - start; }

template<class T>
void BCP_vec< T >::swap BCP_vec< T > &  x  ) 
 

Exchange the contents of the object with that of x.

Definition at line 131 of file BCP_vector_general.cpp.

References BCP_vec< T >::end_of_storage, BCP_vec< T >::finish, and BCP_vec< T >::start.

Referenced by BCP_lp_user::branch_close_to_half().

00131                               {
00132    std::swap(start, x.start);
00133    std::swap(finish, x.finish);
00134    std::swap(end_of_storage, x.end_of_storage);
00135 }

template<class T>
void BCP_vec< T >::unchecked_erase_by_index const int *  firstpos,
const int *  lastpos
 

Same as the previous method but without the sanity checks.

void BCP_vec<>::unchecked_erase_by_index const BCP_vec< int > &  positions  ) 
 

Same as the previous method but without the sanity check.

Definition at line 336 of file BCP_vector_general.cpp.

References BCP_vec< T >::begin(), and BCP_vec< T >::end().

Referenced by BCP_vec< int >::erase_by_index(), BCP_vec< T >::erase_by_index(), BCP_vec< double >::erase_by_index(), BCP_vec< char >::erase_by_index(), BCP_vec< int >::unchecked_erase_by_index(), BCP_vec< double >::unchecked_erase_by_index(), and BCP_vec< char >::unchecked_erase_by_index().

00336                                                                  {
00337    unchecked_erase_by_index(positions.begin(), positions.end());
00338 }

template<class T>
void BCP_vec< T >::unchecked_keep_by_index const int *  firstpos,
const int *  lastpos
 

Same as the previous method but without the sanity checks.

void BCP_vec<>::unchecked_keep_by_index const BCP_vec< int > &  positions  ) 
 

Same as the previous method but without the sanity checks.

Definition at line 321 of file BCP_vector_general.cpp.

References BCP_vec< T >::begin(), and BCP_vec< T >::end().

Referenced by BCP_vec< int >::keep_by_index(), BCP_vec< T >::keep_by_index(), BCP_vec< double >::keep_by_index(), BCP_vec< char >::keep_by_index(), BCP_vec< int >::unchecked_keep_by_index(), BCP_vec< double >::unchecked_keep_by_index(), and BCP_vec< char >::unchecked_keep_by_index().

00321                                                                 {
00322    unchecked_keep_by_index(positions.begin(), positions.end());
00323 }

void BCP_vec<>::unchecked_push_back const_reference  x  )  [inline]
 

Append x to the end of the vector. Does not check if enough space is allcoated.

Definition at line 183 of file BCP_vector.hpp.

Referenced by BCP_var_set::deletable(), BCP_presolved_lp_brobj::get_lower_bounds(), BCP_problem_core_change::make_wrtcore_if_shorter(), BCP_cut_set::move_deletable_to_pool(), BCP_lp_user::pack_dual_solution(), BCP_lp_user::pack_primal_solution(), BCP_lp_user::purge_slack_pool(), BCP_lp_user::reduced_cost_fixing(), BCP_lp_user::select_branching_candidates(), BCP_lp_user::select_fractions(), BCP_lp_user::select_nonzeros(), BCP_lp_user::select_positives(), and BCP_lp_user::select_zeros().

00183                                                       {
00184       BCP_CONSTRUCT(finish++, x);
00185    }

template<class T>
void BCP_vec< T >::unchecked_update const BCP_vec< int > &  positions,
const BCP_vec< T > &  values
 

Same as the previous method but without sanity checks.

Definition at line 409 of file BCP_vector_general.cpp.

References BCP_vec< T >::begin(), BCP_vec< T >::end(), BCP_vec< T >::operator[](), and BCP_vec< T >::size().

Referenced by BCP_vec< int >::update(), BCP_vec< T >::update(), BCP_vec< double >::update(), and BCP_vec< char >::update().

00410                                                       {
00411    if (positions.size() == 0)
00412       return;
00413    const_iterator val = values.begin();
00414    BCP_vec<int>::const_iterator pos = positions.begin();
00415    const BCP_vec<int>::const_iterator lastpos = positions.end();
00416    while (pos != lastpos)
00417       operator[](*pos++) = *val++;
00418 }

template<class T>
void BCP_vec< T >::update const BCP_vec< int > &  positions,
const BCP_vec< T > &  values
 

Update those entries listed in positions to the given values. The two argument vector must be of equal length. Sanity checks are done on the given positions.

Definition at line 398 of file BCP_vector_general.cpp.

References BCP_vec< T >::begin(), BCP_vec< T >::end(), BCP_vec< T >::size(), and BCP_vec< T >::unchecked_update().

00399                                             {
00400    if (positions.size() != values.size())
00401       throw BCP_fatal_error("BCP_vec::update() called with unequal sizes.\n");
00402    BCP_vec_sanity_check(positions.begin(), positions.end(), size());
00403    unchecked_update(positions, values);
00404 }


Member Data Documentation

template<class T>
iterator BCP_vec< T >::end_of_storage [protected]
 

Iterator pointing to right after the last memory location usable by the vector without reallocation.

Definition at line 66 of file BCP_vector.hpp.

Referenced by BCP_vec< T >::assign(), BCP_vec< T >::BCP_vec(), BCP_vec< T >::insert(), BCP_vec< T >::insert_aux(), BCP_vec< T >::operator=(), BCP_vec< T >::reserve(), BCP_vec< int >::swap(), BCP_vec< T >::swap(), BCP_vec< double >::swap(), and BCP_vec< char >::swap().

template<class T>
iterator BCP_vec< T >::finish [protected]
 

Iterator pointing to right after the last entry in the vector.

Definition at line 63 of file BCP_vector.hpp.

Referenced by BCP_vec< T >::assign(), BCP_vec< T >::BCP_vec(), BCP_vec< T >::erase(), BCP_vec< T >::insert(), BCP_vec< T >::insert_aux(), BCP_vec< T >::keep(), BCP_vec< T >::operator=(), BCP_vec< T >::reserve(), BCP_vec< int >::swap(), BCP_vec< T >::swap(), BCP_vec< double >::swap(), and BCP_vec< char >::swap().

template<class T>
iterator BCP_vec< T >::start [protected]
 

Iterator pointing to the beginning of the memory array where the vector is stored.

Definition at line 61 of file BCP_vector.hpp.

Referenced by BCP_vec< T >::assign(), BCP_vec< T >::BCP_vec(), BCP_vec< T >::deallocate(), BCP_vec< T >::insert(), BCP_vec< T >::insert_aux(), BCP_vec< T >::keep(), BCP_vec< int >::operator=(), BCP_vec< T >::operator=(), BCP_vec< double >::operator=(), BCP_vec< char >::operator=(), BCP_vec< T >::reserve(), BCP_vec< int >::swap(), BCP_vec< T >::swap(), BCP_vec< double >::swap(), and BCP_vec< char >::swap().


The documentation for this class was generated from the following files:
Generated on Wed Dec 3 14:32:43 2003 for BCP by doxygen 1.3.5