summaryrefslogtreecommitdiff
path: root/inc/Standard_Size.hxx
blob: ddb9228e6bf683c89fd55e9308fa84c48a3d0cd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// File:      Standard_Size.hxx
// Created:   22.08.06 19:14:29
// Author:    Alexander GRIGORIEV
// Copyright: Open Cascade 2006


#ifndef _Standard_Size_HeaderFile
#define _Standard_Size_HeaderFile

// msv 26.05.2009: add HashCode and IsEqual functions

// ------------------------------------------------------------------
// Hascode : Computes a hashcoding value for a given value
// ------------------------------------------------------------------
inline Standard_Integer HashCode(const Standard_Size Val,
                                 const Standard_Integer Upper)
{
  Standard_Size aKey = ~Val + (Val << 18);
  aKey ^= (aKey >> 31);
  aKey *= 21;
  aKey ^= (aKey >> 11);
  aKey += (aKey << 6);
  aKey ^= (aKey >> 22);
  return (Standard_Integer(aKey & 0x7fffffff) % Upper) + 1;
}

// ------------------------------------------------------------------
// IsEqual : Returns Standard_True if two values are equal
// ------------------------------------------------------------------
inline Standard_Boolean IsEqual(const Standard_Size One,
                                const Standard_Size Two)
{
  return One == Two;
}

#endif