This file is indexed.

/usr/include/crystalspace-2.0/csutil/hashcomputer.h is in libcrystalspace-dev 2.0+dfsg-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
Copyright (C) 2003 by Mat Sutcliffe <oktal@gmx.co.uk>
2007 by Marten Svanfeldt

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __CS_UTIL_HASHCOMPUTER_H__
#define __CS_UTIL_HASHCOMPUTER_H__

/**\addtogroup util_containers
* @{ */


/**
* Compute a hash key for a null-terminated string.
* <p>
* Note that these keys are non-unique; some dissimilar strings may generate
* the same key. For unique keys, see csStringSet.
*/
CS_CRYSTALSPACE_EXPORT
unsigned int csHashCompute (char const*);

/**
* Compute a hash key for a string of a given length.
* <p>
* Note that these keys are non-unique; some dissimilar strings may generate
* the same key. For unique keys, see csStringSet.
*/
CS_CRYSTALSPACE_EXPORT
unsigned int csHashCompute (char const*, size_t length);

/**
* Template for hash value computing.
* Expects that T has a method 'uint GetHash() const'.
*/
template <class T>
class csHashComputer
{
public:
  /// Compute a hash value for \a key.
  static uint ComputeHash (const T& key)
  {
    return key.GetHash();
  }
};

/**
* Template for hash value computing, suitable for integral types and types 
* that can be casted to such.
*/
template <class T>
class csHashComputerIntegral
{
public:
  /// Compute a hash value for \a key.
  static uint ComputeHash (const T& key)
  {
    return (uintptr_t)key;
  }
};

//@{
/**
* csHashComputer<> specialization for an integral type.
*/
template<class T>
class csHashComputer<T*> : public csHashComputerIntegral<T*> {};

template<>
class csHashComputer<char> : public csHashComputerIntegral<char> {};
template<>
class csHashComputer<unsigned char> : public csHashComputerIntegral<unsigned char> {};

template<>
class csHashComputer<short> : public csHashComputerIntegral<short> {};
template<>
class csHashComputer<unsigned short> : public csHashComputerIntegral<unsigned short> {};

template<>
class csHashComputer<int> : public csHashComputerIntegral<int> {}; 
template<>
class csHashComputer<unsigned int> : 
  public csHashComputerIntegral<unsigned int> {}; 

template<>
class csHashComputer<long> : public csHashComputerIntegral<long> {}; 
template<>
class csHashComputer<unsigned long> : 
  public csHashComputerIntegral<unsigned long> {}; 

#if (CS_LONG_SIZE < 8)    
template<>
class csHashComputer<longlong> : 
  public csHashComputerIntegral<longlong> {}; 
template<>
class csHashComputer<ulonglong> : 
  public csHashComputerIntegral<ulonglong> {}; 
#endif

template<>
class csHashComputer<float>
{
public:
  /// Compute a hash value for \a key.
  static uint ComputeHash (float key)
  {
    union
    {
      float f;
      uint u;
    } float2uint;
    float2uint.f = key;
    return float2uint.u;
  }
};
template<>
class csHashComputer<double>
{
public:
  /// Compute a hash value for \a key.
  static uint ComputeHash (double key)
  {
    union
    {
      double f;
      uint u;
    } double2uint;
    double2uint.f = key;
    return double2uint.u;
  }
};


/**
* Template that can be used as a base class for hash computers for 
* string types (must support cast to const char*).
* Example:
* \code
* template<> class csHashComputer<MyString> : 
*   public csHashComputerString<MyString> {};
* \endcode
*/
template <class T>
class csHashComputerString
{
public:
  static uint ComputeHash (const T& key)
  {
    return csHashCompute ((const char*)key);
  }
};

/**
* csHashComputer<> specialization for strings that uses csHashCompute().
*/
template<>
class csHashComputer<const char*> : public csHashComputerString<const char*> {};

/**
* Template that can be used as a base class for hash computers for POD 
* structs.
* Example:
* \code
* template<> class csHashComputer<MyStruct> : 
*   public csHashComputerStruct<MyStruct> {};
* \endcode
*/
template <class T>
class csHashComputerStruct
{
public:
  static uint ComputeHash (const T& key)
  {
    return csHashCompute ((char*)&key, sizeof (T));
  }
};

//@}

namespace CS
{
  namespace Utility
  {

    class HashFoldingFNV1
    {
    public:
      static uint32 FoldHash (uint32 input)
      {
        static const uint32 fnvprime = 0x1000193;
        static const uint32 fnvoffset = 0x811C9DC5;

        uint32 fold = fnvoffset;
        for (size_t i = 0; i < 4; ++i)
        {
          fold = fold ^ (input & 0xFF);
          fold *= fnvprime;
          input >>= 8;
        }
        
        return fold;
      }
    };

    class HashFoldingNone
    {
    public:
      static uint32 FoldHash (uint32 input)
      {
        return input;
      }
    };

  }
}

/** @} */

#endif