| Data Structures and Algorithms 
with Object-Oriented Design Patterns in C#           | 
Of all the C# types, the so-called integral types are the simplest to hash into integers. The integral data types are byte, sbyte, short, ushort, int, uint, long, ulong, and char. Since the underlying representation of such data types can be viewed as an integer, the hash function is trivial. A suitable function f for an integral data type is the identity function:
 
Program  completes the definition
of the ComparableInt32 wrapper class
introduced in Program
 completes the definition
of the ComparableInt32 wrapper class
introduced in Program  .
In this case, the GetHashCode method simply returns
the value of the boxed Int32 object.
Clearly, the running time of of the GetHashCode method is O(1).
.
In this case, the GetHashCode method simply returns
the value of the boxed Int32 object.
Clearly, the running time of of the GetHashCode method is O(1).
   
Program: ComparableInt32 class GetHashCode method.
 
  
  
  
  
 
 Copyright © 2001 by Bruno R. Preiss, P.Eng.  All rights reserved.
Copyright © 2001 by Bruno R. Preiss, P.Eng.  All rights reserved.