Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkEquivalencyTable.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkEquivalencyTable.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/12/23 17:59:28 $
00007   Version:   $Revision: 1.16 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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);
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 
00077   bool Add(unsigned long a, unsigned long b);
00078 
00086   bool AddAndFlatten(unsigned long a, unsigned long b);
00087 
00091   unsigned long Lookup(const unsigned long a) const
00092     {
00093     ConstIterator result = m_HashMap.find(a);
00094     if ( result == m_HashMap.end() ) return a;
00095     else return (*result).second;
00096     }
00098 
00103   unsigned long RecursiveLookup(const unsigned long a) const;
00104 
00107   bool IsEntry(const unsigned long a) const
00108     {
00109     if ( m_HashMap.find(a) == m_HashMap.end() ) return false;
00110     else return true;
00111     }
00113 
00115   void Erase(const unsigned long a)
00116     {  m_HashMap.erase(a); }
00117 
00119   void Clear()
00120     {  m_HashMap.clear();    }
00121 
00123   bool Empty() const
00124     { return m_HashMap.empty();    }
00125 
00127   HashTableType::size_type Size() const
00128     { return m_HashMap.size(); }
00129 
00132   Iterator Begin() { return m_HashMap.begin(); }
00133 
00136   Iterator End()   { return m_HashMap.end();   }
00137 
00139   //  void PrintHashTable();
00140 protected:
00141   EquivalencyTable()  {}
00142   virtual ~EquivalencyTable() {}
00143   EquivalencyTable(const Self&); // purposely not implemented
00144   void operator=(const Self&); // purposely not implemented
00145   void PrintSelf(std::ostream& os, Indent indent) const;
00147 
00148   HashTableType m_HashMap;
00149 };
00150 
00151 }// end namespace itk
00152 
00153 #endif
00154 

Generated at Tue Jul 29 19:51:31 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000