Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Vector_T.cpp

Go to the documentation of this file.
00001 // $Id: Vector_T.cpp,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $
00002 
00003 #ifndef ACE_VECTOR_T_C
00004 #define ACE_VECTOR_T_C
00005 
00006 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00007 # pragma once
00008 #endif /* ACE_LACKS_PRAGMA_ONCE */
00009 
00010 #include "ace/Vector_T.h"
00011 
00012 #if !defined (__ACE_INLINE__)
00013 #include "ace/Vector_T.i"
00014 #endif /* __ACE_INLINE__ */
00015 
00016 ACE_RCSID(ace, Vector_T, "$Id: Vector_T.cpp,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $")
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 0
00049   // Can't do this unless the vector is an object with a dump
00050   // function.
00051   for (size_t i = 0; i < this->size (); ++i)
00052     (*this)[i].dump ();
00053 #endif /* 0 */
00054 }
00055 
00056 #if 0
00057 template<class T>
00058 int compare(const ACE_Vector<T>& v1,
00059              const ACE_Vector<T>& v2,
00060              const size_t from_ndx,
00061              const size_t to_ndx)
00062 {
00063   size_t last1 = v1.size () - 1;
00064   size_t last2 = v2.size () - 1;
00065   if(last1 < from_ndx || last1 < to_ndx)
00066     {
00067       return false;
00068     }
00069   if (last2 < from_ndx || last2 < to_ndx)
00070     {
00071       return false;
00072     }
00073   if (last1 != last2)
00074     {
00075       return false;
00076     }
00077 
00078   //  cout<<"compare() <================="<<endl;
00079   for (size_t i = from_ndx; i <= to_ndx; ++i)
00080     {
00081       //     cout<<"V1["<<i<<"]="<<v1[i];
00082       //     cout<<", V2["<<i<<"]="<<v2[i];
00083       //     cout<<": NOT EQUAL == "<<(v1[i]!=v2[i])<<endl;
00084       if (v1[i] != v2[i])
00085         {
00086           return false;
00087         }
00088     }
00089   //  cout<<"compare() ====================>"<<endl;
00090   return true;
00091 }
00092 
00093 template<class T>
00094 int partial_compare(const ACE_Vector<T>& v1,
00095                      const ACE_Vector<T>& v2,
00096                      const size_t from_ndx,
00097                      const size_t to_ndx)
00098 {
00099   size_t last1 = v1.size () - 1;
00100   size_t last2 = v2.size () - 1;
00101   if (last1 < from_ndx || last1 < to_ndx)
00102     {
00103       return false;
00104     }
00105   if (last2 < from_ndx || last2 < to_ndx)
00106     {
00107       return false;
00108     }
00109   //  cout<<"partial_compare() <================="<<endl;
00110   for (size_t i = from_ndx; i <= to_ndx; ++i)
00111     {
00112       //     cout<<"V1["<<i<<"]="<<v1[i];
00113       //     cout<<", V2["<<i<<"]="<<v2[i];
00114       //     cout<<": NOT EQUAL == "<<(v1[i]!=v2[i])<<endl;
00115       if (v1[i] != v2[i])
00116         {
00117           return false;
00118         }
00119     }
00120   //  cout<<"partial_compare() ====================>"<<endl;
00121   return true;
00122 }
00123 #endif
00124 
00125 #endif /* ACE_VECTOR_T_C */

Generated on Mon Jun 16 11:22:04 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002