#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Container/Misc/BinList.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 RAVLBINLIST_HEADER #define RAVLBINLIST_HEADER 1 /////////////////////////////////////////////////////////////// //! file="Ravl/Core/Container/Misc/BinList.hh" //! userlevel=Normal //! author="Charles Galambos" //! date="11/2/97" //! docentry="Ravl.Core.Misc" //! rcsid="$Id: BinList.hh,v 1.3 2002/01/31 14:55:29 craftit Exp $" //! lib=RavlCore #include "Ravl/BinTable.hh" #include "Ravl/BinIter.hh" #include "Ravl/DList.hh" namespace RavlN { template class BinListC; template ostream &operator<<(ostream &s,const BinListC &); template istream &operator>>(istream &s,BinListC &); //: Binned table of lists. // SMALL OBJECT

// This is simplified the creation of tables with lists in each of the bins. template class BinListC { public: BinListC(const IT &BinSize ) : table(BinSize) {} //: Constructor. inline void Insert(const IT &Key,const BT &Data) { table[Key].InsLast(Data); } //: Insert into table. inline DListC &ListBin(const IT &Key) { return table[Key]; } //: List items in same bin as key. inline void Empty(); //: Empty all bins. inline DListC &operator[](const IT &Key) { return table[Key]; } //: Array access to lists. inline DListC &Bin(const DIT &Key) { return table.Bin(Key); } //: Direct access to bin, use result of BinKey(...). DListC *GetBin(const IT &Pnt) { return table.GetBin(Pnt); } //: See if bins present. inline BinIterC > Iter() { return BinIterC >(table); } //: Create an iterator. inline DIT BinKey(const IT &Oth) const { return table.Scale(Oth); } //: Descritise a point. inline IT BinSize() const { return table.BinSize(); } //: Get size of bins. inline IT BinCentre(const IT &at) const { return table.BinCentre(at); } //: Get centre of bin containing point at. void SetBinSize(const IT &nBinSize) { table.SetBinSize(nBinSize); } //: Set the bin size. // NB. The table MUST be empty. protected: BinTableC > table; #if !defined(__sgi__) && !defined(VISUAL_CPP) friend ostream &operator<< <>(ostream &s,const BinListC &); friend istream &operator>> <>(istream &s,BinListC &); #else friend ostream &operator<<(ostream &s,const BinListC &); friend istream &operator>>(istream &s,BinListC &); #endif }; /////////////////////////////////////// template inline void BinListC::Empty() { for(BinIterC > It(table);It.IsElm();It.Next()) { DListC Lst = It.Data(); Lst.Empty(); } } template ostream &operator<<(ostream &s,const BinListC &tab) { s << tab.table; return s; } //: Write bin list to a stream. template istream &operator>>(istream &s,BinListC &tab) { s >> tab.table; return s; } //: Read bin list from a stream. } #endif