7 #include <lib/base/smartptr.h>
8 #include <lib/base/eerror.h>
11 class ePtrList : public std::list<T*>
14 typedef typename std::list<T*, std::allocator<T*> >::iterator std_list_T_iterator; // to remove compiler warnings
15 typedef typename std::list<T*, std::allocator<T*> >::const_iterator std_list_T_const_iterator;
16 typedef typename std::list<T*, std::allocator<T*> >::reverse_iterator std_list_T_reverse_iterator;
17 typedef typename std::list<T*, std::allocator<T*> >::const_reverse_iterator std_list_T_const_reverse_iterator;
18 typedef typename ePtrList<T>::iterator T_iterator;
19 typedef typename ePtrList<T>::const_iterator T_const_iterator;
20 typedef typename ePtrList<T>::reverse_iterator T_reverse_iterator;
21 typedef typename ePtrList<T>::const_reverse_iterator T_const_reverse_iterator;
26 class reverse_iterator;
27 class const_reverse_iterator;
31 inline ePtrList(const ePtrList&);
34 // overwritted sort method
37 // changed methods for autodelete and current implementation
38 inline void remove(T* t);
40 inline void pop_back();
41 inline void pop_front();
42 inline void push_back(T*);
43 inline void push_front(T*);
45 // added methods for current implementation
47 inline void take(T* t);
53 inline T* setCurrent(const T*);
54 inline const T* current() const;
55 inline const T* next() const;
56 inline const T* prev() const;
57 inline const T* first() const;
58 inline const T* last() const;
60 // added operator methods
61 inline operator bool();
62 inline bool operator!();
64 // added compare struct ... to sort
71 // makes implicit type conversion form std::list::iterator to ePtrList::iterator
72 return std::list<T*>::begin();
77 // makes implicit type conversion form std::list::iterator to ePtrList::iterator
78 return std::list<T*>::end();
81 const_iterator begin() const
83 // makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
84 return std::list<T*>::begin();
87 const_iterator end() const
89 // makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
90 return std::list<T*>::end();
93 reverse_iterator rbegin()
95 // makes implicit type conversion form std::list::reverse:_iterator to ePtrList::reverse_iterator
96 return std::list<T*>::rbegin();
99 reverse_iterator rend()
101 // makes implicit type conversion form std::list::reverse_iterator to ePtrList::reverse_iterator
102 return std::list<T*>::rend();
105 const_reverse_iterator rbegin() const
107 // makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
108 return std::list<T*>::rbegin();
111 const_reverse_iterator rend() const
113 // makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
114 return std::list<T*>::rend();
117 iterator erase(iterator it)
119 // Remove the item it, if auto-deletion is enabled, than the list call delete for this item
120 // If current is equal to the item that was removed, current is set to the next item in the list
122 return cur = std::list<T*>::erase(it);
124 return std::list<T*>::erase(it);
127 iterator erase(iterator from, iterator to)
129 // Remove all items between the to iterators from and to
130 // If auto-deletion is enabled, than the list call delete for all removed items
139 // Returns a iterator that equal to begin() of the list
143 operator const_iterator() const
145 // Returns a const_iterator that equal to begin() of the list
149 operator reverse_iterator()
151 // Returns a reverse_iterator that equal to rbegin() of the list
155 operator const_reverse_iterator() const
157 // Returns a const_reverse_iterator that equal to rbegin() of the list
161 std::vector<T>* getVector()
163 // Creates an vector and copys all elements to this vector
164 // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
165 std::vector<T>* v=new std::vector<T>();
166 v->reserve( std::list<T>::size() );
167 for ( std_list_T_iterator it( std::list<T*>::begin() ); it != std::list<T*>::end(); it++)
168 v->push_back( **it );
173 inline iterator insert_in_order( T* e )
175 // added a new item to the list... in order
176 // returns a iterator to the new item
177 return insert( std::lower_bound( std::list<T*>::begin(), std::list<T*>::end(), e, less()), e );
182 /////////////////// iterator class /////////////////////////////
184 class ePtrList<T>::iterator : public std::list<T*>::iterator
188 iterator(const std_list_T_iterator& Q) : std_list_T_iterator(Q) { }
190 // changed operator for pointer
191 T* operator->() const
193 return *std::list<T*>::iterator::operator->();
198 return *operator->();
206 iterator& operator++()
208 std::list<T*>::iterator::operator++();
212 iterator operator++(int)
214 return std::list<T*>::iterator::operator++(0);
217 iterator& operator--()
219 std::list<T*>::iterator::operator--();
223 iterator operator--(int)
225 return std::list<T*>::iterator::operator--(0);
229 /////////////////// const_iterator class /////////////////////////////
231 class ePtrList<T>::const_iterator : public std::list<T*>::const_iterator
235 const_iterator(const std_list_T_const_iterator& Q) :std_list_T_const_iterator(Q) { }
237 // changed operator for pointer
238 T* operator->() const
240 return *std::list<T*>::const_iterator::operator->();
245 return *operator->();
253 const_iterator& operator++()
255 std::list<T*>::const_iterator::operator++();
259 const_iterator operator++(int)
261 return std::list<T*>::const_iterator::operator++(0);
264 const_iterator& operator--()
266 std::list<T*>::const_iterator::operator--();
270 const_iterator operator--(int)
272 return std::list<T*>::const_iterator::operator--(0);
276 /////////////////// reverse_iterator class /////////////////////////////
278 class ePtrList<T>::reverse_iterator : public std::list<T*>::reverse_iterator
282 reverse_iterator(const std_list_T_reverse_iterator& Q) :std_list_T_reverse_iterator(Q) { }
284 // changed operators for pointer
285 T* operator->() const
287 return *std::list<T*>::reverse_iterator::operator->();
292 return *operator->();
300 reverse_iterator& operator++()
302 std::list<T*>::reverse_iterator::operator++();
306 reverse_iterator operator++(int)
308 return std::list<T*>::reverse_iterator::operator++(0);
311 reverse_iterator& operator--()
313 std::list<T*>::reverse_iterator::operator--();
317 reverse_iterator operator--(int)
319 return std::list<T*>::reverse_iterator::operator--(0);
323 /////////////////// const_reverse_iterator class /////////////////////////////
325 class ePtrList<T>::const_reverse_iterator : public std::list<T*>::const_reverse_iterator
329 const_reverse_iterator(const std_list_T_const_reverse_iterator& Q) :std_list_T_const_reverse_iterator(Q) { }
331 // changed operators for pointer
332 T* operator->() const
334 return *std::list<T*>::const_reverse_iterator::operator->();
339 return *operator->();
347 const_reverse_iterator& operator++()
349 std::list<T*>::const_reverse_iterator::operator++();
353 const_reverse_iterator operator++(int)
355 return std::list<T*>::const_reverse_iterator::operator++(0);
358 const_reverse_iterator& operator--()
360 std::list<T*>::const_reverse_iterator::operator--();
364 const_reverse_iterator operator--(int)
366 return std::list<T*>::const_reverse_iterator::operator--(0);
370 /////////////////// Default Constructor /////////////////////////////
372 ePtrList<T>::ePtrList()
373 :cur(std::list<T*>::begin())
378 /////////////////// Copy Constructor /////////////////////////////
380 ePtrList<T>::ePtrList(const ePtrList& e)
381 :std::list<T*>(e), cur(e.cur)
385 /////////////////// ePtrList Destructor /////////////////////////////
387 inline ePtrList<T>::~ePtrList()
391 /////////////////// ePtrList sort() /////////////////////////
393 inline void ePtrList<T>::sort()
395 // Sorts all items in the list.
396 // The type T must have a operator <.
397 std::list<T*>::sort(typename ePtrList<T>::less());
400 /////////////////// ePtrList remove(T*) /////////////////////////
402 inline void ePtrList<T>::remove(T* t)
404 // Remove all items that, equals to t, if auto-deletion is enabled, than the list call delete for the removed items
405 // If current is equal to one of the removed items, current is set to the next valid item
406 T_iterator it(std::list<T*>::begin());
408 while (it != std::list<T*>::end())
412 break; // one item is complete removed an deleted
417 while (it != std::list<T*>::end())
419 it = std::list<T*>::erase(it); // remove all other items that equals to t (no delete is called..)
425 /////////////////// ePtrList clear() //////////////////
427 inline void ePtrList<T>::clear()
429 // Remove all items from the list
430 // If auto-deletion is enabled, than the list call delete for all items in the list
431 erase(std::list<T*>::begin(), std::list<T*>::end());
434 /////////////////// ePtrList pop_back() ////////////////////
436 inline void ePtrList<T>::pop_back()
438 // Removes the last item from the list. If the current item ist the last, than the current is set to the new
439 // last item in the list;
440 // The removed item is deleted if auto-deletion is enabled.
444 /////////////////// ePtrList pop_front() ////////////////////
446 inline void ePtrList<T>::pop_front()
448 // Removes the first item from the list. If the current item ist the first, than the current is set to the new
449 // first item in the list;
450 // The removed item is deleted if auto-deletion is enabled.
454 /////////////////// ePtrList push_back(T*) ////////////////////
456 inline void ePtrList<T>::push_back(T* x)
458 // Add a new item at the end of the list.
459 // The current item is set to the last item;
460 std::list<T*>::push_back(x);
464 /////////////////// ePtrList push_front(T*) ////////////////////
466 inline void ePtrList<T>::push_front(T* x)
468 // Add a new item at the begin of the list.
469 // The current item is set to the first item;
470 std::list<T*>::push_front(x);
474 /////////////////// ePtrList take() ////////////////////
476 inline T* ePtrList<T>::take()
478 // Takes the current item out of the list without deleting it (even if auto-deletion is enabled).
479 // Returns a pointer to the item taken out of the list, or null if the index is out of range.
480 // 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.
481 // The current item is set to null if the list becomes empty.
483 cur = std::list<T*>::erase(cur);
487 /////////////////// ePtrList take(T*) ////////////////////
489 inline void ePtrList<T>::take(T* t)
491 // Takes all item with T* out of the list without deleting it (even if auto-deletion is enabled).
492 std::list<T*>::remove(t);
495 /////////////////// ePtrList setCurrent(T*) ////////////////////
497 inline T* ePtrList<T>::setCurrent(const T* t)
499 // Sets the internal current iterator to the first element that equals to t, and returns t when a item is found,
500 // otherwise it returns 0 !
501 for (T_iterator it(std::list<T*>::begin()); it != std::list<T*>::end(); ++it)
511 /////////////////// ePtrList current() ////////////////////
513 inline T* ePtrList<T>::current()
515 // Returns a pointer to the current list item. The current item may be null (implies that the current index is -1).
516 return cur==end() ? 0 : *cur;
519 /////////////////// ePtrList next() ////////////////////
521 inline T* ePtrList<T>::next()
523 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
524 // Makes the succeeding item current. If the current item before this function call was the last item, the current item will be set to null. If the current item was null, this function does nothing.
534 /////////////////// ePtrList prev() ////////////////////
536 inline T* ePtrList<T>::prev()
538 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
539 // Makes the preceding item current. If the current item before this function call was the first item, the current item will be set to null. If the current item was null, this function does nothing.
546 /////////////////// ePtrList first() ////////////////////
548 inline T* ePtrList<T>::first()
550 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
551 return *(cur = begin());
554 /////////////////// ePtrList last() ////////////////////
556 inline T* ePtrList<T>::last()
558 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
559 return *(cur = --end());
562 /////////////////// const ePtrList current() ////////////////////
564 inline const T* ePtrList<T>::current() const
566 // Returns a pointer to the current list item. The current item may be null (implies that the current index is not valid)
567 return cur==end() ? 0 : *cur;
570 /////////////////// const ePtrList next() ////////////////////
572 inline const T* ePtrList<T>::next() const
574 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
575 // Makes the succeeding item current. If the current item before this function call was the last item, the current item will be set to null. If the current item was null, this function does nothing.
585 /////////////////// const ePtrList prev() ////////////////////
587 inline const T* ePtrList<T>::prev() const
589 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
590 // Makes the preceding item current. If the current item before this function call was the first item, the current item will be set to null. If the current item was null, this function does nothing.
597 /////////////////// const ePtrList first() ////////////////////
599 inline const T* ePtrList<T>::first() const
601 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
602 return *(cur = begin());
605 /////////////////// const ePtrList last() ////////////////////
607 inline const T* ePtrList<T>::last() const
609 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
610 return *(cur = --end());
613 ////////////////// struct less //////////////////////////////
615 struct ePtrList<T>::less
617 // operator() is used internal from the list to sort them
618 bool operator() (const T* t1, const T* t2)
624 /////////////////// ePtrList operator bool ////////////////////
626 ePtrList<T>::operator bool()
628 // Returns a bool that contains true, when the list is NOT empty otherwise false
629 return !std::list<T*>::empty();
633 bool ePtrList<T>::operator!()
635 // Returns a bool that contains true, when the list is empty otherwise false
636 return std::list<T*>::empty();
640 class eSmartPtrList : public std::list<ePtr<T> >
643 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::iterator std_list_T_iterator; // to remove compiler warnings
644 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::const_iterator std_list_T_const_iterator;
645 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::reverse_iterator std_list_T_reverse_iterator;
646 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::const_reverse_iterator std_list_T_const_reverse_iterator;
647 typedef typename eSmartPtrList<T>::iterator T_iterator;
648 typedef typename eSmartPtrList<T>::const_iterator T_const_iterator;
649 typedef typename eSmartPtrList<T>::reverse_iterator T_reverse_iterator;
650 typedef typename eSmartPtrList<T>::const_reverse_iterator T_const_reverse_iterator;
654 class const_iterator;
655 class reverse_iterator;
656 class const_reverse_iterator;
659 inline eSmartPtrList();
660 inline eSmartPtrList(const eSmartPtrList&);
661 inline ~eSmartPtrList();
663 // overwritted sort method
666 // changed methods for autodelete and current implementation
667 inline void remove(T* t);
669 inline void pop_back();
670 inline void pop_front();
671 inline void push_back(T*);
672 inline void push_front(T*);
674 // added methods for current implementation
676 // inline void take(T* t);
682 inline T* setCurrent(const T*);
683 inline const T* current() const;
684 inline const T* next() const;
685 inline const T* prev() const;
686 inline const T* first() const;
687 inline const T* last() const;
689 // added operator methods
690 inline operator bool();
691 inline bool operator!();
693 // added compare struct ... to sort
700 // makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
701 return std::list<ePtr<T> >::begin();
706 // makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
707 return std::list<ePtr<T> >::end();
710 const_iterator begin() const
712 // makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
713 return std::list<ePtr<T> >::begin();
716 const_iterator end() const
718 // makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
719 return std::list<ePtr<T> >::end();
722 reverse_iterator rbegin()
724 // makes implicit type conversion form std::list::reverse:_iterator to eSmartPtrList::reverse_iterator
725 return std::list<ePtr<T> >::rbegin();
728 reverse_iterator rend()
730 // makes implicit type conversion form std::list::reverse_iterator to eSmartPtrList::reverse_iterator
731 return std::list<ePtr<T> >::rend();
734 const_reverse_iterator rbegin() const
736 // makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
737 return std::list<ePtr<T> >::rbegin();
740 const_reverse_iterator rend() const
742 // makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
743 return std::list<ePtr<T> >::rend();
746 iterator erase(iterator it)
748 // Remove the item it, if auto-deletion is enabled, than the list call delete for this item
749 // If current is equal to the item that was removed, current is set to the next item in the list
752 return cur = std::list<ePtr<T> >::erase(it);
754 return std::list<ePtr<T> >::erase(it);
757 iterator erase(iterator from, iterator to)
759 // Remove all items between the to iterators from and to
760 // If auto-deletion is enabled, than the list call delete for all removed items
769 // Returns a iterator that equal to begin() of the list
773 operator const_iterator() const
775 // Returns a const_iterator that equal to begin() of the list
779 operator reverse_iterator()
781 // Returns a reverse_iterator that equal to rbegin() of the list
785 operator const_reverse_iterator() const
787 // Returns a const_reverse_iterator that equal to rbegin() of the list
791 std::vector<T>* getVector()
793 // Creates an vector and copys all elements to this vector
794 // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
795 std::vector<T>* v=new std::vector<T>();
796 v->reserve( std::list<T>::size() );
797 for ( std_list_T_iterator it( std::list<ePtr<T> >::begin() ); it != std::list<ePtr<T> >::end(); it++)
798 v->push_back( **it );
803 inline iterator insert_in_order( T* e )
805 // added a new item to the list... in order
806 // returns a iterator to the new item
807 return insert( std::lower_bound( std::list<ePtr<T> >::begin(), e, std::list<ePtr<T> >::end()), e );
812 /////////////////// iterator class /////////////////////////////
814 class eSmartPtrList<T>::iterator : public std::list<ePtr<T> >::iterator
818 iterator(const std_list_T_iterator& Q) : std_list_T_iterator(Q) { }
820 // changed operator for pointer
821 T* operator->() const
823 return *std::list<ePtr<T> >::iterator::operator->();
828 return *operator->();
836 iterator& operator++()
838 std::list<ePtr<T> >::iterator::operator++();
842 iterator operator++(int)
844 return std::list<ePtr<T> >::iterator::operator++(0);
847 iterator& operator--()
849 std::list<ePtr<T> >::iterator::operator--();
853 iterator operator--(int)
855 return std::list<ePtr<T> >::iterator::operator--(0);
859 /////////////////// const_iterator class /////////////////////////////
861 class eSmartPtrList<T>::const_iterator : public std::list<ePtr<T> >::const_iterator
865 const_iterator(const std_list_T_const_iterator& Q) :std_list_T_const_iterator(Q) { }
867 // changed operator for pointer
868 T* operator->() const
870 return *std::list<ePtr<T> >::const_iterator::operator->();
875 return *operator->();
883 const_iterator& operator++()
885 std::list<ePtr<T> >::const_iterator::operator++();
889 const_iterator operator++(int)
891 return std::list<ePtr<T> >::const_iterator::operator++(0);
894 const_iterator& operator--()
896 std::list<ePtr<T> >::const_iterator::operator--();
900 const_iterator operator--(int)
902 return std::list<ePtr<T> >::const_iterator::operator--(0);
906 /////////////////// reverse_iterator class /////////////////////////////
908 class eSmartPtrList<T>::reverse_iterator : public std::list<ePtr<T> >::reverse_iterator
912 reverse_iterator(const std_list_T_reverse_iterator& Q) :std_list_T_reverse_iterator(Q) { }
914 // changed operators for pointer
915 T* operator->() const
917 return *std::list<ePtr<T> >::reverse_iterator::operator->();
922 return *operator->();
930 reverse_iterator& operator++()
932 std::list<ePtr<T> >::reverse_iterator::operator++();
936 reverse_iterator operator++(int)
938 return std::list<ePtr<T> >::reverse_iterator::operator++(0);
941 reverse_iterator& operator--()
943 std::list<ePtr<T> >::reverse_iterator::operator--();
947 reverse_iterator operator--(int)
949 return std::list<ePtr<T> >::reverse_iterator::operator--(0);
953 /////////////////// const_reverse_iterator class /////////////////////////////
955 class eSmartPtrList<T>::const_reverse_iterator : public std::list<ePtr<T> >::const_reverse_iterator
959 const_reverse_iterator(const std_list_T_const_reverse_iterator& Q) :std_list_T_const_reverse_iterator(Q) { }
961 // changed operators for pointer
962 T* operator->() const
964 return *std::list<ePtr<T> >::const_reverse_iterator::operator->();
969 return *operator->();
977 const_reverse_iterator& operator++()
979 std::list<ePtr<T> >::const_reverse_iterator::operator++();
983 const_reverse_iterator operator++(int)
985 return std::list<ePtr<T> >::const_reverse_iterator::operator++(0);
988 const_reverse_iterator& operator--()
990 std::list<ePtr<T> >::const_reverse_iterator::operator--();
994 const_reverse_iterator operator--(int)
996 return std::list<ePtr<T> >::const_reverse_iterator::operator--(0);
1000 /////////////////// Default Constructor /////////////////////////////
1002 eSmartPtrList<T>::eSmartPtrList()
1003 :cur(std::list<ePtr<T> >::begin())
1008 /////////////////// Copy Constructor /////////////////////////////
1010 eSmartPtrList<T>::eSmartPtrList(const eSmartPtrList& e)
1011 :std::list<ePtr<T> >(e), cur(e.cur)
1015 /////////////////// eSmartPtrList Destructor /////////////////////////////
1017 inline eSmartPtrList<T>::~eSmartPtrList()
1022 /////////////////// eSmartPtrList sort() /////////////////////////
1024 inline void eSmartPtrList<T>::sort()
1026 // Sorts all items in the list.
1027 // The type T must have a operator <.
1028 std::list<ePtr<T> >::sort(eSmartPtrList<T>::less());
1031 /////////////////// eSmartPtrList remove(T*) /////////////////////////
1033 inline void eSmartPtrList<T>::remove(T* t)
1035 // Remove all items that, equals to t, if auto-deletion is enabled, than the list call delete for the removed items
1036 // If current is equal to one of the removed items, current is set to the next valid item
1037 T_iterator it(std::list<ePtr<T> >::begin());
1039 while (it != std::list<ePtr<T> >::end())
1043 break; // one item is complete removed an deleted
1048 while (it != std::list<ePtr<T> >::end())
1050 it = std::list<ePtr<T> >::erase(it); // remove all other items that equals to t (no delete is called..)
1056 /////////////////// eSmartPtrList clear() //////////////////
1058 inline void eSmartPtrList<T>::clear()
1060 // Remove all items from the list
1061 // If auto-deletion is enabled, than the list call delete for all items in the list
1062 erase(std::list<ePtr<T> >::begin(), std::list<ePtr<T> >::end());
1065 /////////////////// eSmartPtrList pop_back() ////////////////////
1067 inline void eSmartPtrList<T>::pop_back()
1069 // Removes the last item from the list. If the current item ist the last, than the current is set to the new
1070 // last item in the list;
1071 // The removed item is deleted if auto-deletion is enabled.
1075 /////////////////// eSmartPtrList pop_front() ////////////////////
1077 inline void eSmartPtrList<T>::pop_front()
1079 // Removes the first item from the list. If the current item ist the first, than the current is set to the new
1080 // first item in the list;
1081 // The removed item is deleted if auto-deletion is enabled.
1085 /////////////////// eSmartPtrList push_back(T*) ////////////////////
1087 inline void eSmartPtrList<T>::push_back(T* x)
1089 // Add a new item at the end of the list.
1090 // The current item is set to the last item;
1091 std::list<ePtr<T> >::push_back(x);
1095 /////////////////// eSmartPtrList push_front(T*) ////////////////////
1097 inline void eSmartPtrList<T>::push_front(T* x)
1099 // Add a new item at the begin of the list.
1100 // The current item is set to the first item;
1101 std::list<ePtr<T> >::push_front(x);
1105 /////////////////// eSmartPtrList setCurrent(T*) ////////////////////
1107 inline T* eSmartPtrList<T>::setCurrent(const T* t)
1109 // Sets the internal current iterator to the first element that equals to t, and returns t when a item is found,
1110 // otherwise it returns 0 !
1111 for (T_iterator it(std::list<ePtr<T> >::begin()); it != std::list<ePtr<T> >::end(); ++it)
1121 /////////////////// eSmartPtrList current() ////////////////////
1123 inline T* eSmartPtrList<T>::current()
1125 // Returns a pointer to the current list item. The current item may be null (implies that the current index is -1).
1126 return cur==end() ? 0 : *cur;
1129 /////////////////// eSmartPtrList next() ////////////////////
1131 inline T* eSmartPtrList<T>::next()
1133 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
1134 // Makes the succeeding item current. If the current item before this function call was the last item, the current item will be set to null. If the current item was null, this function does nothing.
1144 /////////////////// eSmartPtrList prev() ////////////////////
1146 inline T* eSmartPtrList<T>::prev()
1148 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
1149 // Makes the preceding item current. If the current item before this function call was the first item, the current item will be set to null. If the current item was null, this function does nothing.
1156 /////////////////// eSmartPtrList first() ////////////////////
1158 inline T* eSmartPtrList<T>::first()
1160 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
1161 return *(cur = begin());
1164 /////////////////// eSmartPtrList last() ////////////////////
1166 inline T* eSmartPtrList<T>::last()
1168 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
1169 return *(cur = --end());
1172 /////////////////// const eSmartPtrList current() ////////////////////
1174 inline const T* eSmartPtrList<T>::current() const
1176 // Returns a pointer to the current list item. The current item may be null (implies that the current index is not valid)
1177 return cur==end() ? 0 : *cur;
1180 /////////////////// const eSmartPtrList next() ////////////////////
1182 inline const T* eSmartPtrList<T>::next() const
1184 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
1185 // Makes the succeeding item current. If the current item before this function call was the last item, the current item will be set to null. If the current item was null, this function does nothing.
1195 /////////////////// const eSmartPtrList prev() ////////////////////
1197 inline const T* eSmartPtrList<T>::prev() const
1199 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
1200 // Makes the preceding item current. If the current item before this function call was the first item, the current item will be set to null. If the current item was null, this function does nothing.
1207 /////////////////// const eSmartPtrList first() ////////////////////
1209 inline const T* eSmartPtrList<T>::first() const
1211 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
1212 return *(cur = begin());
1215 /////////////////// const eSmartPtrList last() ////////////////////
1217 inline const T* eSmartPtrList<T>::last() const
1219 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
1220 return *(cur = --end());
1223 ////////////////// struct less //////////////////////////////
1225 struct eSmartPtrList<T>::less
1227 // operator() is used internal from the list to sort them
1228 bool operator() (const T* t1, const T* t2)
1234 /////////////////// eSmartPtrList operator bool ////////////////////
1236 eSmartPtrList<T>::operator bool()
1238 // Returns a bool that contains true, when the list is NOT empty otherwise false
1239 return !std::list<T>::empty();
1243 bool eSmartPtrList<T>::operator!()
1245 // Returns a bool that contains true, when the list is empty otherwise false
1246 return std::list<T>::empty();
1249 #endif // _E_PTRLIST