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

itkOneWayEquivalencyTable.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkOneWayEquivalencyTable.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/12/23 17:59:29 $
00007   Version:   $Revision: 1.13 $
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 __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 long 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   //  void PrintHashTable();
00128 
00129 protected:
00130   OneWayEquivalencyTable()  {}
00131   virtual ~OneWayEquivalencyTable() {}
00132   OneWayEquivalencyTable(const Self&); // purposely not implemented
00133   void operator=(const Self&); // purposely not implemented
00134   void PrintSelf(std::ostream& os, Indent indent) const;
00135 
00136   HashTableType m_HashMap;
00137 };
00138 
00139 }// end namespace itk
00140 
00141 #endif
00142 
00143 

Generated at Wed Nov 5 23:16:37 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000