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 ++length_;
00042 (*this)[length_-1] = elem;
00043 }
00044
00045 template <class T, size_t DEFAULT_SIZE>
00046 void ACE_Vector<T, DEFAULT_SIZE>::dump (void) const
00047 {
00048 #if defined (ACE_HAS_DUMP)
00049 #if 0
00050
00051
00052 for (size_t i = 0; i < this->size (); ++i)
00053 (*this)[i].dump ();
00054 #endif
00055 #endif
00056 }
00057
00058
00059 template <class T, size_t DEFAULT_SIZE> bool
00060 ACE_Vector<T, DEFAULT_SIZE>::operator== (const ACE_Vector<T, DEFAULT_SIZE> &s) const
00061 {
00062 if (this == &s)
00063 return true;
00064 else if (this->size () != s.size ())
00065 return false;
00066
00067 const size_t len = s.size ();
00068 for (size_t slot = 0; slot < len; ++slot)
00069 if ((*this)[slot] != s[slot])
00070 return false;
00071
00072 return true;
00073 }
00074
00075 #if 0
00076 template<class T>
00077 int compare(const ACE_Vector<T>& v1,
00078 const ACE_Vector<T>& v2,
00079 const size_t from_ndx,
00080 const size_t to_ndx)
00081 {
00082 size_t last1 = v1.size () - 1;
00083 size_t last2 = v2.size () - 1;
00084 if (last1 < from_ndx || last1 < to_ndx)
00085 {
00086 return false;
00087 }
00088 if (last2 < from_ndx || last2 < to_ndx)
00089 {
00090 return false;
00091 }
00092 if (last1 != last2)
00093 {
00094 return false;
00095 }
00096
00097
00098 for (size_t i = from_ndx; i <= to_ndx; ++i)
00099 {
00100
00101
00102
00103 if (v1[i] != v2[i])
00104 {
00105 return false;
00106 }
00107 }
00108
00109 return true;
00110 }
00111
00112 template<class T>
00113 int partial_compare(const ACE_Vector<T>& v1,
00114 const ACE_Vector<T>& v2,
00115 const size_t from_ndx,
00116 const size_t to_ndx)
00117 {
00118 size_t last1 = v1.size () - 1;
00119 size_t last2 = v2.size () - 1;
00120 if (last1 < from_ndx || last1 < to_ndx)
00121 {
00122 return false;
00123 }
00124 if (last2 < from_ndx || last2 < to_ndx)
00125 {
00126 return false;
00127 }
00128
00129 for (size_t i = from_ndx; i <= to_ndx; ++i)
00130 {
00131
00132
00133
00134 if (v1[i] != v2[i])
00135 {
00136 return false;
00137 }
00138 }
00139
00140 return true;
00141 }
00142 #endif
00143
00144
00145
00146 template <class T, size_t DEFAULT_SIZE> int
00147 ACE_Vector_Iterator<T, DEFAULT_SIZE>::next (T *&item)
00148 {
00149
00150
00151 if (this->done ())
00152 {
00153 item = 0;
00154 return 0;
00155 }
00156 else
00157 {
00158 item = &vector_[current_];
00159 return 1;
00160 }
00161 }
00162
00163 ACE_END_VERSIONED_NAMESPACE_DECL
00164
00165 #endif