X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fbase%2Feptrlist.h;h=0da46daa49ca47759531616f2b0df746c3365fe7;hp=ae61d78dae2183486156a4594486dee8af4e304a;hb=a87ad4f47c8badc8826a3541717fd1d26daf614b;hpb=1aeefd997cc362c3b37c1587c5f08891b35c3a75 diff --git a/lib/base/eptrlist.h b/lib/base/eptrlist.h index ae61d78..0da46da 100644 --- a/lib/base/eptrlist.h +++ b/lib/base/eptrlist.h @@ -3,7 +3,9 @@ #include #include +#include #include +#include template class ePtrList : public std::list @@ -56,63 +58,63 @@ public: inline const T* last() const; // added operator methods - inline operator bool(); - inline bool operator!(); + inline operator bool() const; + inline bool operator!() const; // added compare struct ... to sort struct less; private: iterator cur; public: - iterator ePtrList::begin() + iterator begin() { // makes implicit type conversion form std::list::iterator to ePtrList::iterator return std::list::begin(); } - iterator ePtrList::end() + iterator end() { // makes implicit type conversion form std::list::iterator to ePtrList::iterator return std::list::end(); } - const_iterator ePtrList::begin() const + const_iterator begin() const { // makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator return std::list::begin(); } - const_iterator ePtrList::end() const + const_iterator end() const { // makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator return std::list::end(); } - reverse_iterator ePtrList::rbegin() + reverse_iterator rbegin() { // makes implicit type conversion form std::list::reverse:_iterator to ePtrList::reverse_iterator return std::list::rbegin(); } - reverse_iterator ePtrList::rend() + reverse_iterator rend() { // makes implicit type conversion form std::list::reverse_iterator to ePtrList::reverse_iterator return std::list::rend(); } - const_reverse_iterator ePtrList::rbegin() const + const_reverse_iterator rbegin() const { // makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator return std::list::rbegin(); } - const_reverse_iterator ePtrList::rend() const + const_reverse_iterator rend() const { // makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator return std::list::rend(); } - iterator ePtrList::erase(iterator it) + iterator erase(iterator it) { // Remove the item it, if auto-deletion is enabled, than the list call delete for this item // If current is equal to the item that was removed, current is set to the next item in the list @@ -122,7 +124,7 @@ public: return std::list::erase(it); } - iterator ePtrList::erase(iterator from, iterator to) + iterator erase(iterator from, iterator to) { // Remove all items between the to iterators from and to // If auto-deletion is enabled, than the list call delete for all removed items @@ -161,8 +163,8 @@ public: // Creates an vector and copys all elements to this vector // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! ) std::vector* v=new std::vector(); - v->reserve( size() ); - for ( std_list_T_iterator it( std::list::begin() ); it != std::list::end(); it++) + v->reserve( std::list::size() ); + for ( std_list_T_iterator it( std::list::begin() ); it != std::list::end(); it++) v->push_back( **it ); return v; @@ -172,7 +174,7 @@ public: { // added a new item to the list... in order // returns a iterator to the new item - return insert( std::lower_bound( std::list::begin(), std::list::end(), e ), e ); + return insert( std::lower_bound( std::list::begin(), std::list::end(), e, less()), e ); } }; @@ -392,7 +394,7 @@ inline void ePtrList::sort() { // Sorts all items in the list. // The type T must have a operator <. - std::list::sort(ePtrList::less()); + std::list::sort(typename ePtrList::less()); } /////////////////// ePtrList remove(T*) ///////////////////////// @@ -621,17 +623,17 @@ struct ePtrList::less /////////////////// ePtrList operator bool //////////////////// template -ePtrList::operator bool() +ePtrList::operator bool() const { // Returns a bool that contains true, when the list is NOT empty otherwise false - return !empty(); + return !std::list::empty(); } template -bool ePtrList::operator!() +bool ePtrList::operator!() const { // Returns a bool that contains true, when the list is empty otherwise false - return empty(); + return std::list::empty(); } template @@ -685,63 +687,63 @@ public: inline const T* last() const; // added operator methods - inline operator bool(); - inline bool operator!(); + inline operator bool() const; + inline bool operator!() const; // added compare struct ... to sort struct less; private: iterator cur; public: - iterator eSmartPtrList::begin() + iterator begin() { // makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator return std::list >::begin(); } - iterator eSmartPtrList::end() + iterator end() { // makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator return std::list >::end(); } - const_iterator eSmartPtrList::begin() const + const_iterator begin() const { // makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator return std::list >::begin(); } - const_iterator eSmartPtrList::end() const + const_iterator end() const { // makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator return std::list >::end(); } - reverse_iterator eSmartPtrList::rbegin() + reverse_iterator rbegin() { // makes implicit type conversion form std::list::reverse:_iterator to eSmartPtrList::reverse_iterator return std::list >::rbegin(); } - reverse_iterator eSmartPtrList::rend() + reverse_iterator rend() { // makes implicit type conversion form std::list::reverse_iterator to eSmartPtrList::reverse_iterator return std::list >::rend(); } - const_reverse_iterator eSmartPtrList::rbegin() const + const_reverse_iterator rbegin() const { // makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator return std::list >::rbegin(); } - const_reverse_iterator eSmartPtrList::rend() const + const_reverse_iterator rend() const { // makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator return std::list >::rend(); } - iterator eSmartPtrList::erase(iterator it) + iterator erase(iterator it) { // Remove the item it, if auto-deletion is enabled, than the list call delete for this item // If current is equal to the item that was removed, current is set to the next item in the list @@ -752,7 +754,7 @@ public: return std::list >::erase(it); } - iterator eSmartPtrList::erase(iterator from, iterator to) + iterator erase(iterator from, iterator to) { // Remove all items between the to iterators from and to // If auto-deletion is enabled, than the list call delete for all removed items @@ -791,7 +793,7 @@ public: // Creates an vector and copys all elements to this vector // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! ) std::vector* v=new std::vector(); - v->reserve( size() ); + v->reserve( std::list::size() ); for ( std_list_T_iterator it( std::list >::begin() ); it != std::list >::end(); it++) v->push_back( **it ); @@ -802,7 +804,7 @@ public: { // added a new item to the list... in order // returns a iterator to the new item - return insert( std::lower_bound( std::list >::begin(), std::list >::end(), e ), e ); + return insert( std::lower_bound( std::list >::begin(), e, std::list >::end()), e ); } }; @@ -1100,27 +1102,6 @@ inline void eSmartPtrList::push_front(T* x) first(); } -/////////////////// eSmartPtrList take() //////////////////// -//template -//inline T* eSmartPtrList::take() -//{ -//// Takes the current item out of the list without deleting it (even if auto-deletion is enabled). -//// Returns a pointer to the item taken out of the list, or null if the index is out of range. -//// The item after the taken item becomes the new current list item if the taken item is not the last item in the list. If the last item is taken, the new last item becomes the current item. -//// The current item is set to null if the list becomes empty. -// T* tmp = *cur; -// cur = std::list::erase(cur); -// return tmp; -//} - -/////////////////// eSmartPtrList take(T*) //////////////////// -//template -//inline void eSmartPtrList::take(T* t) -//{ -//// Takes all item with T* out of the list without deleting it (even if auto-deletion is enabled). -// std::list::remove(t); -//} - /////////////////// eSmartPtrList setCurrent(T*) //////////////////// template inline T* eSmartPtrList::setCurrent(const T* t) @@ -1252,17 +1233,17 @@ struct eSmartPtrList::less /////////////////// eSmartPtrList operator bool //////////////////// template -eSmartPtrList::operator bool() +eSmartPtrList::operator bool() const { // Returns a bool that contains true, when the list is NOT empty otherwise false - return !empty(); + return !std::list::empty(); } template -bool eSmartPtrList::operator!() +bool eSmartPtrList::operator!() const { // Returns a bool that contains true, when the list is empty otherwise false - return empty(); + return std::list::empty(); } #endif // _E_PTRLIST