ITK  4.6.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 
25 namespace itk
26 {
46 {
47 public:
53  itkNewMacro(Self);
56 
58  typedef itksys::hash_map< unsigned long, unsigned long,
59  itksys::hash< unsigned long > > HashTableType;
60 
61  typedef HashTableType::iterator Iterator;
62  typedef HashTableType::const_iterator ConstIterator;
63  typedef HashTableType::value_type ValueType;
64 
68  void Flatten();
69 
77  bool Add(unsigned long a, unsigned long b);
78 
82  unsigned long Lookup(const unsigned long a) const
83  {
84  ConstIterator result = m_HashMap.find(a);
85 
86  if ( result == m_HashMap.end() ) { return a; }
87  else { return ( *result ).second; }
88  }
89 
94  unsigned long RecursiveLookup(const unsigned long a) const;
95 
98  bool IsEntry(const unsigned long a) const
99  {
100  if ( m_HashMap.find(a) == m_HashMap.end() ) { return false; }
101  else { return true; }
102  }
104 
106  void Erase(const unsigned long a)
107  { m_HashMap.erase(a); }
108 
110  void Clear()
111  { m_HashMap.clear(); }
112 
114  bool Empty() const
115  { return m_HashMap.empty(); }
116 
119  Iterator Begin() { return m_HashMap.begin(); }
120 
123  Iterator End() { return m_HashMap.end(); }
124 
126  // void PrintHashTable();
127 
128 protected:
131  OneWayEquivalencyTable(const Self &); // purposely not implemented
132  void operator=(const Self &); // purposely not implemented
133 
134  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
135 
137 };
138 } // end namespace itk
139 
140 #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
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
void Erase(const unsigned long a)
SmartPointer< const Self > ConstPointer
bool Add(unsigned long a, unsigned long b)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void operator=(const Self &)
unsigned long RecursiveLookup(const unsigned long a) const
HashTableType::value_type ValueType
Base class for all data objects in ITK.