6 #include <lib/base/smartptr.h>
9 class ePtrList : public std::list<T*>
12 typedef typename std::list<T*, std::allocator<T*> >::iterator std_list_T_iterator; // to remove compiler warnings
13 typedef typename std::list<T*, std::allocator<T*> >::const_iterator std_list_T_const_iterator;
14 typedef typename std::list<T*, std::allocator<T*> >::reverse_iterator std_list_T_reverse_iterator;
15 typedef typename std::list<T*, std::allocator<T*> >::const_reverse_iterator std_list_T_const_reverse_iterator;
16 typedef typename ePtrList<T>::iterator T_iterator;
17 typedef typename ePtrList<T>::const_iterator T_const_iterator;
18 typedef typename ePtrList<T>::reverse_iterator T_reverse_iterator;
19 typedef typename ePtrList<T>::const_reverse_iterator T_const_reverse_iterator;
24 class reverse_iterator;
25 class const_reverse_iterator;
29 inline ePtrList(const ePtrList&);
32 // overwritted sort method
35 // changed methods for autodelete and current implementation
36 inline void remove(T* t);
38 inline void pop_back();
39 inline void pop_front();
40 inline void push_back(T*);
41 inline void push_front(T*);
43 // added methods for current implementation
45 inline void take(T* t);
51 inline T* setCurrent(const T*);
52 inline const T* current() const;
53 inline const T* next() const;
54 inline const T* prev() const;
55 inline const T* first() const;
56 inline const T* last() const;
58 // added operator methods
59 inline operator bool();
60 inline bool operator!();
62 // added compare struct ... to sort
67 iterator ePtrList<T>::begin()
69 // makes implicit type conversion form std::list::iterator to ePtrList::iterator
70 return std::list<T*>::begin();
73 iterator ePtrList<T>::end()
75 // makes implicit type conversion form std::list::iterator to ePtrList::iterator
76 return std::list<T*>::end();
79 const_iterator ePtrList<T>::begin() const
81 // makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
82 return std::list<T*>::begin();
85 const_iterator ePtrList<T>::end() const
87 // makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
88 return std::list<T*>::end();
91 reverse_iterator ePtrList<T>::rbegin()
93 // makes implicit type conversion form std::list::reverse:_iterator to ePtrList::reverse_iterator
94 return std::list<T*>::rbegin();
97 reverse_iterator ePtrList<T>::rend()
99 // makes implicit type conversion form std::list::reverse_iterator to ePtrList::reverse_iterator
100 return std::list<T*>::rend();
103 const_reverse_iterator ePtrList<T>::rbegin() const
105 // makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
106 return std::list<T*>::rbegin();
109 const_reverse_iterator ePtrList<T>::rend() const
111 // makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
112 return std::list<T*>::rend();
115 iterator ePtrList<T>::erase(iterator it)
117 // Remove the item it, if auto-deletion is enabled, than the list call delete for this item
118 // If current is equal to the item that was removed, current is set to the next item in the list
120 return cur = std::list<T*>::erase(it);
122 return std::list<T*>::erase(it);
125 iterator ePtrList<T>::erase(iterator from, iterator to)
127 // Remove all items between the to iterators from and to
128 // If auto-deletion is enabled, than the list call delete for all removed items
137 // Returns a iterator that equal to begin() of the list
141 operator const_iterator() const
143 // Returns a const_iterator that equal to begin() of the list
147 operator reverse_iterator()
149 // Returns a reverse_iterator that equal to rbegin() of the list
153 operator const_reverse_iterator() const
155 // Returns a const_reverse_iterator that equal to rbegin() of the list
159 std::vector<T>* getVector()
161 // Creates an vector and copys all elements to this vector
162 // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
163 std::vector<T>* v=new std::vector<T>();
164 v->reserve( std::list<T>::size() );
165 for ( std_list_T_iterator it( std::list<T*>::begin() ); it != std::list<T*>::end(); it++)
166 v->push_back( **it );
171 // inline iterator insert_in_order( T* e )
173 // // added a new item to the list... in order
174 // // returns a iterator to the new item
175 // return insert( std::lower_bound( std::list<T*>::begin(), std::list<T*>::end(), e ), e );
180 /////////////////// iterator class /////////////////////////////
182 class ePtrList<T>::iterator : public std::list<T*>::iterator
186 iterator(const std_list_T_iterator& Q) : std_list_T_iterator(Q) { }
188 // changed operator for pointer
189 T* operator->() const
191 return *std::list<T*>::iterator::operator->();
196 return *operator->();
204 iterator& operator++()
206 std::list<T*>::iterator::operator++();
210 iterator operator++(int)
212 return std::list<T*>::iterator::operator++(0);
215 iterator& operator--()
217 std::list<T*>::iterator::operator--();
221 iterator operator--(int)
223 return std::list<T*>::iterator::operator--(0);
227 /////////////////// const_iterator class /////////////////////////////
229 class ePtrList<T>::const_iterator : public std::list<T*>::const_iterator
233 const_iterator(const std_list_T_const_iterator& Q) :std_list_T_const_iterator(Q) { }
235 // changed operator for pointer
236 T* operator->() const
238 return *std::list<T*>::const_iterator::operator->();
243 return *operator->();
251 const_iterator& operator++()
253 std::list<T*>::const_iterator::operator++();
257 const_iterator operator++(int)
259 return std::list<T*>::const_iterator::operator++(0);
262 const_iterator& operator--()
264 std::list<T*>::const_iterator::operator--();
268 const_iterator operator--(int)
270 return std::list<T*>::const_iterator::operator--(0);
274 /////////////////// reverse_iterator class /////////////////////////////
276 class ePtrList<T>::reverse_iterator : public std::list<T*>::reverse_iterator
280 reverse_iterator(const std_list_T_reverse_iterator& Q) :std_list_T_reverse_iterator(Q) { }
282 // changed operators for pointer
283 T* operator->() const
285 return *std::list<T*>::reverse_iterator::operator->();
290 return *operator->();
298 reverse_iterator& operator++()
300 std::list<T*>::reverse_iterator::operator++();
304 reverse_iterator operator++(int)
306 return std::list<T*>::reverse_iterator::operator++(0);
309 reverse_iterator& operator--()
311 std::list<T*>::reverse_iterator::operator--();
315 reverse_iterator operator--(int)
317 return std::list<T*>::reverse_iterator::operator--(0);
321 /////////////////// const_reverse_iterator class /////////////////////////////
323 class ePtrList<T>::const_reverse_iterator : public std::list<T*>::const_reverse_iterator
327 const_reverse_iterator(const std_list_T_const_reverse_iterator& Q) :std_list_T_const_reverse_iterator(Q) { }
329 // changed operators for pointer
330 T* operator->() const
332 return *std::list<T*>::const_reverse_iterator::operator->();
337 return *operator->();
345 const_reverse_iterator& operator++()
347 std::list<T*>::const_reverse_iterator::operator++();
351 const_reverse_iterator operator++(int)
353 return std::list<T*>::const_reverse_iterator::operator++(0);
356 const_reverse_iterator& operator--()
358 std::list<T*>::const_reverse_iterator::operator--();
362 const_reverse_iterator operator--(int)
364 return std::list<T*>::const_reverse_iterator::operator--(0);
368 /////////////////// Default Constructor /////////////////////////////
370 ePtrList<T>::ePtrList()
371 :cur(std::list<T*>::begin())
376 /////////////////// Copy Constructor /////////////////////////////
378 ePtrList<T>::ePtrList(const ePtrList& e)
379 :std::list<T*>(e), cur(e.cur)
383 /////////////////// ePtrList Destructor /////////////////////////////
385 inline ePtrList<T>::~ePtrList()
389 /////////////////// ePtrList sort() /////////////////////////
391 inline void ePtrList<T>::sort()
393 // Sorts all items in the list.
394 // The type T must have a operator <.
395 std::list<T*>::sort(typename ePtrList<T>::less());
398 /////////////////// ePtrList remove(T*) /////////////////////////
400 inline void ePtrList<T>::remove(T* t)
402 // Remove all items that, equals to t, if auto-deletion is enabled, than the list call delete for the removed items
403 // If current is equal to one of the removed items, current is set to the next valid item
404 T_iterator it(std::list<T*>::begin());
406 while (it != std::list<T*>::end())
410 break; // one item is complete removed an deleted
415 while (it != std::list<T*>::end())
417 it = std::list<T*>::erase(it); // remove all other items that equals to t (no delete is called..)
423 /////////////////// ePtrList clear() //////////////////
425 inline void ePtrList<T>::clear()
427 // Remove all items from the list
428 // If auto-deletion is enabled, than the list call delete for all items in the list
429 erase(std::list<T*>::begin(), std::list<T*>::end());
432 /////////////////// ePtrList pop_back() ////////////////////
434 inline void ePtrList<T>::pop_back()
436 // Removes the last item from the list. If the current item ist the last, than the current is set to the new
437 // last item in the list;
438 // The removed item is deleted if auto-deletion is enabled.
442 /////////////////// ePtrList pop_front() ////////////////////
444 inline void ePtrList<T>::pop_front()
446 // Removes the first item from the list. If the current item ist the first, than the current is set to the new
447 // first item in the list;
448 // The removed item is deleted if auto-deletion is enabled.
452 /////////////////// ePtrList push_back(T*) ////////////////////
454 inline void ePtrList<T>::push_back(T* x)
456 // Add a new item at the end of the list.
457 // The current item is set to the last item;
458 std::list<T*>::push_back(x);
462 /////////////////// ePtrList push_front(T*) ////////////////////
464 inline void ePtrList<T>::push_front(T* x)
466 // Add a new item at the begin of the list.
467 // The current item is set to the first item;
468 std::list<T*>::push_front(x);
472 /////////////////// ePtrList take() ////////////////////
474 inline T* ePtrList<T>::take()
476 // Takes the current item out of the list without deleting it (even if auto-deletion is enabled).
477 // Returns a pointer to the item taken out of the list, or null if the index is out of range.
478 // 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.
479 // The current item is set to null if the list becomes empty.
481 cur = std::list<T*>::erase(cur);
485 /////////////////// ePtrList take(T*) ////////////////////
487 inline void ePtrList<T>::take(T* t)
489 // Takes all item with T* out of the list without deleting it (even if auto-deletion is enabled).
490 std::list<T*>::remove(t);
493 /////////////////// ePtrList setCurrent(T*) ////////////////////
495 inline T* ePtrList<T>::setCurrent(const T* t)
497 // Sets the internal current iterator to the first element that equals to t, and returns t when a item is found,
498 // otherwise it returns 0 !
499 for (T_iterator it(std::list<T*>::begin()); it != std::list<T*>::end(); ++it)
509 /////////////////// ePtrList current() ////////////////////
511 inline T* ePtrList<T>::current()
513 // Returns a pointer to the current list item. The current item may be null (implies that the current index is -1).
514 return cur==end() ? 0 : *cur;
517 /////////////////// ePtrList next() ////////////////////
519 inline T* ePtrList<T>::next()
521 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
522 // 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.
532 /////////////////// ePtrList prev() ////////////////////
534 inline T* ePtrList<T>::prev()
536 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
537 // 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.
544 /////////////////// ePtrList first() ////////////////////
546 inline T* ePtrList<T>::first()
548 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
549 return *(cur = begin());
552 /////////////////// ePtrList last() ////////////////////
554 inline T* ePtrList<T>::last()
556 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
557 return *(cur = --end());
560 /////////////////// const ePtrList current() ////////////////////
562 inline const T* ePtrList<T>::current() const
564 // Returns a pointer to the current list item. The current item may be null (implies that the current index is not valid)
565 return cur==end() ? 0 : *cur;
568 /////////////////// const ePtrList next() ////////////////////
570 inline const T* ePtrList<T>::next() const
572 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
573 // 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.
583 /////////////////// const ePtrList prev() ////////////////////
585 inline const T* ePtrList<T>::prev() const
587 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
588 // 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.
595 /////////////////// const ePtrList first() ////////////////////
597 inline const T* ePtrList<T>::first() const
599 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
600 return *(cur = begin());
603 /////////////////// const ePtrList last() ////////////////////
605 inline const T* ePtrList<T>::last() const
607 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
608 return *(cur = --end());
611 ////////////////// struct less //////////////////////////////
613 struct ePtrList<T>::less
615 // operator() is used internal from the list to sort them
616 bool operator() (const T* t1, const T* t2)
622 /////////////////// ePtrList operator bool ////////////////////
624 ePtrList<T>::operator bool()
626 // Returns a bool that contains true, when the list is NOT empty otherwise false
627 return !std::list<T*>::empty();
631 bool ePtrList<T>::operator!()
633 // Returns a bool that contains true, when the list is empty otherwise false
634 return std::list<T*>::empty();
638 class eSmartPtrList : public std::list<ePtr<T> >
641 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::iterator std_list_T_iterator; // to remove compiler warnings
642 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::const_iterator std_list_T_const_iterator;
643 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::reverse_iterator std_list_T_reverse_iterator;
644 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::const_reverse_iterator std_list_T_const_reverse_iterator;
645 typedef typename eSmartPtrList<T>::iterator T_iterator;
646 typedef typename eSmartPtrList<T>::const_iterator T_const_iterator;
647 typedef typename eSmartPtrList<T>::reverse_iterator T_reverse_iterator;
648 typedef typename eSmartPtrList<T>::const_reverse_iterator T_const_reverse_iterator;
652 class const_iterator;
653 class reverse_iterator;
654 class const_reverse_iterator;
657 inline eSmartPtrList();
658 inline eSmartPtrList(const eSmartPtrList&);
659 inline ~eSmartPtrList();
661 // overwritted sort method
664 // changed methods for autodelete and current implementation
665 inline void remove(T* t);
667 inline void pop_back();
668 inline void pop_front();
669 inline void push_back(T*);
670 inline void push_front(T*);
672 // added methods for current implementation
674 // inline void take(T* t);
680 inline T* setCurrent(const T*);
681 inline const T* current() const;
682 inline const T* next() const;
683 inline const T* prev() const;
684 inline const T* first() const;
685 inline const T* last() const;
687 // added operator methods
688 inline operator bool();
689 inline bool operator!();
691 // added compare struct ... to sort
696 iterator eSmartPtrList<T>::begin()
698 // makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
699 return std::list<ePtr<T> >::begin();
702 iterator eSmartPtrList<T>::end()
704 // makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
705 return std::list<ePtr<T> >::end();
708 const_iterator eSmartPtrList<T>::begin() const
710 // makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
711 return std::list<ePtr<T> >::begin();
714 const_iterator eSmartPtrList<T>::end() const
716 // makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
717 return std::list<ePtr<T> >::end();
720 reverse_iterator eSmartPtrList<T>::rbegin()
722 // makes implicit type conversion form std::list::reverse:_iterator to eSmartPtrList::reverse_iterator
723 return std::list<ePtr<T> >::rbegin();
726 reverse_iterator eSmartPtrList<T>::rend()
728 // makes implicit type conversion form std::list::reverse_iterator to eSmartPtrList::reverse_iterator
729 return std::list<ePtr<T> >::rend();
732 const_reverse_iterator eSmartPtrList<T>::rbegin() const
734 // makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
735 return std::list<ePtr<T> >::rbegin();
738 const_reverse_iterator eSmartPtrList<T>::rend() const
740 // makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
741 return std::list<ePtr<T> >::rend();
744 iterator eSmartPtrList<T>::erase(iterator it)
746 // Remove the item it, if auto-deletion is enabled, than the list call delete for this item
747 // If current is equal to the item that was removed, current is set to the next item in the list
750 return cur = std::list<ePtr<T> >::erase(it);
752 return std::list<ePtr<T> >::erase(it);
755 iterator eSmartPtrList<T>::erase(iterator from, iterator to)
757 // Remove all items between the to iterators from and to
758 // If auto-deletion is enabled, than the list call delete for all removed items
767 // Returns a iterator that equal to begin() of the list
771 operator const_iterator() const
773 // Returns a const_iterator that equal to begin() of the list
777 operator reverse_iterator()
779 // Returns a reverse_iterator that equal to rbegin() of the list
783 operator const_reverse_iterator() const
785 // Returns a const_reverse_iterator that equal to rbegin() of the list
789 std::vector<T>* getVector()
791 // Creates an vector and copys all elements to this vector
792 // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
793 std::vector<T>* v=new std::vector<T>();
794 v->reserve( std::list<T>::size() );
795 for ( std_list_T_iterator it( std::list<ePtr<T> >::begin() ); it != std::list<ePtr<T> >::end(); it++)
796 v->push_back( **it );
801 // inline iterator insert_in_order( T* e )
803 // // added a new item to the list... in order
804 // // returns a iterator to the new item
805 // return insert( std::lower_bound( std::list<ePtr<T> >::begin(), std::list<ePtr<T> >::end(), e ), e );
810 /////////////////// iterator class /////////////////////////////
812 class eSmartPtrList<T>::iterator : public std::list<ePtr<T> >::iterator
816 iterator(const std_list_T_iterator& Q) : std_list_T_iterator(Q) { }
818 // changed operator for pointer
819 T* operator->() const
821 return *std::list<ePtr<T> >::iterator::operator->();
826 return *operator->();
834 iterator& operator++()
836 std::list<ePtr<T> >::iterator::operator++();
840 iterator operator++(int)
842 return std::list<ePtr<T> >::iterator::operator++(0);
845 iterator& operator--()
847 std::list<ePtr<T> >::iterator::operator--();
851 iterator operator--(int)
853 return std::list<ePtr<T> >::iterator::operator--(0);
857 /////////////////// const_iterator class /////////////////////////////
859 class eSmartPtrList<T>::const_iterator : public std::list<ePtr<T> >::const_iterator
863 const_iterator(const std_list_T_const_iterator& Q) :std_list_T_const_iterator(Q) { }
865 // changed operator for pointer
866 T* operator->() const
868 return *std::list<ePtr<T> >::const_iterator::operator->();
873 return *operator->();
881 const_iterator& operator++()
883 std::list<ePtr<T> >::const_iterator::operator++();
887 const_iterator operator++(int)
889 return std::list<ePtr<T> >::const_iterator::operator++(0);
892 const_iterator& operator--()
894 std::list<ePtr<T> >::const_iterator::operator--();
898 const_iterator operator--(int)
900 return std::list<ePtr<T> >::const_iterator::operator--(0);
904 /////////////////// reverse_iterator class /////////////////////////////
906 class eSmartPtrList<T>::reverse_iterator : public std::list<ePtr<T> >::reverse_iterator
910 reverse_iterator(const std_list_T_reverse_iterator& Q) :std_list_T_reverse_iterator(Q) { }
912 // changed operators for pointer
913 T* operator->() const
915 return *std::list<ePtr<T> >::reverse_iterator::operator->();
920 return *operator->();
928 reverse_iterator& operator++()
930 std::list<ePtr<T> >::reverse_iterator::operator++();
934 reverse_iterator operator++(int)
936 return std::list<ePtr<T> >::reverse_iterator::operator++(0);
939 reverse_iterator& operator--()
941 std::list<ePtr<T> >::reverse_iterator::operator--();
945 reverse_iterator operator--(int)
947 return std::list<ePtr<T> >::reverse_iterator::operator--(0);
951 /////////////////// const_reverse_iterator class /////////////////////////////
953 class eSmartPtrList<T>::const_reverse_iterator : public std::list<ePtr<T> >::const_reverse_iterator
957 const_reverse_iterator(const std_list_T_const_reverse_iterator& Q) :std_list_T_const_reverse_iterator(Q) { }
959 // changed operators for pointer
960 T* operator->() const
962 return *std::list<ePtr<T> >::const_reverse_iterator::operator->();
967 return *operator->();
975 const_reverse_iterator& operator++()
977 std::list<ePtr<T> >::const_reverse_iterator::operator++();
981 const_reverse_iterator operator++(int)
983 return std::list<ePtr<T> >::const_reverse_iterator::operator++(0);
986 const_reverse_iterator& operator--()
988 std::list<ePtr<T> >::const_reverse_iterator::operator--();
992 const_reverse_iterator operator--(int)
994 return std::list<ePtr<T> >::const_reverse_iterator::operator--(0);
998 /////////////////// Default Constructor /////////////////////////////
1000 eSmartPtrList<T>::eSmartPtrList()
1001 :cur(std::list<ePtr<T> >::begin())
1006 /////////////////// Copy Constructor /////////////////////////////
1008 eSmartPtrList<T>::eSmartPtrList(const eSmartPtrList& e)
1009 :std::list<ePtr<T> >(e), cur(e.cur)
1013 /////////////////// eSmartPtrList Destructor /////////////////////////////
1015 inline eSmartPtrList<T>::~eSmartPtrList()
1020 /////////////////// eSmartPtrList sort() /////////////////////////
1022 inline void eSmartPtrList<T>::sort()
1024 // Sorts all items in the list.
1025 // The type T must have a operator <.
1026 std::list<ePtr<T> >::sort(eSmartPtrList<T>::less());
1029 /////////////////// eSmartPtrList remove(T*) /////////////////////////
1031 inline void eSmartPtrList<T>::remove(T* t)
1033 // Remove all items that, equals to t, if auto-deletion is enabled, than the list call delete for the removed items
1034 // If current is equal to one of the removed items, current is set to the next valid item
1035 T_iterator it(std::list<ePtr<T> >::begin());
1037 while (it != std::list<ePtr<T> >::end())
1041 break; // one item is complete removed an deleted
1046 while (it != std::list<ePtr<T> >::end())
1048 it = std::list<ePtr<T> >::erase(it); // remove all other items that equals to t (no delete is called..)
1054 /////////////////// eSmartPtrList clear() //////////////////
1056 inline void eSmartPtrList<T>::clear()
1058 // Remove all items from the list
1059 // If auto-deletion is enabled, than the list call delete for all items in the list
1060 erase(std::list<ePtr<T> >::begin(), std::list<ePtr<T> >::end());
1063 /////////////////// eSmartPtrList pop_back() ////////////////////
1065 inline void eSmartPtrList<T>::pop_back()
1067 // Removes the last item from the list. If the current item ist the last, than the current is set to the new
1068 // last item in the list;
1069 // The removed item is deleted if auto-deletion is enabled.
1073 /////////////////// eSmartPtrList pop_front() ////////////////////
1075 inline void eSmartPtrList<T>::pop_front()
1077 // Removes the first item from the list. If the current item ist the first, than the current is set to the new
1078 // first item in the list;
1079 // The removed item is deleted if auto-deletion is enabled.
1083 /////////////////// eSmartPtrList push_back(T*) ////////////////////
1085 inline void eSmartPtrList<T>::push_back(T* x)
1087 // Add a new item at the end of the list.
1088 // The current item is set to the last item;
1089 std::list<ePtr<T> >::push_back(x);
1093 /////////////////// eSmartPtrList push_front(T*) ////////////////////
1095 inline void eSmartPtrList<T>::push_front(T* x)
1097 // Add a new item at the begin of the list.
1098 // The current item is set to the first item;
1099 std::list<ePtr<T> >::push_front(x);
1103 /////////////////// eSmartPtrList take() ////////////////////
1104 //template <class T>
1105 //inline T* eSmartPtrList<T>::take()
1107 //// Takes the current item out of the list without deleting it (even if auto-deletion is enabled).
1108 //// Returns a pointer to the item taken out of the list, or null if the index is out of range.
1109 //// 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.
1110 //// The current item is set to null if the list becomes empty.
1112 // cur = std::list<T*>::erase(cur);
1116 /////////////////// eSmartPtrList take(T*) ////////////////////
1117 //template <class T>
1118 //inline void eSmartPtrList<T>::take(T* t)
1120 //// Takes all item with T* out of the list without deleting it (even if auto-deletion is enabled).
1121 // std::list<T*>::remove(t);
1124 /////////////////// eSmartPtrList setCurrent(T*) ////////////////////
1126 inline T* eSmartPtrList<T>::setCurrent(const T* t)
1128 // Sets the internal current iterator to the first element that equals to t, and returns t when a item is found,
1129 // otherwise it returns 0 !
1130 for (T_iterator it(std::list<ePtr<T> >::begin()); it != std::list<ePtr<T> >::end(); ++it)
1140 /////////////////// eSmartPtrList current() ////////////////////
1142 inline T* eSmartPtrList<T>::current()
1144 // Returns a pointer to the current list item. The current item may be null (implies that the current index is -1).
1145 return cur==end() ? 0 : *cur;
1148 /////////////////// eSmartPtrList next() ////////////////////
1150 inline T* eSmartPtrList<T>::next()
1152 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
1153 // 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.
1163 /////////////////// eSmartPtrList prev() ////////////////////
1165 inline T* eSmartPtrList<T>::prev()
1167 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
1168 // 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.
1175 /////////////////// eSmartPtrList first() ////////////////////
1177 inline T* eSmartPtrList<T>::first()
1179 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
1180 return *(cur = begin());
1183 /////////////////// eSmartPtrList last() ////////////////////
1185 inline T* eSmartPtrList<T>::last()
1187 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
1188 return *(cur = --end());
1191 /////////////////// const eSmartPtrList current() ////////////////////
1193 inline const T* eSmartPtrList<T>::current() const
1195 // Returns a pointer to the current list item. The current item may be null (implies that the current index is not valid)
1196 return cur==end() ? 0 : *cur;
1199 /////////////////// const eSmartPtrList next() ////////////////////
1201 inline const T* eSmartPtrList<T>::next() const
1203 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
1204 // 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.
1214 /////////////////// const eSmartPtrList prev() ////////////////////
1216 inline const T* eSmartPtrList<T>::prev() const
1218 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
1219 // 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.
1226 /////////////////// const eSmartPtrList first() ////////////////////
1228 inline const T* eSmartPtrList<T>::first() const
1230 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
1231 return *(cur = begin());
1234 /////////////////// const eSmartPtrList last() ////////////////////
1236 inline const T* eSmartPtrList<T>::last() const
1238 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
1239 return *(cur = --end());
1242 ////////////////// struct less //////////////////////////////
1244 struct eSmartPtrList<T>::less
1246 // operator() is used internal from the list to sort them
1247 bool operator() (const T* t1, const T* t2)
1253 /////////////////// eSmartPtrList operator bool ////////////////////
1255 eSmartPtrList<T>::operator bool()
1257 // Returns a bool that contains true, when the list is NOT empty otherwise false
1258 return !std::list<T>::empty();
1262 bool eSmartPtrList<T>::operator!()
1264 // Returns a bool that contains true, when the list is empty otherwise false
1265 return std::list<T>::empty();
1268 #endif // _E_PTRLIST