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<short>::destroy(iterator pos) 00012 { 00013 } 00014 //------------------------------------------------------------------------------ 00015 template<> inline void BCP_vec<short>::destroy_range(iterator first, iterator last) 00016 { 00017 } 00018 //------------------------------------------------------------------------------ 00019 template<> inline void BCP_vec<short>::construct(iterator pos) 00020 { 00021 *pos = 0; 00022 } 00023 //------------------------------------------------------------------------------ 00024 template<> inline void BCP_vec<short>::construct(iterator pos, const_reference x) 00025 { 00026 *pos = x; 00027 } 00028 00029 //############################################################################## 00030 00031 // template<> inline void BCP_vec<short>::allocate(size_t len) 00032 //------------------------------------------------------------------------------ 00033 template<> inline void BCP_vec<short>::deallocate() { 00034 if (start) { 00035 ::operator delete(start); 00036 } 00037 } 00038 //------------------------------------------------------------------------------ 00039 template<> void BCP_vec<short>::insert_aux(iterator position, const_reference x); 00040 00041 //############################################################################## 00042 00043 // template<> void BCP_vec<short>::BCP_vec(); 00044 //------------------------------------------------------------------------------ 00045 // template<> void BCP_vec<short>::BCP_vec(const BCP_vec<short>& x); 00046 //------------------------------------------------------------------------------ 00047 template<> BCP_vec<short>::BCP_vec(const size_t n, const_reference value); 00048 //------------------------------------------------------------------------------ 00049 template<> BCP_vec<short>::BCP_vec(const_iterator first, const_iterator last); 00050 //------------------------------------------------------------------------------ 00051 template<> BCP_vec<short>::BCP_vec(const short* x, const size_t num); 00052 00053 //############################################################################## 00054 00055 template<> void BCP_vec<short>::reserve(const size_t n); 00056 //------------------------------------------------------------------------------ 00057 // template<> inline void BCP_vec<short>::swap(BCP_vec<short>& x); 00058 //------------------------------------------------------------------------------ 00059 template<> BCP_vec<short>& BCP_vec<short>::operator=(const BCP_vec<short>& x); 00060 00061 //############################################################################## 00062 // these two members serve to copy out entries from a buffer. 00063 00064 template<> void BCP_vec<short>::assign(const void* x, const size_t num); 00065 //------------------------------------------------------------------------------ 00066 template<> void BCP_vec<short>::insert(short* position, 00067 const void* first, const size_t n); 00068 //------------------------------------------------------------------------------ 00069 template<> void BCP_vec<short>::insert(iterator position, 00070 const_iterator first, 00071 const_iterator last); 00072 //------------------------------------------------------------------------------ 00073 template<> void BCP_vec<short>::insert(iterator position, const size_t n, 00074 const_reference x); 00075 //------------------------------------------------------------------------------ 00076 template<> inline BCP_vec<short>::iterator 00077 BCP_vec<short>::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<short>::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<short>::unchecked_push_back(const_reference x) 00098 { 00099 *finish++ = x; 00100 } 00101 //------------------------------------------------------------------------------ 00102 template<> inline void BCP_vec<short>::pop_back() 00103 { 00104 --finish; 00105 } 00106 //------------------------------------------------------------------------------ 00107 // template<> inline void BCP_vec<short>::clear(); 00108 //------------------------------------------------------------------------------ 00109 template<> inline void 00110 BCP_vec<short>::unchecked_update(const BCP_vec<int>& positions, 00111 const BCP_vec<short>& 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 template<> inline void BCP_vec<short>::update(const BCP_vec<int>& positions, 00123 const BCP_vec<short>& values) 00124 { 00125 if (positions.size() != values.size()) 00126 throw BCP_fatal_error("BCP_vec::update() called with unequal sizes.\n"); 00127 BCP_vec_sanity_check(positions.begin(), positions.end(), size()); 00128 unchecked_update(positions, values); 00129 } 00130 00131 //############################################################################## 00132 00133 template<> inline void BCP_vec<short>::keep(iterator pos) 00134 { 00135 *start = *pos; 00136 finish = start + 1; 00137 } 00138 //------------------------------------------------------------------------------ 00139 template<> inline void BCP_vec<short>::keep(iterator first, iterator last) 00140 { 00141 const size_t len = last - first; 00142 memmove(start, first, len * sizeof(short)); 00143 finish = start + len; 00144 } 00145 //------------------------------------------------------------------------------ 00146 // template<> inline void 00147 // BCP_vec<short>::unchecked_keep_by_index(BCP_vec<int>::const_iterator firstpos, 00148 // BCP_vec<int>::const_iterator lastpos); 00149 //------------------------------------------------------------------------------ 00150 // template<> inline void 00151 // BCP_vec<short>::keep_by_index(BCP_vec<int>::const_iterator firstpos, 00152 // BCP_vec<int>::const_iterator lastpos); 00153 //------------------------------------------------------------------------------ 00154 // template<> inline void 00155 // BCP_vec<short>::keep_by_index(const BCP_vec<int>& positions); 00156 //------------------------------------------------------------------------------ 00157 // template<> inline void 00158 // BCP_vec<short>::unchecked_keep_by_index(const BCP_vec<int>& positions); 00159 00160 //############################################################################## 00161 00162 template<> inline void BCP_vec<short>::erase(iterator position) 00163 { 00164 if (position + 1 != finish) 00165 memmove(position, position + 1, ((finish-position) - 1) * sizeof(short)); 00166 --finish; 00167 } 00168 //------------------------------------------------------------------------------ 00169 template<> inline void BCP_vec<short>::erase(iterator first, iterator last) 00170 { 00171 if (first != last && last != finish) 00172 memmove(first, last, (finish - last) * sizeof(short)); 00173 finish -= (last - first); 00174 } 00175 //------------------------------------------------------------------------------ 00176 // template <class T> inline void 00177 // BCP_vec<T>::erase_by_index(const BCP_vec<int>& positions); 00178 //------------------------------------------------------------------------------ 00179 // template <class T> inline void 00180 // BCP_vec<T>::unchecked_erase_by_index(const BCP_vec<int>& positions); 00181 //------------------------------------------------------------------------------ 00182 // template <class T> inline void 00183 // BCP_vec<T>::erase_by_index(BCP_vec<int>::const_iterator firstpos, 00184 // BCP_vec<int>::const_iterator lastpos); 00185 //------------------------------------------------------------------------------ 00186 // template <class T> void 00187 // BCP_vec<T>::unchecked_erase_by_index(BCP_vec<int>::const_iterator firstpos, 00188 // BCP_vec<int>::const_iterator lastpos); 00189 00190 //############################################################################# 00191