00001 // Package : omniEvents 00002 // ErasableIterator.h Created : 2003/12/04 00003 // Author : Alex Tingle 00004 // 00005 // Copyright (C) 2003 Alex Tingle. 00006 // 00007 // This file is part of the omniEvents application. 00008 // 00009 // omniEvents is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // omniEvents is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 00040 template <class T> 00041 class ErasableIterator 00042 { 00043 private: 00044 typename T::iterator _curr; 00045 typename T::iterator _next; 00046 typename T::iterator _end; 00047 00048 public: 00049 ErasableIterator(T& t):_curr(t.begin()),_next(),_end(t.end()) 00050 { 00051 // pass 00052 } 00053 inline bool more() 00054 { 00055 if(_curr==_end) 00056 return false; 00057 _next=_curr; 00058 ++_next; 00059 return true; 00060 } 00061 inline void next() 00062 { 00063 _curr=_next; 00064 } 00065 inline operator typename T::iterator&() 00066 { 00067 return _curr; 00068 } 00069 inline typename T::reference operator*() 00070 { 00071 return *_curr; 00072 } 00073 inline typename T::pointer operator->() 00074 { 00075 return &(*_curr); 00076 } 00077 };