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

itkStructHashFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkStructHashFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-12 17:26:21 $
00007   Version:   $Revision: 1.7 $
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 __itkStructHashFunction_h
00018 #define __itkStructHashFunction_h
00019 
00020 namespace itk
00021 {
00022 
00035 template< class TInput >
00036 class ITK_EXPORT StructHashFunction
00037 {
00038 public:
00039 
00041   typedef StructHashFunction Self;
00042 
00044   typedef TInput InputType;
00045 
00046   unsigned int operator()( const InputType& key ) const;
00047 
00048 };
00049 
00050 template< class TInput >
00051 inline unsigned int
00052 StructHashFunction< TInput >
00053 ::operator()( const InputType& key ) const
00054 {
00055   ::size_t len = sizeof( InputType );
00056   const char* p = reinterpret_cast< const char* >( &key );
00057   unsigned int hash = 0;
00058   while( len-- )
00059     {
00060     hash = hash * 65 + *p++;
00061     }
00062   hash += (hash >> 5);
00063   return hash;
00064 }
00065 
00066 }
00067 
00068 #endif  // ndef itkStructHashFunction_h
00069 

Generated at Mon Jul 12 2010 19:59:39 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000