#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Container/SArray/SArr1Iter.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_SARR1ITER_HEADER #define RAVL_SARR1ITER_HEADER 1 /////////////////////////////////////////////////// //! docentry="Ravl.Core.Arrays.1D" //! rcsid="$Id: SArr1Iter.hh,v 1.4 2002/05/21 14:46:11 craftit Exp $" //! file="Ravl/Core/Container/SArray/SArr1Iter.hh" //! lib=RavlCore //! author="Charles Galambos" //! date="10/09/1998" //! userlevel=Advanced #include "Ravl/SArray1d.hh" #include "Ravl/Assert.hh" #include "Ravl/BfAccIter.hh" namespace RavlN { //: SArray1d iterator. // Fast simple array iterator. template class SArray1dIterC : public BufferAccessIterC { public: SArray1dIterC() {} //: Default constructor. SArray1dIterC(const SArray1dC &arr); //: Constructor. SArray1dIterC(const SArray1dC &arr,UIntT maxInd); //: Constructor. // only iterate first maxInd items, maxInd must be withing the array bounds. const SArray1dIterC &operator=(SArray1dC &arr); //: Assignment to an array. inline void First() { BufferAccessIterC::First((SizeBufferAccessC &)arr); } //: Goto first element in array. SArray1dC &Array() { return arr; } //: Access array. IndexC Index() const { return (IntT) (&Data() - &arr[0]); } //: Get current index. // This is a little slow. bool IsFirst() const { return at == &arr[0]; } //: Test if this is the first element in the range. // Note,this is slower than IsElm(). private: SArray1dC arr; }; /////////////////////////////////////////// template SArray1dIterC::SArray1dIterC(const SArray1dC &narr) : arr(narr) { BufferAccessIterC::First( arr); } template SArray1dIterC::SArray1dIterC(const SArray1dC &narr,UIntT maxInd) : arr(narr) { BufferAccessIterC::First(SizeBufferAccessC(arr,maxInd)); } template const SArray1dIterC & SArray1dIterC::operator=(SArray1dC &narr) { arr = narr; First(); return *this; } } #endif