Skip to content

Commit df22391

Browse files
committed
Fix GetKeyByIndex
1 parent 2e86f8f commit df22391

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Collections.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ public static T GetValueByKey<T>(this IntHashMap<T> hashMap, in int key) {
571571
public static T GetValueByIndex<T>(this IntHashMap<T> hashMap, in int index) => hashMap.data[index];
572572

573573
[MethodImpl(MethodImplOptions.AggressiveInlining)]
574-
public static int GetKeyByIndex<T>(this IntHashMap<T> hashMap, in int index) => hashMap.slots[index].key;
574+
public static int GetKeyByIndex<T>(this IntHashMap<T> hashMap, in int index) => hashMap.slots[index].key - 1;
575575

576576
[MethodImpl(MethodImplOptions.AggressiveInlining)]
577577
public static int TryGetIndex<T>(this IntHashMap<T> hashMap, in int key) {
@@ -881,7 +881,7 @@ public static T GetValueByIndex<T>(this UnsafeIntHashMap<T> hashMap, in int inde
881881
[MethodImpl(MethodImplOptions.AggressiveInlining)]
882882
public static int GetKeyByIndex<T>(this UnsafeIntHashMap<T> hashMap, in int index) where T : unmanaged {
883883
fixed (int* d = &hashMap.slots[0]) {
884-
return *(d + index) - 1;
884+
return (*(d + index)) - 1;
885885
}
886886
}
887887

0 commit comments

Comments
 (0)