Exemplo n.º 1
0
 /// <summary>
 /// 唯一静态哈希字典
 /// </summary>
 /// <param name="values">数据集合</param>
 /// <param name="count">数据数量</param>
 /// <param name="size">哈希容器尺寸</param>
 private unsafe void fromArray(KeyValue<keyType, valueType>[] values, int count, int size)
 {
     int count64 = (size + 63) >> 6;
     byte* isValue = stackalloc byte[count64 << 3];
     MemoryMap map = new MemoryMap((ulong*)isValue, count64);
     do
     {
         KeyValue<keyType, valueType> value = values[--count];
         int index = value.Key.GetHashCode();
         if ((uint)index >= size) throw new IndexOutOfRangeException(index.toString() + " >= " + size.toString());
         if (map.Get(index) != 0) throw new IndexOutOfRangeException(index.toString() + " is exists");
         map.Set(index);
         array[index] = value;
     }
     while (count != 0);
 }