Orfeo Toolbox  4.0
itkEquivalencyTable.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkEquivalencyTable_h
19 #define __itkEquivalencyTable_h
20 
21 
22 #include "itkProcessObject.h"
23 #include "itksys/hash_map.hxx"
24 
25 namespace itk
26 {
44 class ITKCommon_EXPORT EquivalencyTable:public DataObject
45 {
46 public:
52  itkNewMacro(Self);
53  itkTypeMacro(EquivalencyTable, DataObject);
54 
56  typedef itksys::hash_map< unsigned long, unsigned long,
57  itksys::hash< unsigned long > > HashTableType;
58 
59  typedef HashTableType::iterator Iterator;
60  typedef HashTableType::const_iterator ConstIterator;
61  typedef HashTableType::value_type ValueType;
62 
66  void Flatten();
67 
74  bool Add(unsigned long a, unsigned long b);
75 
83  bool AddAndFlatten(unsigned long a, unsigned long b);
84 
88  unsigned long Lookup(const unsigned long a) const
89  {
90  ConstIterator result = m_HashMap.find(a);
91 
92  if ( result == m_HashMap.end() ) { return a; }
93  else { return ( *result ).second; }
94  }
95 
100  unsigned long RecursiveLookup(const unsigned long a) const;
101 
104  bool IsEntry(const unsigned long a) const
105  {
106  if ( m_HashMap.find(a) == m_HashMap.end() ) { return false; }
107  else { return true; }
108  }
109 
111  void Erase(const unsigned long a)
112  { m_HashMap.erase(a); }
113 
115  void Clear()
116  { m_HashMap.clear(); }
117 
119  bool Empty() const
120  { return m_HashMap.empty(); }
121 
123  HashTableType::size_type Size() const
124  { return m_HashMap.size(); }
125 
128  Iterator Begin() { return m_HashMap.begin(); }
129 
132  Iterator End() { return m_HashMap.end(); }
133 
135  // void PrintHashTable();
136 
137 protected:
139  virtual ~EquivalencyTable() {}
140  EquivalencyTable(const Self &); // purposely not implemented
141  void operator=(const Self &); // purposely not implemented
142 
143  void PrintSelf(std::ostream & os, Indent indent) const;
144 
146 };
147 } // end namespace itk
148 
149 #endif

Generated at Sat Mar 8 2014 14:34:40 for Orfeo Toolbox with doxygen 1.8.3.1