Beispiel #1
0
        public unsafe ThreadSafeTypeKeyFormatterHashTable(int count = 0, double loadFactor = 0.45d)
        {
            typeArrayArray = count <= 0 ? new Type[256][] : new Type[HashTableHelper.CalcSize(count, loadFactor)][];

            bitMask       = typeArrayArray.Length - 1;
            shift         = 0;
            functionBytes = ArrayPool <byte> .Shared.Rent(typeArrayArray.Length *sizeof(FunctionPair));
        }
Beispiel #2
0
 public ThreadSafeTypeKeyReferenceHashTable(ReadOnlySpan <Entry> entries, double loadFactor) : this(entries.Length, loadFactor)
 {
     foreach (ref readonly var entry in entries)
     {
         var     code  = entry.Key.GetHashCode() & bitMask;
         ref var array = ref pairArrayArray[code];
         HashTableHelper.Add(ref array, entry);
     }
Beispiel #3
0
 public UInt16KeyByteArrayValueHashTable(ReadOnlySpan <Entry> entries, double loadFactor)
 {
     keys    = new ushort[HashTableHelper.CalcSize(entries.Length, loadFactor)][];
     values  = new byte[keys.Length][][];
     bitMask = (uint)(keys.Length - 1);
     foreach (ref readonly var entry in entries)
     {
         var     code     = entry.Key & bitMask;
         ref var keyArray = ref keys[code];
         HashTableHelper.Add(ref keyArray, entry.Key);
         ref var valueArray = ref values[code];
Beispiel #4
0
        public ByteArrayKeyUnmanagedValueHashTable(ReadOnlySpan <Entry> entries)
        {
            var maxLength = 0;

            foreach (ref readonly var entry in entries)
            {
                if (maxLength < entry.Key.Length)
                {
                    maxLength = entry.Key.Length;
                }
            }

            table = new Entry[maxLength + 1][];
            foreach (ref readonly var entry in entries)
            {
                ref var array = ref table[entry.Key.Length];
                HashTableHelper.SortInsert(ref array, entry);
            }
Beispiel #5
0
        public unsafe ThreadSafeTypeKeyFormatterHashTable(ReadOnlySpan <Entry> entries, double loadFactor = 0.45d)
        {
            typeArrayArray = entries.Length == 0 ? new Type[256][] : new Type[HashTableHelper.CalcSize(entries.Length, loadFactor)][];

            bitMask = typeArrayArray.Length - 1;
            shift   = 0;
            var maxCount = 0;

            foreach (ref readonly var entry in entries)
            {
                var     entryKey = entry.Key;
                var     code     = entryKey.GetHashCode() & bitMask;
                ref var array    = ref typeArrayArray[code];
                HashTableHelper.Add(ref array, entryKey);

                if (maxCount < array.Length)
                {
                    maxCount = array.Length;
                }
            }
Beispiel #6
0
 public ThreadSafeTypeKeyReferenceHashTable(int size = 16, double loadFactor = 0.75)
 {
     pairArrayArray = new Entry[HashTableHelper.CalcSize(size, loadFactor)][];
     bitMask        = pairArrayArray.Length - 1;
 }