#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Container/Array/Array1dIter.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_ARRAY1DITER_HEADER #define RAVL_ARRAY1DITER_HEADER 1 ////////////////////////////////////////////////////// //! rcsid="$Id: Array1dIter.hh,v 1.4 2002/04/29 18:13:06 craftit Exp $" //! docentry="Ravl.Core.Arrays.1D" //! file="Ravl/Core/Container/Array/Array1dIter.hh" //! lib=RavlCore //! author="Charles Galambos" //! userlevel=Normal //! date="24/08/99" //! example=exArray1.cc #include "Ravl/Array1d.hh" #include "Ravl/BfAccIter.hh" namespace RavlN { //! userlevel=Normal //: Array1dC iterator. template class Array1dIterC : public BufferAccessIterC { public: Array1dIterC() {} //: Default constructor. Array1dIterC(const Array1dC &arr) : BufferAccessIterC(arr), dat(arr) {} //: Constructor. Array1dIterC(const Array1dC &arr,const IndexRangeC & range) : dat(arr,range) { BufferAccessIterC::operator=(dat); } //: Iterate through a sub-range. inline void First() { BufferAccessIterC::First(dat); } //: Goto first element in the array. inline void First(Array1dC &arr) { dat = arr; BufferAccessIterC::First(dat); } //: Goto first element in the array. bool IsFirst() const { return at == &dat[dat.IMin()]; } //: Test if this is the first element in the range. // Note,this is slower than IsElm(). const Array1dIterC &operator=(const Array1dC &arr) { dat = arr; First(); return *this; } //: Assignment. IndexC Index() const { return IndexC((IntT)( at - dat.ReferenceElm())); } //: Calculate the index we're at. protected: Array1dC dat; }; } #endif