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