org.h2.dev.hash

## Class MinimalPerfectHash.StringHash

- java.lang.Object
- - org.h2.dev.hash.MinimalPerfectHash.StringHash

All Implemented Interfaces:
  MinimalPerfectHash.UniversalHash<java.lang.String>

Enclosing class:
  MinimalPerfectHash<K>

    public static class MinimalPerfectHash.StringHash
    extends java.lang.Object
    implements MinimalPerfectHash.UniversalHash<java.lang.String>

A sample hash implementation for integer keys.

### Constructor Summary

Constructors
Constructor and Description
`MinimalPerfectHash.StringHash()`

### Method Summary

Methods
`static int` `getFastHash(java.lang.String o, int index, int seed)` A cryptographically weak hash function.
`static int` `getSipHash24(byte[] b, int start, int end, long k0, long k1)` A cryptographically relatively secure hash function.
`static int` `getSipHash24(java.lang.String o, long k0, long k1)` A cryptographically relatively secure hash function.
`int` `hashCode(java.lang.String o, int index, int seed)` Calculate the hash of the given object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### MinimalPerfectHash.StringHash

    public MinimalPerfectHash.StringHash()

### Method Detail

#### hashCode

    public int hashCode(java.lang.String o,
               int index,
               int seed)

Description copied from interface: `MinimalPerfectHash.UniversalHash`
Calculate the hash of the given object.

Specified by:
  `hashCode` in interface `MinimalPerfectHash.UniversalHash<java.lang.String>`
Parameters:
  `o` - the object
  `index` - the hash function index (index 0 is used first, so the method should be very fast with index 0; index 1 and so on are only called when really needed)
  `seed` - the random seed (always the same for a hash table)
Returns:
  the hash value

#### getFastHash

    public static int getFastHash(java.lang.String o,
                  int index,
                  int seed)

A cryptographically weak hash function. It is supposed to be fast.

Parameters:
  `o` - the string
  `index` - the hash function index
  `seed` - the seed
Returns:
  the hash value

#### getSipHash24

    public static int getSipHash24(java.lang.String o,
                   long k0,
                   long k1)

A cryptographically relatively secure hash function. It is supposed to protected against hash-flooding denial-of-service attacks.

Parameters:
  `o` - the string
  `k0` - key 0
  `k1` - key 1
Returns:
  the hash value

#### getSipHash24

    public static int getSipHash24(byte[] b,
                   int start,
                   int end,
                   long k0,
                   long k1)

A cryptographically relatively secure hash function. It is supposed to protected against hash-flooding denial-of-service attacks.

Parameters:
  `b` - the data
  `start` - the start position
  `end` - the end position plus one
  `k0` - key 0
  `k1` - key 1
Returns:
  the hash value