title: Hash function to map unique array of int to an index of range 0..n
body: <p>I need to map an array of sorted integers, with the length varying from 1 to 4 at max, to an index of a global array. Like [13,24,32] becoming a number in range 0..n, and no other array mapping to that same number.
  The quantity of arrays is a few millions, and the mapping has to be "unique" (or at least with very few collisions for smaller arrays), because these arrays represent itemsets and I use the k-1 smaller itemset to build the one of size k.</p>
  
  <p>My current implementation uses a efficient hash function that produces a double between 0..1 for an array, and I store the itemsets in STL Map, with the double as the key. Got from this article:</p>
  
  <p>N. D. Atreas,  C. Karanikas “A faster pattern matching algorithm based on prime numbers and hashing approximation “, 2007</p>
  
  <p>I'm going to implement a parallel version of this in CUDA, so I can't use something like STL Map. I could create myself easily a self-balancing binary search tree as a map in the GPU global memory, but that would be really slow. So in order to reduce global memory access to a minimum, I need to map the itemset to a huge array in the global memory.</p>
  
  <p>I've tried to cast the double as a long integer and hash it with a 64 bit hash function, but it produces some collision, as expected.</p>
  
  <p>So, I ask if there's a "unique" hash function for doubles between 0..1, or for array of integers from size 1..4, that gives an unique index for a table of size N.</p>