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

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