00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://ogre.sourceforge.net/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #ifndef __IteratorWrappers_H__ 00026 #define __IteratorWrappers_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 00030 namespace Ogre { 00031 00046 template <class T> 00047 class VectorIterator 00048 { 00049 private: 00050 typename T::iterator mCurrent; 00051 typename T::iterator mEnd; 00052 public: 00053 VectorIterator(); 00058 VectorIterator(typename T::iterator start, typename T::iterator end) 00059 : mCurrent(start), mEnd(end) 00060 { 00061 } 00062 00064 bool hasMoreElements(void) 00065 { 00066 return mCurrent != mEnd; 00067 } 00068 00070 typename T::value_type getNext(void) 00071 { 00072 return *mCurrent++; 00073 } 00075 typename T::value_type peekNext(void) 00076 { 00077 return *mCurrent; 00078 } 00079 00080 00081 00082 }; 00083 00098 template <class T> 00099 class MapIterator 00100 { 00101 private: 00102 typename T::iterator mCurrent; 00103 typename T::iterator mEnd; 00104 public: 00105 MapIterator(); 00110 MapIterator(typename T::iterator start, typename T::iterator end) 00111 : mCurrent(start), mEnd(end) 00112 { 00113 } 00114 00116 bool hasMoreElements(void) 00117 { 00118 return mCurrent != mEnd; 00119 } 00120 00122 typename T::mapped_type getNext(void) 00123 { 00124 return (mCurrent++)->second; 00125 } 00127 typename T::mapped_type peekNextValue(void) 00128 { 00129 return mCurrent->second; 00130 } 00132 typename T::key_type peekNextKey(void) 00133 { 00134 return mCurrent->first; 00135 } 00137 MapIterator<T> & operator=( MapIterator<T> &rhs ) 00138 { 00139 mCurrent = rhs.mCurrent; 00140 mEnd = rhs.mEnd; 00141 return *this; 00142 } 00143 00144 00145 00146 }; 00147 00148 } 00149 #endif
Copyright © 2002 by The OGRE Team