00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkOneWayEquivalencyTable_h
00018 #define __itkOneWayEquivalencyTable_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 OneWayEquivalencyTable : public DataObject
00048 {
00049 public:
00051 typedef OneWayEquivalencyTable Self;
00052 typedef DataObject Superclass;
00053 typedef SmartPointer<Self> Pointer;
00054 typedef SmartPointer<const Self> ConstPointer;
00055 itkNewMacro(Self);
00056 itkTypeMacro(OneWayEquivalencyTable, DataObject);
00058
00060 typedef itk::hash_map<unsigned long, unsigned long,
00061 itk::hash<unsigned long> > HashTableType;
00062 typedef HashTableType::iterator Iterator;
00063 typedef HashTableType::const_iterator ConstIterator;
00064 typedef HashTableType::value_type ValueType;
00065
00069 void Flatten();
00070
00078 bool Add(unsigned long a, unsigned long b);
00079
00083 unsigned long Lookup(const unsigned long a) const
00084 {
00085 ConstIterator result = m_HashMap.find(a);
00086 if ( result == m_HashMap.end() ) return a;
00087 else return (*result).second;
00088 }
00090
00095 unsigned long RecursiveLookup(const unsigned a) const;
00096
00099 bool IsEntry(const unsigned long a) const
00100 {
00101 if ( m_HashMap.find(a) == m_HashMap.end() ) return false;
00102 else return true;
00103 }
00105
00107 void Erase(const unsigned long a)
00108 { m_HashMap.erase(a); }
00109
00111 void Clear()
00112 { m_HashMap.clear(); }
00113
00115 bool Empty() const
00116 { return m_HashMap.empty(); }
00117
00120 Iterator Begin() { return m_HashMap.begin(); }
00121
00124 Iterator End() { return m_HashMap.end(); }
00125
00127
00128
00129 protected:
00130 OneWayEquivalencyTable() {}
00131 virtual ~OneWayEquivalencyTable() {}
00132 OneWayEquivalencyTable(const Self&);
00133 void operator=(const Self&);
00134 void PrintSelf(std::ostream& os, Indent indent) const;
00135
00136 HashTableType m_HashMap;
00137 };
00138
00139 }
00140
00141 #endif
00142
00143