00001 // This is oxl/mvl/PairMatchMultiIterator.h 00002 #ifndef PairMatchMultiIterator_h_ 00003 #define PairMatchMultiIterator_h_ 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // \brief Iterator for PairMatchMulti 00010 // 00011 // PairMatchMultiIterator is a helper class that iterates through 00012 // a set of matches in a PairMatchMulti. 00013 // 00014 // \author 00015 // Andrew W. Fitzgibbon, Oxford RRG, 17 Sep 96 00016 //----------------------------------------------------------------------------- 00017 00018 #include <vcl_functional.h> 00019 #include <vcl_map.h> 00020 #include <vcl_cstdlib.h> // for vcl_abort() 00021 class PairMatchMulti; 00022 00023 // conceptually a list of tuples (index1, index2, strength) 00024 class vcl_multimap_uint_uint : public vcl_multimap<unsigned,unsigned, vcl_less<unsigned> > 00025 { 00026 typedef vcl_multimap<unsigned, unsigned, vcl_less<unsigned> > base; 00027 public: 00028 iterator insert(unsigned int key, unsigned int value); 00029 void clear(); 00030 }; 00031 00032 class PairMatchMultiIterator 00033 { 00034 VCL_SAFE_BOOL_DEFINE; 00035 vcl_multimap_uint_uint::const_iterator first_; 00036 vcl_multimap_uint_uint::const_iterator last_; 00037 public: 00038 //: Construct a PairMatchMultiIterator from two multimap iterators 00039 PairMatchMultiIterator(const vcl_multimap_uint_uint::iterator& first, 00040 const vcl_multimap_uint_uint::iterator& last): 00041 first_(first), 00042 last_(last) 00043 { 00044 } 00045 00046 //: Construct a PairMatchMultiIterator which will scan all matches in a PairMatchMulti 00047 PairMatchMultiIterator(PairMatchMulti const& pmm); 00048 00049 //: Return true if the iterator is still valid. 00050 operator safe_bool () const 00051 { return (first_ != last_)? VCL_SAFE_BOOL_TRUE : 0; } 00052 00053 //: Return false if the iterator is still valid. 00054 bool operator!() const 00055 { return (first_ != last_)? false : true; } 00056 00057 //: Advance to the next match. 00058 PairMatchMultiIterator& operator ++ (/*prefix*/) { ++first_; return *this; } 00059 00060 //: Return the first component of the match pointed to by the iterator. 00061 int get_i1() const { return (*first_).first; } 00062 00063 //: Return the second component of the match pointed to by the iterator. 00064 int get_i2() const { return (*first_).second; } 00065 00066 private: 00067 PairMatchMultiIterator operator++ (int /*postfix*/) { vcl_abort(); return *this; } 00068 }; 00069 00070 #endif // PairMatchMultiIterator_h_