ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkOneWayEquivalencyTable.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 itkOneWayEquivalencyTable_h
19 #define itkOneWayEquivalencyTable_h
20 
21 
22 #include "itkProcessObject.h"
23 #include "itksys/hash_map.hxx"
24 #include "ITKWatershedsExport.h"
25 
26 namespace itk
27 {
46 class ITKWatersheds_EXPORT OneWayEquivalencyTable:public DataObject
47 {
48 public:
54  itkNewMacro(Self);
57 
59  typedef itksys::hash_map< unsigned long, unsigned long,
60  itksys::hash< unsigned long > > HashTableType;
61 
62  typedef HashTableType::iterator Iterator;
63  typedef HashTableType::const_iterator ConstIterator;
64  typedef HashTableType::value_type ValueType;
65 
69  void Flatten();
70 
78  bool Add(unsigned long a, unsigned long b);
79 
83  unsigned long Lookup(const unsigned long a) const
84  {
85  ConstIterator result = m_HashMap.find(a);
86 
87  if ( result == m_HashMap.end() ) { return a; }
88  else { return ( *result ).second; }
89  }
90 
95  unsigned long RecursiveLookup(const unsigned long a) const;
96 
99  bool IsEntry(const unsigned long a) const
100  {
101  if ( m_HashMap.find(a) == m_HashMap.end() ) { return false; }
102  else { return true; }
103  }
105 
107  void Erase(const unsigned long a)
108  { m_HashMap.erase(a); }
109 
111  void Clear()
112  { m_HashMap.clear(); }
113 
115  bool Empty() const
116  { return m_HashMap.empty(); }
117 
120  Iterator Begin() { return m_HashMap.begin(); }
121 
124  Iterator End() { return m_HashMap.end(); }
125 
127  // void PrintHashTable();
128 
129 protected:
132  OneWayEquivalencyTable(const Self &); // purposely not implemented
133  void operator=(const Self &); // purposely not implemented
134 
135  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
136 
138 };
139 } // end namespace itk
140 
141 #endif
unsigned long Lookup(const unsigned long a) const
HashTableType::const_iterator ConstIterator
bool IsEntry(const unsigned long a) const
Hash table to manage integral label equivalencies that are order dependent.
itksys::hash_map< unsigned long, unsigned long, itksys::hash< unsigned long > > HashTableType
void Erase(const unsigned long a)
SmartPointer< const Self > ConstPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
HashTableType::value_type ValueType
Base class for all data objects in ITK.