00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef BBRCOLLECTIONUTILS_HH
00020 #define BBRCOLLECTIONUTILS_HH
00021
00022 #include <algorithm>
00023
00024
00025 namespace bes {
00026 namespace Collection {
00027
00028 #ifdef OO_DDL_TRANSLATION
00029 struct PtrLess;
00030 #else
00031 struct PtrLess {
00032 template<class PtrType>
00033 bool operator()(PtrType ptr1, PtrType ptr2) const {
00034 return (*ptr1) < (*ptr2);
00035 }
00036 };
00037 #endif
00038
00039 struct DeleteObject{
00040
00041
00042
00043 template< class T >
00044 void operator()(const T* ptr) const {
00045 delete ptr;
00046 }
00047 };
00048
00049 struct DeleteArray{
00050
00051
00052
00053 template< class T >
00054 void operator()(const T array[]) const {
00055 delete[] array;
00056 }
00057 };
00058
00073 template < class C, class T >
00074 typename C::difference_type
00075 findIndex( const C& container, const T& value ) {
00076 typename C::const_iterator found
00077 = std::find( container.begin(), container.end(), value );
00078
00079
00081
00082
00083 return found - container.begin();
00084 }
00085
00086 }
00087 }
00088
00089 #endif