00001
00002
00003 #ifndef ACE_VECTOR_T_CPP
00004 #define ACE_VECTOR_T_CPP
00005
00006 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00007 # pragma once
00008 #endif
00009
00010 #include "ace/Vector_T.h"
00011
00012 #if !defined (__ACE_INLINE__)
00013 #include "ace/Vector_T.inl"
00014 #endif
00015
00016 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00017
00018 ACE_ALLOC_HOOK_DEFINE(ACE_Vector)
00019
00020 template <class T, size_t DEFAULT_SIZE>
00021 void ACE_Vector<T, DEFAULT_SIZE>::resize (const size_t new_size,
00022 const T& t)
00023 {
00024 ACE_Array<T>::size (new_size);
00025 if (new_size > length_)
00026 for (size_t i = length_; i < new_size; ++i)
00027 (*this)[i]=t;
00028
00029 curr_max_size_ = this->max_size ();
00030 length_ = new_size;
00031 }
00032
00033 template <class T, size_t DEFAULT_SIZE>
00034 void ACE_Vector<T, DEFAULT_SIZE>::push_back (const T& elem)
00035 {
00036 if (length_ == curr_max_size_)
00037 {
00038 ACE_Array<T>::size (curr_max_size_ * 2);
00039 curr_max_size_ = this->max_size ();
00040 }
00041 else
00042 ACE_Array<T>::size (length_ + 1);
00043
00044 ++length_;
00045 (*this)[length_-1] = elem;
00046 }
00047
00048 template <class T, size_t DEFAULT_SIZE>
00049 void ACE_Vector<T, DEFAULT_SIZE>::dump (void) const
00050 {
00051 #if defined (ACE_HAS_DUMP)
00052 #if 0
00053
00054
00055 for (size_t i = 0; i < this->size (); ++i)
00056 (*this)[i].dump ();
00057 #endif
00058 #endif
00059 }
00060
00061
00062 template <class T, size_t DEFAULT_SIZE> bool
00063 ACE_Vector<T, DEFAULT_SIZE>::operator== (const ACE_Vector<T, DEFAULT_SIZE> &s) const
00064 {
00065 if (this == &s)
00066 return true;
00067 else if (this->size () != s.size ())
00068 return false;
00069
00070 const size_t len = s.size ();
00071 for (size_t slot = 0; slot < len; ++slot)
00072 if ((*this)[slot] != s[slot])
00073 return false;
00074
00075 return true;
00076 }
00077
00078 #if 0
00079 template<class T>
00080 int compare(const ACE_Vector<T>& v1,
00081 const ACE_Vector<T>& v2,
00082 const size_t from_ndx,
00083 const size_t to_ndx)
00084 {
00085 size_t last1 = v1.size () - 1;
00086 size_t last2 = v2.size () - 1;
00087 if (last1 < from_ndx || last1 < to_ndx)
00088 return false;
00089 if (last2 < from_ndx || last2 < to_ndx)
00090 return false;
00091 if (last1 != last2)
00092 return false;
00093
00094
00095 for (size_t i = from_ndx; i <= to_ndx; ++i)
00096
00097
00098
00099 if (v1[i] != v2[i])
00100 return false;
00101
00102
00103 return true;
00104 }
00105
00106 template<class T>
00107 int partial_compare(const ACE_Vector<T>& v1,
00108 const ACE_Vector<T>& v2,
00109 const size_t from_ndx,
00110 const size_t to_ndx)
00111 {
00112 size_t last1 = v1.size () - 1;
00113 size_t last2 = v2.size () - 1;
00114
00115 if (last1 < from_ndx || last1 < to_ndx)
00116 return false;
00117 if (last2 < from_ndx || last2 < to_ndx)
00118 return false;
00119
00120
00121 for (size_t i = from_ndx; i <= to_ndx; ++i)
00122
00123
00124
00125 if (v1[i] != v2[i])
00126 return false;
00127
00128
00129 return true;
00130 }
00131 #endif
00132
00133
00134
00135 template <class T, size_t DEFAULT_SIZE> int
00136 ACE_Vector_Iterator<T, DEFAULT_SIZE>::next (T *&item)
00137 {
00138
00139
00140 if (this->done ())
00141 {
00142 item = 0;
00143 return 0;
00144 }
00145 else
00146 {
00147 item = &vector_[current_];
00148 return 1;
00149 }
00150 }
00151
00152 ACE_END_VERSIONED_NAMESPACE_DECL
00153
00154 #endif