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 methods for autodelete implementation
63 inline void setAutoDelete(bool b);
64 inline bool isAutoDelete();
66 // added compare struct ... to sort
73 iterator ePtrList<T>::begin()
75 // makes implicit type conversion form std::list::iterator to ePtrList::iterator
76 return std::list<T*>::begin();
79 iterator ePtrList<T>::end()
81 // makes implicit type conversion form std::list::iterator to ePtrList::iterator
82 return std::list<T*>::end();
85 const_iterator ePtrList<T>::begin() const
87 // makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
88 return std::list<T*>::begin();
91 const_iterator ePtrList<T>::end() const
93 // makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
94 return std::list<T*>::end();
97 reverse_iterator ePtrList<T>::rbegin()
99 // makes implicit type conversion form std::list::reverse:_iterator to ePtrList::reverse_iterator
100 return std::list<T*>::rbegin();
103 reverse_iterator ePtrList<T>::rend()
105 // makes implicit type conversion form std::list::reverse_iterator to ePtrList::reverse_iterator
106 return std::list<T*>::rend();
109 const_reverse_iterator ePtrList<T>::rbegin() const
111 // makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
112 return std::list<T*>::rbegin();
115 const_reverse_iterator ePtrList<T>::rend() const
117 // makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
118 return std::list<T*>::rend();
121 iterator ePtrList<T>::erase(iterator it)
123 // Remove the item it, if auto-deletion is enabled, than the list call delete for this item
124 // If current is equal to the item that was removed, current is set to the next item in the list
125 if (autoDelete && *it)
129 return cur = std::list<T*>::erase(it);
131 return std::list<T*>::erase(it);
134 iterator ePtrList<T>::erase(iterator from, iterator to)
136 // Remove all items between the to iterators from and to
137 // If auto-deletion is enabled, than the list call delete for all removed items
146 // Returns a iterator that equal to begin() of the list
150 operator const_iterator() const
152 // Returns a const_iterator that equal to begin() of the list
156 operator reverse_iterator()
158 // Returns a reverse_iterator that equal to rbegin() of the list
162 operator const_reverse_iterator() const
164 // Returns a const_reverse_iterator that equal to rbegin() of the list
168 std::vector<T>* getVector()
170 // Creates an vector and copys all elements to this vector
171 // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
172 std::vector<T>* v=new std::vector<T>();
173 v->reserve( size() );
174 for ( std_list_T_iterator it( std::list<T*>::begin() ); it != std::list<T*>::end(); it++)
175 v->push_back( **it );
180 inline iterator insert_in_order( T* e )
182 // added a new item to the list... in order
183 // returns a iterator to the new item
184 return insert( std::lower_bound( std::list<T*>::begin(), std::list<T*>::end(), e ), e );
189 /////////////////// iterator class /////////////////////////////
191 class ePtrList<T>::iterator : public std::list<T*>::iterator
195 iterator(const std_list_T_iterator& Q) : std_list_T_iterator(Q) { }
197 // changed operator for pointer
198 T* operator->() const
200 return *std::list<T*>::iterator::operator->();
205 return *operator->();
213 iterator& operator++()
215 std::list<T*>::iterator::operator++();
219 iterator operator++(int)
221 return std::list<T*>::iterator::operator++(0);
224 iterator& operator--()
226 std::list<T*>::iterator::operator--();
230 iterator operator--(int)
232 return std::list<T*>::iterator::operator--(0);
236 /////////////////// const_iterator class /////////////////////////////
238 class ePtrList<T>::const_iterator : public std::list<T*>::const_iterator
242 const_iterator(const std_list_T_const_iterator& Q) :std_list_T_const_iterator(Q) { }
244 // changed operator for pointer
245 T* operator->() const
247 return *std::list<T*>::const_iterator::operator->();
252 return *operator->();
260 const_iterator& operator++()
262 std::list<T*>::const_iterator::operator++();
266 const_iterator operator++(int)
268 return std::list<T*>::const_iterator::operator++(0);
271 const_iterator& operator--()
273 std::list<T*>::const_iterator::operator--();
277 const_iterator operator--(int)
279 return std::list<T*>::const_iterator::operator--(0);
283 /////////////////// reverse_iterator class /////////////////////////////
285 class ePtrList<T>::reverse_iterator : public std::list<T*>::reverse_iterator
289 reverse_iterator(const std_list_T_reverse_iterator& Q) :std_list_T_reverse_iterator(Q) { }
291 // changed operators for pointer
292 T* operator->() const
294 return *std::list<T*>::reverse_iterator::operator->();
299 return *operator->();
307 reverse_iterator& operator++()
309 std::list<T*>::reverse_iterator::operator++();
313 reverse_iterator operator++(int)
315 return std::list<T*>::reverse_iterator::operator++(0);
318 reverse_iterator& operator--()
320 std::list<T*>::reverse_iterator::operator--();
324 reverse_iterator operator--(int)
326 return std::list<T*>::reverse_iterator::operator--(0);
330 /////////////////// const_reverse_iterator class /////////////////////////////
332 class ePtrList<T>::const_reverse_iterator : public std::list<T*>::const_reverse_iterator
336 const_reverse_iterator(const std_list_T_const_reverse_iterator& Q) :std_list_T_const_reverse_iterator(Q) { }
338 // changed operators for pointer
339 T* operator->() const
341 return *std::list<T*>::const_reverse_iterator::operator->();
346 return *operator->();
354 const_reverse_iterator& operator++()
356 std::list<T*>::const_reverse_iterator::operator++();
360 const_reverse_iterator operator++(int)
362 return std::list<T*>::const_reverse_iterator::operator++(0);
365 const_reverse_iterator& operator--()
367 std::list<T*>::const_reverse_iterator::operator--();
371 const_reverse_iterator operator--(int)
373 return std::list<T*>::const_reverse_iterator::operator--(0);
377 /////////////////// Default Constructor /////////////////////////////
379 ePtrList<T>::ePtrList()
380 :cur(std::list<T*>::begin()), autoDelete(false)
385 /////////////////// Copy Constructor /////////////////////////////
387 ePtrList<T>::ePtrList(const ePtrList& e)
388 :std::list<T*>(e), cur(e.cur), autoDelete( false )
392 eDebug("Warning !! We make a Copy of a non empty ePtrList, with autoDelete enabled"
393 "We disable autoDelete in the new ePtrList !!");
398 /////////////////// ePtrList Destructor /////////////////////////////
400 inline ePtrList<T>::~ePtrList()
402 // if autoDelete is enabled, delete is called for all elements in the list
404 for (std_list_T_iterator it(std::list<T*>::begin()); it != std::list<T*>::end(); it++)
409 /////////////////// ePtrList sort() /////////////////////////
411 inline void ePtrList<T>::sort()
413 // Sorts all items in the list.
414 // The type T must have a operator <.
415 std::list<T*>::sort(ePtrList<T>::less());
418 /////////////////// ePtrList remove(T*) /////////////////////////
420 inline void ePtrList<T>::remove(T* t)
422 // Remove all items that, equals to t, if auto-deletion is enabled, than the list call delete for the removed items
423 // If current is equal to one of the removed items, current is set to the next valid item
424 T_iterator it(std::list<T*>::begin());
426 while (it != std::list<T*>::end())
430 break; // one item is complete removed an deleted
435 while (it != std::list<T*>::end())
437 it = std::list<T*>::erase(it); // remove all other items that equals to t (no delete is called..)
443 /////////////////// ePtrList clear() //////////////////
445 inline void ePtrList<T>::clear()
447 // Remove all items from the list
448 // If auto-deletion is enabled, than the list call delete for all items in the list
449 erase(std::list<T*>::begin(), std::list<T*>::end());
452 /////////////////// ePtrList pop_back() ////////////////////
454 inline void ePtrList<T>::pop_back()
456 // Removes the last item from the list. If the current item ist the last, than the current is set to the new
457 // last item in the list;
458 // The removed item is deleted if auto-deletion is enabled.
462 /////////////////// ePtrList pop_front() ////////////////////
464 inline void ePtrList<T>::pop_front()
466 // Removes the first item from the list. If the current item ist the first, than the current is set to the new
467 // first item in the list;
468 // The removed item is deleted if auto-deletion is enabled.
472 /////////////////// ePtrList push_back(T*) ////////////////////
474 inline void ePtrList<T>::push_back(T* x)
476 // Add a new item at the end of the list.
477 // The current item is set to the last item;
478 std::list<T*>::push_back(x);
482 /////////////////// ePtrList push_front(T*) ////////////////////
484 inline void ePtrList<T>::push_front(T* x)
486 // Add a new item at the begin of the list.
487 // The current item is set to the first item;
488 std::list<T*>::push_front(x);
492 /////////////////// ePtrList take() ////////////////////
494 inline T* ePtrList<T>::take()
496 // Takes the current item out of the list without deleting it (even if auto-deletion is enabled).
497 // Returns a pointer to the item taken out of the list, or null if the index is out of range.
498 // 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.
499 // The current item is set to null if the list becomes empty.
501 cur = std::list<T*>::erase(cur);
505 /////////////////// ePtrList take(T*) ////////////////////
507 inline void ePtrList<T>::take(T* t)
509 // Takes all item with T* out of the list without deleting it (even if auto-deletion is enabled).
510 std::list<T*>::remove(t);
513 /////////////////// ePtrList setCurrent(T*) ////////////////////
515 inline T* ePtrList<T>::setCurrent(const T* t)
517 // Sets the internal current iterator to the first element that equals to t, and returns t when a item is found,
518 // otherwise it returns 0 !
519 for (T_iterator it(std::list<T*>::begin()); it != std::list<T*>::end(); ++it)
529 /////////////////// ePtrList current() ////////////////////
531 inline T* ePtrList<T>::current()
533 // Returns a pointer to the current list item. The current item may be null (implies that the current index is -1).
534 return cur==end() ? 0 : *cur;
537 /////////////////// ePtrList next() ////////////////////
539 inline T* ePtrList<T>::next()
541 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
542 // 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.
552 /////////////////// ePtrList prev() ////////////////////
554 inline T* ePtrList<T>::prev()
556 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
557 // 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.
564 /////////////////// ePtrList first() ////////////////////
566 inline T* ePtrList<T>::first()
568 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
569 return *(cur = begin());
572 /////////////////// ePtrList last() ////////////////////
574 inline T* ePtrList<T>::last()
576 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
577 return *(cur = --end());
580 /////////////////// const ePtrList current() ////////////////////
582 inline const T* ePtrList<T>::current() const
584 // Returns a pointer to the current list item. The current item may be null (implies that the current index is not valid)
585 return cur==end() ? 0 : *cur;
588 /////////////////// const ePtrList next() ////////////////////
590 inline const T* ePtrList<T>::next() const
592 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
593 // 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.
603 /////////////////// const ePtrList prev() ////////////////////
605 inline const T* ePtrList<T>::prev() const
607 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
608 // 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.
615 /////////////////// const ePtrList first() ////////////////////
617 inline const T* ePtrList<T>::first() const
619 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
620 return *(cur = begin());
623 /////////////////// const ePtrList last() ////////////////////
625 inline const T* ePtrList<T>::last() const
627 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
628 return *(cur = --end());
631 ////////////////// struct less //////////////////////////////
633 struct ePtrList<T>::less
635 // operator() is used internal from the list to sort them
636 bool operator() (const T* t1, const T* t2)
642 /////////////////// ePtrList operator bool ////////////////////
644 ePtrList<T>::operator bool()
646 // Returns a bool that contains true, when the list is NOT empty otherwise false
651 bool ePtrList<T>::operator!()
653 // Returns a bool that contains true, when the list is empty otherwise false
658 void ePtrList<T>::setAutoDelete(bool b)
660 // switched autoDelete on or off
661 // if autoDelete is true, than the pointer list controls the heap memory behind the pointer itself
662 // the list calls delete for the item before it removed from the list
667 bool ePtrList<T>::isAutoDelete()
669 // returns a bool that contains the state of autoDelete
674 class eSmartPtrList : public std::list<ePtr<T> >
677 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::iterator std_list_T_iterator; // to remove compiler warnings
678 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::const_iterator std_list_T_const_iterator;
679 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::reverse_iterator std_list_T_reverse_iterator;
680 typedef typename std::list<ePtr<T>, std::allocator<ePtr<T> > >::const_reverse_iterator std_list_T_const_reverse_iterator;
681 typedef typename eSmartPtrList<T>::iterator T_iterator;
682 typedef typename eSmartPtrList<T>::const_iterator T_const_iterator;
683 typedef typename eSmartPtrList<T>::reverse_iterator T_reverse_iterator;
684 typedef typename eSmartPtrList<T>::const_reverse_iterator T_const_reverse_iterator;
688 class const_iterator;
689 class reverse_iterator;
690 class const_reverse_iterator;
693 inline eSmartPtrList();
694 inline eSmartPtrList(const eSmartPtrList&);
695 inline ~eSmartPtrList();
697 // overwritted sort method
700 // changed methods for autodelete and current implementation
701 inline void remove(T* t);
703 inline void pop_back();
704 inline void pop_front();
705 inline void push_back(T*);
706 inline void push_front(T*);
708 // added methods for current implementation
710 // inline void take(T* t);
716 inline T* setCurrent(const T*);
717 inline const T* current() const;
718 inline const T* next() const;
719 inline const T* prev() const;
720 inline const T* first() const;
721 inline const T* last() const;
723 // added operator methods
724 inline operator bool();
725 inline bool operator!();
727 // added methods for autodelete implementation
728 inline void setAutoDelete(bool b);
729 inline bool isAutoDelete();
731 // added compare struct ... to sort
738 iterator eSmartPtrList<T>::begin()
740 // makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
741 return std::list<ePtr<T> >::begin();
744 iterator eSmartPtrList<T>::end()
746 // makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
747 return std::list<ePtr<T> >::end();
750 const_iterator eSmartPtrList<T>::begin() const
752 // makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
753 return std::list<ePtr<T> >::begin();
756 const_iterator eSmartPtrList<T>::end() const
758 // makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
759 return std::list<ePtr<T> >::end();
762 reverse_iterator eSmartPtrList<T>::rbegin()
764 // makes implicit type conversion form std::list::reverse:_iterator to eSmartPtrList::reverse_iterator
765 return std::list<ePtr<T> >::rbegin();
768 reverse_iterator eSmartPtrList<T>::rend()
770 // makes implicit type conversion form std::list::reverse_iterator to eSmartPtrList::reverse_iterator
771 return std::list<ePtr<T> >::rend();
774 const_reverse_iterator eSmartPtrList<T>::rbegin() const
776 // makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
777 return std::list<ePtr<T> >::rbegin();
780 const_reverse_iterator eSmartPtrList<T>::rend() const
782 // makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
783 return std::list<ePtr<T> >::rend();
786 iterator eSmartPtrList<T>::erase(iterator it)
788 // Remove the item it, if auto-deletion is enabled, than the list call delete for this item
789 // If current is equal to the item that was removed, current is set to the next item in the list
790 if (autoDelete && *it)
794 return cur = std::list<ePtr<T> >::erase(it);
796 return std::list<ePtr<T> >::erase(it);
799 iterator eSmartPtrList<T>::erase(iterator from, iterator to)
801 // Remove all items between the to iterators from and to
802 // If auto-deletion is enabled, than the list call delete for all removed items
811 // Returns a iterator that equal to begin() of the list
815 operator const_iterator() const
817 // Returns a const_iterator that equal to begin() of the list
821 operator reverse_iterator()
823 // Returns a reverse_iterator that equal to rbegin() of the list
827 operator const_reverse_iterator() const
829 // Returns a const_reverse_iterator that equal to rbegin() of the list
833 std::vector<T>* getVector()
835 // Creates an vector and copys all elements to this vector
836 // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
837 std::vector<T>* v=new std::vector<T>();
838 v->reserve( size() );
839 for ( std_list_T_iterator it( std::list<ePtr<T> >::begin() ); it != std::list<ePtr<T> >::end(); it++)
840 v->push_back( **it );
845 inline iterator insert_in_order( T* e )
847 // added a new item to the list... in order
848 // returns a iterator to the new item
849 return insert( std::lower_bound( std::list<ePtr<T> >::begin(), std::list<ePtr<T> >::end(), e ), e );
854 /////////////////// iterator class /////////////////////////////
856 class eSmartPtrList<T>::iterator : public std::list<ePtr<T> >::iterator
860 iterator(const std_list_T_iterator& Q) : std_list_T_iterator(Q) { }
862 // changed operator for pointer
863 T* operator->() const
865 return *std::list<ePtr<T> >::iterator::operator->();
870 return *operator->();
878 iterator& operator++()
880 std::list<ePtr<T> >::iterator::operator++();
884 iterator operator++(int)
886 return std::list<ePtr<T> >::iterator::operator++(0);
889 iterator& operator--()
891 std::list<ePtr<T> >::iterator::operator--();
895 iterator operator--(int)
897 return std::list<ePtr<T> >::iterator::operator--(0);
901 /////////////////// const_iterator class /////////////////////////////
903 class eSmartPtrList<T>::const_iterator : public std::list<ePtr<T> >::const_iterator
907 const_iterator(const std_list_T_const_iterator& Q) :std_list_T_const_iterator(Q) { }
909 // changed operator for pointer
910 T* operator->() const
912 return *std::list<ePtr<T> >::const_iterator::operator->();
917 return *operator->();
925 const_iterator& operator++()
927 std::list<ePtr<T> >::const_iterator::operator++();
931 const_iterator operator++(int)
933 return std::list<ePtr<T> >::const_iterator::operator++(0);
936 const_iterator& operator--()
938 std::list<ePtr<T> >::const_iterator::operator--();
942 const_iterator operator--(int)
944 return std::list<ePtr<T> >::const_iterator::operator--(0);
948 /////////////////// reverse_iterator class /////////////////////////////
950 class eSmartPtrList<T>::reverse_iterator : public std::list<ePtr<T> >::reverse_iterator
954 reverse_iterator(const std_list_T_reverse_iterator& Q) :std_list_T_reverse_iterator(Q) { }
956 // changed operators for pointer
957 T* operator->() const
959 return *std::list<ePtr<T> >::reverse_iterator::operator->();
964 return *operator->();
972 reverse_iterator& operator++()
974 std::list<ePtr<T> >::reverse_iterator::operator++();
978 reverse_iterator operator++(int)
980 return std::list<ePtr<T> >::reverse_iterator::operator++(0);
983 reverse_iterator& operator--()
985 std::list<ePtr<T> >::reverse_iterator::operator--();
989 reverse_iterator operator--(int)
991 return std::list<ePtr<T> >::reverse_iterator::operator--(0);
995 /////////////////// const_reverse_iterator class /////////////////////////////
997 class eSmartPtrList<T>::const_reverse_iterator : public std::list<ePtr<T> >::const_reverse_iterator
1001 const_reverse_iterator(const std_list_T_const_reverse_iterator& Q) :std_list_T_const_reverse_iterator(Q) { }
1003 // changed operators for pointer
1004 T* operator->() const
1006 return *std::list<ePtr<T> >::const_reverse_iterator::operator->();
1011 return *operator->();
1016 return operator->();
1019 const_reverse_iterator& operator++()
1021 std::list<ePtr<T> >::const_reverse_iterator::operator++();
1025 const_reverse_iterator operator++(int)
1027 return std::list<ePtr<T> >::const_reverse_iterator::operator++(0);
1030 const_reverse_iterator& operator--()
1032 std::list<ePtr<T> >::const_reverse_iterator::operator--();
1036 const_reverse_iterator operator--(int)
1038 return std::list<ePtr<T> >::const_reverse_iterator::operator--(0);
1042 /////////////////// Default Constructor /////////////////////////////
1044 eSmartPtrList<T>::eSmartPtrList()
1045 :cur(std::list<ePtr<T> >::begin()), autoDelete(false)
1050 /////////////////// Copy Constructor /////////////////////////////
1052 eSmartPtrList<T>::eSmartPtrList(const eSmartPtrList& e)
1053 :std::list<ePtr<T> >(e), cur(e.cur), autoDelete( false )
1057 eDebug("Warning !! We make a Copy of a non empty eSmartPtrList, with autoDelete enabled"
1058 "We disable autoDelete in the new eSmartPtrList !!");
1063 /////////////////// eSmartPtrList Destructor /////////////////////////////
1065 inline eSmartPtrList<T>::~eSmartPtrList()
1067 // if autoDelete is enabled, delete is called for all elements in the list
1069 for (std_list_T_iterator it(std::list<ePtr<T> >::begin()); it != std::list<ePtr<T> >::end(); it++)
1074 /////////////////// eSmartPtrList sort() /////////////////////////
1076 inline void eSmartPtrList<T>::sort()
1078 // Sorts all items in the list.
1079 // The type T must have a operator <.
1080 std::list<ePtr<T> >::sort(eSmartPtrList<T>::less());
1083 /////////////////// eSmartPtrList remove(T*) /////////////////////////
1085 inline void eSmartPtrList<T>::remove(T* t)
1087 // Remove all items that, equals to t, if auto-deletion is enabled, than the list call delete for the removed items
1088 // If current is equal to one of the removed items, current is set to the next valid item
1089 T_iterator it(std::list<ePtr<T> >::begin());
1091 while (it != std::list<ePtr<T> >::end())
1095 break; // one item is complete removed an deleted
1100 while (it != std::list<ePtr<T> >::end())
1102 it = std::list<ePtr<T> >::erase(it); // remove all other items that equals to t (no delete is called..)
1108 /////////////////// eSmartPtrList clear() //////////////////
1110 inline void eSmartPtrList<T>::clear()
1112 // Remove all items from the list
1113 // If auto-deletion is enabled, than the list call delete for all items in the list
1114 erase(std::list<ePtr<T> >::begin(), std::list<ePtr<T> >::end());
1117 /////////////////// eSmartPtrList pop_back() ////////////////////
1119 inline void eSmartPtrList<T>::pop_back()
1121 // Removes the last item from the list. If the current item ist the last, than the current is set to the new
1122 // last item in the list;
1123 // The removed item is deleted if auto-deletion is enabled.
1127 /////////////////// eSmartPtrList pop_front() ////////////////////
1129 inline void eSmartPtrList<T>::pop_front()
1131 // Removes the first item from the list. If the current item ist the first, than the current is set to the new
1132 // first item in the list;
1133 // The removed item is deleted if auto-deletion is enabled.
1137 /////////////////// eSmartPtrList push_back(T*) ////////////////////
1139 inline void eSmartPtrList<T>::push_back(T* x)
1141 // Add a new item at the end of the list.
1142 // The current item is set to the last item;
1143 std::list<ePtr<T> >::push_back(x);
1147 /////////////////// eSmartPtrList push_front(T*) ////////////////////
1149 inline void eSmartPtrList<T>::push_front(T* x)
1151 // Add a new item at the begin of the list.
1152 // The current item is set to the first item;
1153 std::list<ePtr<T> >::push_front(x);
1157 /////////////////// eSmartPtrList take() ////////////////////
1158 //template <class T>
1159 //inline T* eSmartPtrList<T>::take()
1161 //// Takes the current item out of the list without deleting it (even if auto-deletion is enabled).
1162 //// Returns a pointer to the item taken out of the list, or null if the index is out of range.
1163 //// 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.
1164 //// The current item is set to null if the list becomes empty.
1166 // cur = std::list<T*>::erase(cur);
1170 /////////////////// eSmartPtrList take(T*) ////////////////////
1171 //template <class T>
1172 //inline void eSmartPtrList<T>::take(T* t)
1174 //// Takes all item with T* out of the list without deleting it (even if auto-deletion is enabled).
1175 // std::list<T*>::remove(t);
1178 /////////////////// eSmartPtrList setCurrent(T*) ////////////////////
1180 inline T* eSmartPtrList<T>::setCurrent(const T* t)
1182 // Sets the internal current iterator to the first element that equals to t, and returns t when a item is found,
1183 // otherwise it returns 0 !
1184 for (T_iterator it(std::list<ePtr<T> >::begin()); it != std::list<ePtr<T> >::end(); ++it)
1194 /////////////////// eSmartPtrList current() ////////////////////
1196 inline T* eSmartPtrList<T>::current()
1198 // Returns a pointer to the current list item. The current item may be null (implies that the current index is -1).
1199 return cur==end() ? 0 : *cur;
1202 /////////////////// eSmartPtrList next() ////////////////////
1204 inline T* eSmartPtrList<T>::next()
1206 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
1207 // 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.
1217 /////////////////// eSmartPtrList prev() ////////////////////
1219 inline T* eSmartPtrList<T>::prev()
1221 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
1222 // 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.
1229 /////////////////// eSmartPtrList first() ////////////////////
1231 inline T* eSmartPtrList<T>::first()
1233 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
1234 return *(cur = begin());
1237 /////////////////// eSmartPtrList last() ////////////////////
1239 inline T* eSmartPtrList<T>::last()
1241 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
1242 return *(cur = --end());
1245 /////////////////// const eSmartPtrList current() ////////////////////
1247 inline const T* eSmartPtrList<T>::current() const
1249 // Returns a pointer to the current list item. The current item may be null (implies that the current index is not valid)
1250 return cur==end() ? 0 : *cur;
1253 /////////////////// const eSmartPtrList next() ////////////////////
1255 inline const T* eSmartPtrList<T>::next() const
1257 // Returns a pointer to the item succeeding the current item. Returns null if the current items is null or equal to the last item.
1258 // 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.
1268 /////////////////// const eSmartPtrList prev() ////////////////////
1270 inline const T* eSmartPtrList<T>::prev() const
1272 // Returns a pointer to the item preceding the current item. Returns null if the current items is null or equal to the first item.
1273 // 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.
1280 /////////////////// const eSmartPtrList first() ////////////////////
1282 inline const T* eSmartPtrList<T>::first() const
1284 // Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty.
1285 return *(cur = begin());
1288 /////////////////// const eSmartPtrList last() ////////////////////
1290 inline const T* eSmartPtrList<T>::last() const
1292 // Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty.
1293 return *(cur = --end());
1296 ////////////////// struct less //////////////////////////////
1298 struct eSmartPtrList<T>::less
1300 // operator() is used internal from the list to sort them
1301 bool operator() (const T* t1, const T* t2)
1307 /////////////////// eSmartPtrList operator bool ////////////////////
1309 eSmartPtrList<T>::operator bool()
1311 // Returns a bool that contains true, when the list is NOT empty otherwise false
1316 bool eSmartPtrList<T>::operator!()
1318 // Returns a bool that contains true, when the list is empty otherwise false
1323 void eSmartPtrList<T>::setAutoDelete(bool b)
1325 // switched autoDelete on or off
1326 // if autoDelete is true, than the pointer list controls the heap memory behind the pointer itself
1327 // the list calls delete for the item before it removed from the list
1332 bool eSmartPtrList<T>::isAutoDelete()
1334 // returns a bool that contains the state of autoDelete
1338 #endif // _E_PTRLIST