< Summary

Class:GDX.Collections.Generic.IntKeyDictionary[TValue]
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Collections/Generic/IntKeyDictionary.cs
Covered lines:350
Uncovered lines:27
Coverable lines:377
Total lines:667
Line coverage:92.8% (350 of 377)
Covered branches:0
Total branches:0
Covered methods:19
Total methods:19
Method coverage:100% (19 of 19)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
IntKeyDictionary(...)0%330100%
AddWithExpandCheck(...)0%220100%
AddWithUniqueCheck(...)0%33095.65%
AddSafe(...)0%4.284074.07%
AddUnchecked(...)0%110100%
ContainsKey(...)0%3.033085.71%
ExpandWhenFull()0%440100%
Reserve(...)0%6.146084.21%
IndexOf(...)0%33092.86%
TryModifyValue(...)0%3.023086.67%
TryRemove(...)0%5.035088.89%
TryRemoveNoValueClear(...)0%5.135082.86%
TryGetValue(...)0%33093.75%
MoveNext(...)0%4.034087.5%
MoveNext(...)0%330100%
MoveNext(...)0%330100%
Clear()0%330100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Collections/Generic/IntKeyDictionary.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace GDX.Collections.Generic
 5{
 6    /// <summary>
 7    ///     An optimized <see cref="System.Collections.Generic.Dictionary{T,T}" />-like data structure with a
 8    ///     <see cref="string" /> key requirement.
 9    /// </summary>
 10    [Serializable]
 11    public struct IntKeyDictionary<TValue>
 12    {
 13        public int[] Buckets;
 14        public IntKeyEntry<TValue>[] Entries;
 15        public int FreeListHead;
 16        public int Count;
 17
 18        /// <summary>
 19        ///     Initializes the dictionary with at least <paramref name="minCapacity" /> capacity.
 20        /// </summary>
 21        /// <param name="minCapacity">The minimal initial capacity to reserve.</param>
 22        public IntKeyDictionary(int minCapacity)
 6023        {
 6024            int primeCapacity = DictionaryPrimes.GetPrime(minCapacity);
 25
 6026            Buckets = new int[primeCapacity];
 226827            for (int i = 0; i < primeCapacity; i++)
 107428            {
 107429                Buckets[i] = int.MaxValue;
 107430            }
 31
 6032            Entries = new IntKeyEntry<TValue>[primeCapacity];
 33
 226834            for (int i = 0; i < primeCapacity; i++)
 107435            {
 107436                Entries[i].Next = (1 << 31) | (i + 1);
 107437            }
 38
 6039            Count = 0;
 6040            FreeListHead = 0;
 6041        }
 42
 43        /// <summary>
 44        ///     Directly access a value by key.
 45        /// </summary>
 46        /// <param name="key">The target key to look for a value identified by.</param>
 47        /// <exception cref="ArgumentNullException">Thrown when a null <paramref name="key" /> is provided to lookup.</e
 48        /// <exception cref="System.Collections.Generic.KeyNotFoundException">
 49        ///     Thrown when the <paramref name="key" /> is not found
 50        ///     in the <see cref="StringKeyDictionary{TValue}" />.
 51        /// </exception>
 52        public TValue this[int key]
 53        {
 54            get
 755            {
 756                int hashCode = key & 0x7FFFFFFF;
 757                int bucketIndex = hashCode % Buckets.Length;
 758                int nextKeyIndex = Buckets[bucketIndex];
 59
 60
 761                while (nextKeyIndex != int.MaxValue)
 762                {
 763                    ref IntKeyEntry<TValue> currEntry = ref Entries[nextKeyIndex];
 764                    nextKeyIndex = currEntry.Next;
 65
 766                    if (currEntry.Key == key)
 767                    {
 768                        return currEntry.Value;
 69                    }
 070                }
 71
 072                throw new KeyNotFoundException();
 773            }
 74
 75            set
 5676            {
 5677                int freeIndex = FreeListHead;
 78
 5679                if (freeIndex >= Buckets.Length)
 380                {
 381                    ExpandWhenFull();
 382                }
 83
 5684                int hashCode = key & 0x7FFFFFFF;
 5685                int bucketIndex = hashCode % Buckets.Length;
 5686                int indexAtBucket = Buckets[bucketIndex];
 87
 5688                int nextKeyIndex = indexAtBucket;
 89
 5690                while (nextKeyIndex != int.MaxValue)
 191                {
 192                    ref IntKeyEntry<TValue> currEntry = ref Entries[nextKeyIndex];
 193                    nextKeyIndex = currEntry.Next;
 194                    if (currEntry.Key == key)
 195                    {
 196                        currEntry.Value = value;
 197                        return;
 98                    }
 099                }
 100
 55101                ref IntKeyEntry<TValue> entry = ref Entries[freeIndex];
 102
 55103                FreeListHead = entry.Next & 0x7FFFFFFF;
 55104                entry.Next = indexAtBucket;
 55105                entry.Key = key;
 55106                entry.Value = value;
 55107                Buckets[bucketIndex] = freeIndex;
 108
 55109                ++Count;
 56110            }
 111        }
 112
 113        /// <summary>
 114        ///     Adds the key value pair to the dictionary, expanding if necessary but not checking for duplicate entries
 115        /// </summary>
 116        /// <param name="key">The key to add.</param>
 117        /// <param name="value">The value to add.</param>
 118        public void AddWithExpandCheck(int key, TValue value)
 58119        {
 58120            int freeIndex = FreeListHead;
 121
 58122            if (freeIndex >= Buckets.Length)
 2123            {
 2124                ExpandWhenFull();
 2125            }
 126
 58127            int hashCode = key & 0x7FFFFFFF;
 58128            int hashIndex = hashCode % Buckets.Length;
 58129            int indexAtBucket = Buckets[hashIndex];
 58130            ref IntKeyEntry<TValue> entry = ref Entries[freeIndex];
 131
 58132            FreeListHead = entry.Next & 0x7FFFFFFF;
 58133            entry.Next = indexAtBucket;
 58134            entry.Key = key;
 58135            entry.Value = value;
 58136            Buckets[hashIndex] = freeIndex;
 137
 58138            ++Count;
 58139        }
 140
 141        /// <summary>
 142        ///     Adds the key value pair to the dictionary, checking for duplicates but not expanding if necessary.
 143        /// </summary>
 144        /// <param name="key">The key to add.</param>
 145        /// <param name="value">The value to add.</param>
 146        /// <returns>True if the entry was successfully created.</returns>
 147        public bool AddWithUniqueCheck(int key, TValue value)
 3148        {
 3149            int freeIndex = FreeListHead;
 3150            int hashCode = key & 0x7FFFFFFF;
 3151            int hashIndex = hashCode % Buckets.Length;
 3152            int indexAtBucket = Buckets[hashIndex];
 153
 3154            int nextKeyIndex = indexAtBucket;
 155
 3156            while (nextKeyIndex != int.MaxValue)
 1157            {
 1158                ref IntKeyEntry<TValue> currEntry = ref Entries[nextKeyIndex];
 1159                nextKeyIndex = currEntry.Next;
 1160                if (currEntry.Key == key)
 1161                {
 1162                    return false;
 163                }
 0164            }
 165
 2166            ref IntKeyEntry<TValue> entry = ref Entries[freeIndex];
 167
 2168            FreeListHead = entry.Next & 0x7FFFFFFF;
 2169            entry.Next = indexAtBucket;
 2170            entry.Key = key;
 2171            entry.Value = value;
 2172            Buckets[hashIndex] = freeIndex;
 173
 2174            ++Count;
 2175            return true;
 3176        }
 177
 178        /// <summary>
 179        ///     Adds the key value pair to the dictionary, checking for duplicate entries and expanding if necessary.
 180        /// </summary>
 181        /// <param name="key">The key to add.</param>
 182        /// <param name="value">The value to add.</param>
 183        /// <returns>True if the entry was successfully created.</returns>
 184        public bool AddSafe(int key, TValue value)
 61185        {
 61186            int freeIndex = FreeListHead;
 187
 61188            if (freeIndex >= Buckets.Length)
 3189            {
 3190                ExpandWhenFull();
 3191            }
 192
 61193            int hashCode = key & 0x7FFFFFFF;
 61194            int hashIndex = hashCode % Buckets.Length;
 61195            int indexAtBucket = Buckets[hashIndex];
 196
 61197            int nextKeyIndex = indexAtBucket;
 198
 61199            while (nextKeyIndex != int.MaxValue)
 0200            {
 0201                IntKeyEntry<TValue> currEntry = Entries[nextKeyIndex];
 0202                nextKeyIndex = currEntry.Next;
 0203                if (currEntry.Key == key)
 0204                {
 0205                    return false;
 206                }
 0207            }
 208
 61209            ref IntKeyEntry<TValue> entry = ref Entries[freeIndex];
 210
 61211            FreeListHead = entry.Next & 0x7FFFFFFF;
 61212            entry.Next = indexAtBucket;
 61213            entry.Key = key;
 61214            entry.Value = value;
 61215            Buckets[hashIndex] = freeIndex;
 216
 61217            ++Count;
 61218            return true;
 61219        }
 220
 221        /// <summary>
 222        ///     Adds the key value pair to the dictionary, without checking for available capacity or duplicate entries.
 223        /// </summary>
 224        /// <param name="key">The key to add.</param>
 225        /// <param name="value">The value to add.</param>
 226        public void AddUnchecked(int key, TValue value)
 16227        {
 16228            int dataIndex = FreeListHead;
 16229            int hashCode = key & 0x7FFFFFFF;
 16230            int bucketIndex = hashCode % Buckets.Length;
 16231            int initialBucketValue = Buckets[bucketIndex];
 232
 16233            ref IntKeyEntry<TValue> entry = ref Entries[dataIndex];
 234
 16235            FreeListHead = entry.Next & 0x7FFFFFFF;
 16236            entry.Next = initialBucketValue;
 16237            entry.Key = key;
 16238            entry.Value = value;
 16239            Buckets[bucketIndex] = dataIndex;
 16240        }
 241
 242
 243        /// <summary>
 244        ///     Checks if the dictionary contains the given key.
 245        /// </summary>
 246        /// <param name="key">The key to check for.</param>
 247        /// <returns>True if the dictionary contains the key.</returns>
 248        public bool ContainsKey(int key)
 26249        {
 26250            int hashCode = key & 0x7FFFFFFF;
 26251            int bucketIndex = hashCode % Buckets.Length;
 26252            int nextKeyIndex = Buckets[bucketIndex];
 253
 26254            while (nextKeyIndex != int.MaxValue)
 20255            {
 20256                ref IntKeyEntry<TValue> currEntry = ref Entries[nextKeyIndex];
 257
 20258                if (currEntry.Key == key)
 20259                {
 20260                    return true;
 261                }
 262
 0263                nextKeyIndex = currEntry.Next;
 0264            }
 265
 6266            return false;
 26267        }
 268
 269        /// <summary>
 270        ///     Resizes the dictionary with the assumption that it is full. Do not use otherwise.
 271        /// </summary>
 272        public void ExpandWhenFull()
 9273        {
 9274            int oldCapacity = Buckets.Length;
 9275            int nextPrimeCapacity = DictionaryPrimes.GetNextSize(oldCapacity);
 276
 9277            int[] newBuckets = new int[nextPrimeCapacity];
 684278            for (int i = 0; i < nextPrimeCapacity; i++)
 333279            {
 333280                newBuckets[i] = int.MaxValue;
 333281            }
 282
 9283            IntKeyEntry<TValue>[] newEntries = new IntKeyEntry<TValue>[nextPrimeCapacity];
 9284            Array.Copy(Entries, 0, newEntries, 0, oldCapacity);
 285
 324286            for (int i = 0; i < oldCapacity; i++)
 153287            {
 153288                ref IntKeyEntry<TValue> entry = ref newEntries[i];
 289
 153290                int newBucketIndex = (entry.Key & 0x7FFFFFFF) % nextPrimeCapacity;
 291
 153292                int indexAtBucket = newBuckets[newBucketIndex];
 153293                entry.Next = indexAtBucket;
 153294                newBuckets[newBucketIndex] = i;
 153295            }
 296
 378297            for (int i = oldCapacity; i < nextPrimeCapacity; i++)
 180298            {
 180299                newEntries[i].Next = (1 << 31) | (i + 1);
 180300            }
 301
 9302            Buckets = newBuckets;
 9303            Entries = newEntries;
 9304        }
 305
 306        /// <summary>
 307        ///     Expands the dictionary if it does not have enough empty space for <paramref name="capacityToReserve" />.
 308        /// </summary>
 309        /// <param name="capacityToReserve"></param>
 310        public void Reserve(int capacityToReserve)
 1311        {
 1312            int oldCapacity = Entries.Length;
 1313            if (Count + capacityToReserve > oldCapacity)
 1314            {
 1315                int minCapacity = Count + capacityToReserve;
 1316                int nextPrimeCapacity = DictionaryPrimes.GetNextSize(minCapacity);
 317
 1318                int[] newBuckets = new int[nextPrimeCapacity];
 328319                for (int i = 0; i < nextPrimeCapacity; i++)
 163320                {
 163321                    newBuckets[i] = int.MaxValue;
 163322                }
 323
 1324                IntKeyEntry<TValue>[] newEntries = new IntKeyEntry<TValue>[nextPrimeCapacity];
 1325                Array.Copy(Entries, 0, newEntries, 0, oldCapacity);
 326
 36327                for (int i = 0; i < oldCapacity; i++)
 17328                {
 17329                    ref IntKeyEntry<TValue> entry = ref newEntries[i];
 330
 17331                    if (entry.Next >= 0)
 0332                    {
 0333                        int newBucketIndex = (entry.Key & 0x7FFFFFFF) % nextPrimeCapacity;
 334
 0335                        int indexAtBucket = newBuckets[newBucketIndex];
 0336                        entry.Next = indexAtBucket;
 0337                        newBuckets[newBucketIndex] = i;
 0338                    }
 17339                }
 340
 294341                for (int i = oldCapacity; i < nextPrimeCapacity; i++)
 146342                {
 146343                    newEntries[i].Next = (1 << 31) | (i + 1);
 146344                }
 345
 1346                Buckets = newBuckets;
 1347                Entries = newEntries;
 1348            }
 1349        }
 350
 351        /// <summary>
 352        ///     Finds the index of the entry corresponding to a key.
 353        /// </summary>
 354        /// <param name="key">The key to find the index of.</param>
 355        /// <returns>The index of the entry, or -1 if the entry does not exist.</returns>
 356        public int IndexOf(int key)
 63357        {
 63358            int hashCode = key & 0x7FFFFFFF;
 63359            int bucketIndex = hashCode % Buckets.Length;
 63360            int nextKeyIndex = Buckets[bucketIndex];
 361
 65362            while (nextKeyIndex != int.MaxValue)
 64363            {
 64364                ref IntKeyEntry<TValue> currEntry = ref Entries[nextKeyIndex];
 365
 64366                if (currEntry.Key == key)
 62367                {
 62368                    return nextKeyIndex;
 369                }
 370
 2371                nextKeyIndex = currEntry.Next;
 2372            }
 373
 1374            return -1;
 63375        }
 376
 377        /// <summary>
 378        ///     Replaces the value of the entry if the entry exists.
 379        /// </summary>
 380        /// <param name="key">The key of the entry to modify.</param>
 381        /// <param name="value">The new value of the entry.</param>
 382        /// <returns>True if the entry was found.</returns>
 383        public bool TryModifyValue(int key, TValue value)
 2384        {
 2385            int hashCode = key & 0x7FFFFFFF;
 2386            int bucketIndex = hashCode % Buckets.Length;
 2387            int nextKeyIndex = Buckets[bucketIndex];
 388
 2389            while (nextKeyIndex != int.MaxValue)
 1390            {
 1391                ref IntKeyEntry<TValue> currEntry = ref Entries[nextKeyIndex];
 1392                nextKeyIndex = currEntry.Next;
 393
 1394                if (currEntry.Key == key)
 1395                {
 1396                    currEntry.Value = value;
 1397                    return true;
 398                }
 0399            }
 400
 1401            return false;
 2402        }
 403
 404        /// <summary>
 405        ///     Removes the entry if it exists.
 406        /// </summary>
 407        /// <param name="key">The key to remove.</param>
 408        /// <returns>True if the entry was found.</returns>
 409        public bool TryRemove(int key)
 9410        {
 9411            int hashCode = key & 0x7FFFFFFF;
 9412            int bucketIndex = hashCode % Buckets.Length;
 9413            int indexAtBucket = Buckets[bucketIndex];
 9414            int indexOfKey = indexAtBucket;
 9415            int previousIndex = indexAtBucket;
 416
 9417            bool foundIndex = false;
 418
 10419            while (indexOfKey != int.MaxValue)
 9420            {
 9421                ref IntKeyEntry<TValue> currEntry = ref Entries[indexOfKey];
 422
 9423                if (currEntry.Key == key)
 8424                {
 8425                    foundIndex = true;
 8426                    break;
 427                }
 428
 1429                previousIndex = indexOfKey;
 1430                indexOfKey = currEntry.Next;
 1431            }
 432
 9433            if (foundIndex)
 8434            {
 8435                ref IntKeyEntry<TValue> currEntry = ref Entries[indexOfKey];
 8436                int nextUsedIndex = currEntry.Next;
 8437                int nextFreeIndex = FreeListHead;
 438
 8439                currEntry.Value = default;
 8440                currEntry.Next = nextFreeIndex | (1 << 31);
 8441                Entries[indexOfKey] = currEntry;
 8442                FreeListHead = indexOfKey;
 443
 8444                if (indexOfKey == indexAtBucket)
 7445                {
 7446                    Buckets[bucketIndex] = nextUsedIndex;
 7447                }
 448                else
 1449                {
 1450                    Entries[previousIndex].Next = nextUsedIndex;
 1451                }
 452
 8453                return true;
 454            }
 455
 1456            return false;
 9457        }
 458
 459        /// <summary>
 460        ///     Removes the entry if it exists, but does not remove the value of the key value pair.
 461        /// </summary>
 462        /// <param name="key">The key to remove.</param>
 463        /// <returns>True if the entry was found.</returns>
 464        public bool TryRemoveNoValueClear(int key)
 3465        {
 3466            int hashCode = key & 0x7FFFFFFF;
 3467            int bucketIndex = hashCode % Buckets.Length;
 3468            int indexAtBucket = Buckets[bucketIndex];
 3469            int indexOfKey = indexAtBucket;
 3470            int previousIndex = indexAtBucket;
 471
 3472            bool foundIndex = false;
 473
 3474            while (indexOfKey != int.MaxValue)
 2475            {
 2476                ref IntKeyEntry<TValue> currEntry = ref Entries[indexOfKey];
 477
 2478                if (currEntry.Key == key)
 2479                {
 2480                    foundIndex = true;
 2481                    break;
 482                }
 483
 0484                previousIndex = indexOfKey;
 0485                indexOfKey = currEntry.Next;
 0486            }
 487
 3488            if (foundIndex)
 2489            {
 2490                ref IntKeyEntry<TValue> currEntry = ref Entries[indexOfKey];
 2491                int nextUsedIndex = currEntry.Next;
 2492                int nextFreeIndex = FreeListHead;
 493
 2494                currEntry.Next = nextFreeIndex | (1 << 31);
 2495                Entries[indexOfKey] = currEntry;
 2496                FreeListHead = indexOfKey;
 497
 2498                if (indexOfKey == indexAtBucket)
 2499                {
 2500                    Buckets[bucketIndex] = nextUsedIndex;
 2501                }
 502                else
 0503                {
 0504                    Entries[previousIndex].Next = nextUsedIndex;
 0505                }
 506
 2507                return true;
 508            }
 509
 1510            return false;
 3511        }
 512
 513        /// <summary>
 514        ///     Attempts to get the value for the given key; returns true if key was found, false otherwise.
 515        /// </summary>
 516        /// <param name="key">The key to retrieve.</param>
 517        /// <param name="value">The value of the entry found.</param>
 518        /// <returns>True if the entry was found; false otherwise.</returns>
 519        public bool TryGetValue(int key, out TValue value)
 2520        {
 2521            int hashCode = key & 0x7FFFFFFF;
 2522            int bucketIndex = hashCode % Buckets.Length;
 2523            int nextKeyIndex = Buckets[bucketIndex];
 524
 2525            while (nextKeyIndex != int.MaxValue)
 1526            {
 1527                ref IntKeyEntry<TValue> currEntry = ref Entries[nextKeyIndex];
 1528                nextKeyIndex = currEntry.Next;
 529
 1530                if (currEntry.Key == key)
 1531                {
 1532                    value = currEntry.Value;
 1533                    return true;
 534                }
 0535            }
 536
 1537            value = default;
 1538            return false;
 2539        }
 540
 541        /// <summary>
 542        ///     Iterates the dictionary.
 543        /// </summary>
 544        /// <param name="iteratedIndexCount">The number of indices iterated so far - pass in 0 at the start of iteration
 545        /// <param name="iteratorVersion">The version when iteration started.</param>
 546        /// <param name="dictionaryVersion">
 547        ///     The current version of the dictionary - update this on add, remove, or clear
 548        ///     operations.
 549        /// </param>
 550        /// <param name="entry">The entry returned by the iterator</param>
 551        /// <returns>Whether the iterator found an entry, finished iteration, or could not continue due to an invalid ve
 552        public IteratorState MoveNext(ref int iteratedIndexCount, int iteratorVersion, in int dictionaryVersion,
 553            out IntKeyEntry<TValue> entry)
 5554        {
 5555            entry = default;
 556
 5557            if (iteratorVersion != dictionaryVersion)
 1558            {
 1559                return IteratorState.InvalidVersion;
 560            }
 561
 19562            while (iteratedIndexCount < Entries.Length)
 18563            {
 18564                ref IntKeyEntry<TValue> keyEntry = ref Entries[iteratedIndexCount];
 18565                iteratedIndexCount++;
 566
 18567                if (keyEntry.Next >= 0)
 3568                {
 3569                    entry = keyEntry;
 3570                    return IteratorState.FoundEntry;
 571                }
 15572            }
 573
 1574            return IteratorState.Finished;
 5575        }
 576
 577        /// <summary>
 578        ///     Iterates the dictionary.
 579        ///     NOTE: if you suspect the dictionary might be modified while iterating, this will not catch the error -- 
 580        ///     other overload instead.
 581        /// </summary>
 582        /// <param name="iteratedIndexCount">The number of indices iterated so far - pass in 0 at the start of iteration
 583        /// <param name="entry">The entry returned by the iterator</param>
 584        /// <returns>Whether or not the iterator found an entry</returns>
 585        public bool MoveNext(ref int iteratedIndexCount, out IntKeyEntry<TValue> entry)
 3586        {
 3587            entry = default;
 588
 18589            while (iteratedIndexCount < Entries.Length)
 17590            {
 17591                ref IntKeyEntry<TValue> keyEntry = ref Entries[iteratedIndexCount];
 17592                iteratedIndexCount++;
 593
 17594                if (keyEntry.Next >= 0)
 2595                {
 2596                    entry = keyEntry;
 597
 2598                    return true;
 599                }
 15600            }
 601
 1602            return false;
 3603        }
 604
 605        /// <summary>
 606        ///     Iterates the dictionary.
 607        /// </summary>
 608        /// <remarks>
 609        ///     <para>
 610        ///         If you use <paramref name="iteratedIndexCount" /> during iteration, you need to decrement it by 1 to
 611        ///         properly access the current iterations index.
 612        ///     </para>
 613        ///     <para>
 614        ///         If you suspect the dictionary might be modified while iterating, this will not catch the error.
 615        ///         You must use the other overload instead.
 616        ///     </para>
 617        /// </remarks>
 618        /// <param name="iteratedIndexCount">The number of indices iterated so far - pass in 0 at the start of iteration
 619        /// <returns>Whether or not the iterator found an entry</returns>
 620        public bool MoveNext(ref int iteratedIndexCount)
 3621        {
 18622            while (iteratedIndexCount < Entries.Length)
 17623            {
 17624                ref IntKeyEntry<TValue> keyEntry = ref Entries[iteratedIndexCount];
 17625                iteratedIndexCount++;
 626
 17627                if (keyEntry.Next >= 0)
 2628                {
 2629                    return true;
 630                }
 15631            }
 632
 1633            return false;
 3634        }
 635
 636        /// <summary>
 637        ///     Clears the dictionary.
 638        /// </summary>
 639        public void Clear()
 1640        {
 1641            int length = Entries.Length;
 642
 76643            for (int i = 0; i < length; i++)
 37644            {
 37645                Buckets[i] = int.MaxValue;
 37646            }
 647
 76648            for (int i = 0; i < length; i++)
 37649            {
 37650                ref IntKeyEntry<TValue> entryAt = ref Entries[i];
 37651                entryAt.Next = (1 << 31) | (i + 1);
 37652                entryAt.Value = default;
 37653            }
 654
 1655            FreeListHead = 0;
 1656            Count = 0;
 1657        }
 658    }
 659
 660    [Serializable]
 661    public struct IntKeyEntry<T>
 662    {
 663        public int Key;
 664        public int Next;
 665        public T Value;
 666    }
 667}

Coverage by test methods









































Methods/Properties

IntKeyDictionary(System.Int32)
Item(System.Int32)
Item(System.Int32, TValue)
AddWithExpandCheck(System.Int32, TValue)
AddWithUniqueCheck(System.Int32, TValue)
AddSafe(System.Int32, TValue)
AddUnchecked(System.Int32, TValue)
ContainsKey(System.Int32)
ExpandWhenFull()
Reserve(System.Int32)
IndexOf(System.Int32)
TryModifyValue(System.Int32, TValue)
TryRemove(System.Int32)
TryRemoveNoValueClear(System.Int32)
TryGetValue(System.Int32, )
MoveNext(System.Int32&, System.Int32, System.Int32&, )
MoveNext(System.Int32&, )
MoveNext(System.Int32&)
Clear()