00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkEquivalencyTable_h
00018 #define __itkEquivalencyTable_h
00019
00020 #if defined(_MSC_VER)
00021 #pragma warning ( disable : 4786 )
00022 #endif
00023
00024 #include "itkObjectFactory.h"
00025 #include "itkDataObject.h"
00026 #include "itkProcessObject.h"
00027 #include "itk_hash_map.h"
00028
00029 namespace itk
00030 {
00047 class ITKCommon_EXPORT EquivalencyTable : public DataObject
00048 {
00049 public:
00051 typedef EquivalencyTable Self;
00052 typedef DataObject Superclass;
00053 typedef SmartPointer<Self> Pointer;
00054 typedef SmartPointer<const Self> ConstPointer;
00055 itkNewMacro(Self);
00056 itkTypeMacro(EquivalencyTable, DataObject);
00057
00059 typedef itk::hash_map<unsigned long, unsigned long,
00060 itk::hash<unsigned long> > HashTableType;
00061 typedef HashTableType::iterator Iterator;
00062 typedef HashTableType::const_iterator ConstIterator;
00063 typedef HashTableType::value_type ValueType;
00064
00068 void Flatten();
00069
00076 bool Add(unsigned long a, unsigned long b);
00077
00085 bool AddAndFlatten(unsigned long a, unsigned long b);
00086
00090 unsigned long Lookup(const unsigned long a) const
00091 {
00092 ConstIterator result = m_HashMap.find(a);
00093 if ( result == m_HashMap.end() ) return a;
00094 else return (*result).second;
00095 }
00096
00101 unsigned long RecursiveLookup(const unsigned a) const;
00102
00105 bool IsEntry(const unsigned long a) const
00106 {
00107 if ( m_HashMap.find(a) == m_HashMap.end() ) return false;
00108 else return true;
00109 }
00110
00112 void Erase(const unsigned long a)
00113 { m_HashMap.erase(a); }
00114
00116 void Clear()
00117 { m_HashMap.clear(); }
00118
00120 bool Empty() const
00121 { return m_HashMap.empty(); }
00122
00124 HashTableType::size_type Size() const
00125 { return m_HashMap.size(); }
00126
00129 Iterator Begin() { return m_HashMap.begin(); }
00130
00133 Iterator End() { return m_HashMap.end(); }
00134
00136
00137 protected:
00138 EquivalencyTable() {}
00139 virtual ~EquivalencyTable() {}
00140 EquivalencyTable(const Self&);
00141 void operator=(const Self&);
00142 void PrintSelf(std::ostream& os, Indent indent) const;
00143
00144 HashTableType m_HashMap;
00145 };
00146
00147 }
00148
00149 #endif
00150