/home/coin/SVN-release/Bcp-1.2.1/Bcp/src/include/BCP_vector_bool.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 #include <cstring>
00005 
00006 //##############################################################################
00007 
00008 /* The methods that are commented out are sort of generic methods that do not
00009    need specialization. Their implementation is in BCP_vector_general.hpp */
00010 
00011 //##############################################################################
00012 
00013 // to get memmove
00014 #include <cstring>
00015 
00016 template<> inline void BCP_vec<bool>::destroy(iterator pos)
00017 {
00018 }
00019 //------------------------------------------------------------------------------
00020 template<> inline void BCP_vec<bool>::destroy_range(iterator first, iterator last)
00021 {
00022 }
00023 //------------------------------------------------------------------------------
00024 template<> inline void BCP_vec<bool>::construct(iterator pos)
00025 {
00026         *pos = 0;
00027 }
00028 //------------------------------------------------------------------------------
00029 template<> inline void BCP_vec<bool>::construct(iterator pos, const_reference x)
00030 {
00031         *pos = x;
00032 }
00033 
00034 //##############################################################################
00035 
00036 // template<> inline void BCP_vec<bool>::allocate(size_t len)
00037 //------------------------------------------------------------------------------
00038 template<> inline void BCP_vec<bool>::deallocate() {
00039         if (start) {
00040                 ::operator delete(start);
00041         }
00042 }
00043 //------------------------------------------------------------------------------
00044 template<> void BCP_vec<bool>::insert_aux(iterator position, const_reference x);
00045 
00046 //##############################################################################
00047 
00048 // template<> void BCP_vec<bool>::BCP_vec();
00049 //------------------------------------------------------------------------------
00050 // template<> void BCP_vec<bool>::BCP_vec(const BCP_vec<bool>& x);
00051 //------------------------------------------------------------------------------
00052 template<> BCP_vec<bool>::BCP_vec(const size_t n, const_reference value);
00053 //------------------------------------------------------------------------------
00054 template<> BCP_vec<bool>::BCP_vec(const_iterator first, const_iterator last);
00055 //------------------------------------------------------------------------------
00056 template<> BCP_vec<bool>::BCP_vec(const bool* x, const size_t num);
00057 
00058 //##############################################################################
00059 
00060 template<> void BCP_vec<bool>::reserve(const size_t n);
00061 //------------------------------------------------------------------------------
00062 // template<> inline void BCP_vec<bool>::swap(BCP_vec<bool>& x);
00063 //------------------------------------------------------------------------------
00064 template<> BCP_vec<bool>& BCP_vec<bool>::operator=(const BCP_vec<bool>& x);
00065 
00066 //##############################################################################
00067 // these two members serve to copy out entries from a buffer.
00068 
00069 template<> void BCP_vec<bool>::assign(const void* x, const size_t num);
00070 //------------------------------------------------------------------------------
00071 template<> void BCP_vec<bool>::insert(bool* position,
00072                                                                           const void* first, const size_t n);
00073 //------------------------------------------------------------------------------
00074 template<> void BCP_vec<bool>::insert(iterator position,
00075                                                                           const_iterator first,
00076                                                                           const_iterator last);
00077 //------------------------------------------------------------------------------
00078 template<> void BCP_vec<bool>::insert(iterator position, const size_t n,
00079                                                                           const_reference x);
00080 //------------------------------------------------------------------------------
00081 template<> inline BCP_vec<bool>::iterator
00082 BCP_vec<bool>::insert(iterator position, const_reference x)
00083 {
00084         const size_t n = position - start;
00085         if (finish != end_of_storage && position == finish) {
00086                 *finish++ = x;
00087         } else
00088                 insert_aux(position, x);
00089         return start + n;
00090 }
00091 
00092 //##############################################################################
00093 
00094 template<> inline void BCP_vec<bool>::push_back(const_reference x)
00095 {
00096         if (finish != end_of_storage)
00097                 *finish++ = x;
00098         else
00099                 insert_aux(finish, x);
00100 }
00101 //------------------------------------------------------------------------------
00102 template<> inline void BCP_vec<bool>::unchecked_push_back(const_reference x)
00103 {
00104         *finish++ = x;
00105 }
00106 //------------------------------------------------------------------------------
00107 template<> inline void BCP_vec<bool>::pop_back()
00108 {
00109         --finish;
00110 }
00111 //------------------------------------------------------------------------------
00112 // template<> inline void BCP_vec<bool>::clear();
00113 //------------------------------------------------------------------------------
00114 template<> inline void
00115 BCP_vec<bool>::unchecked_update(const BCP_vec<int>& positions,
00116                                                                 const BCP_vec<bool>& values)
00117 {
00118         if (positions.size() == 0)
00119                 return;
00120         const_iterator val = values.begin();
00121         BCP_vec<int>::const_iterator pos = positions.begin();
00122         const BCP_vec<int>::const_iterator lastpos = positions.end();
00123         while (pos != lastpos)
00124                 operator[](*pos++) = *val++;
00125 }
00126 
00127 //------------------------------------------------------------------------------
00128 template<> inline void BCP_vec<bool>::update(const BCP_vec<int>& positions,
00129                                                                                          const BCP_vec<bool>& values)
00130 {
00131         if (positions.size() != values.size())
00132                 throw BCP_fatal_error("BCP_vec::update() called with unequal sizes.\n");
00133         BCP_vec_sanity_check(positions.begin(), positions.end(), size());
00134         unchecked_update(positions, values);
00135 }
00136 
00137 //##############################################################################
00138 
00139 template<> inline void BCP_vec<bool>::keep(iterator pos)
00140 {
00141         *start = *pos;
00142         finish = start + 1;
00143 }
00144 //------------------------------------------------------------------------------
00145 template<> inline void BCP_vec<bool>::keep(iterator first, iterator last)
00146 {
00147         const size_t len = last - first;
00148         std::memmove(start, first, len * sizeof(bool));
00149         finish = start + len;
00150 }
00151 //------------------------------------------------------------------------------
00152 // template<> inline void
00153 // BCP_vec<bool>::unchecked_keep_by_index(BCP_vec<int>::const_iterator firstpos,
00154 //                                                                         BCP_vec<int>::const_iterator lastpos);
00155 //------------------------------------------------------------------------------
00156 // template<> inline void
00157 // BCP_vec<bool>::keep_by_index(BCP_vec<int>::const_iterator firstpos,
00158 //                                                BCP_vec<int>::const_iterator lastpos);
00159 //------------------------------------------------------------------------------
00160 // template<> inline void
00161 // BCP_vec<bool>::keep_by_index(const BCP_vec<int>& positions);
00162 //------------------------------------------------------------------------------
00163 // template<> inline void
00164 // BCP_vec<bool>::unchecked_keep_by_index(const BCP_vec<int>& positions);
00165 
00166 //##############################################################################
00167 
00168 template<> inline void BCP_vec<bool>::erase(iterator position)
00169 {
00170         if (position + 1 != finish)
00171                 std::memmove(position, position + 1, ((finish-position) - 1) * sizeof(bool));
00172         --finish;
00173 }
00174 //------------------------------------------------------------------------------
00175 template<> inline void BCP_vec<bool>::erase(iterator first, iterator last)
00176 {
00177         if (first != last && last != finish)
00178                 std::memmove(first, last, (finish - last) * sizeof(bool));
00179         finish -= (last - first);
00180 }
00181 //------------------------------------------------------------------------------
00182 // template <class T> inline void
00183 // BCP_vec<T>::erase_by_index(const BCP_vec<int>& positions);
00184 //------------------------------------------------------------------------------
00185 // template <class T> inline void
00186 // BCP_vec<T>::unchecked_erase_by_index(const BCP_vec<int>& positions);
00187 //------------------------------------------------------------------------------
00188 // template <class T> inline void
00189 // BCP_vec<T>::erase_by_index(BCP_vec<int>::const_iterator firstpos,
00190 //                                                 BCP_vec<int>::const_iterator lastpos);
00191 //------------------------------------------------------------------------------
00192 // template <class T> void
00193 // BCP_vec<T>::unchecked_erase_by_index(BCP_vec<int>::const_iterator firstpos,
00194 //                                                                       BCP_vec<int>::const_iterator lastpos);
00195 
00196 //#############################################################################
00197 

Generated on Thu Jan 15 03:00:59 2009 for coin-Bcp by  doxygen 1.4.7