From 24538e39b65ae56d2b85a4dde5b3af7297d80457 Mon Sep 17 00:00:00 2001 From: dadhi Date: Thu, 3 Aug 2023 23:36:48 +0300 Subject: [PATCH] commenting #57 --- playground/Experiments/FHashMap91.cs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/playground/Experiments/FHashMap91.cs b/playground/Experiments/FHashMap91.cs index 76ab725..f2db560 100644 --- a/playground/Experiments/FHashMap91.cs +++ b/playground/Experiments/FHashMap91.cs @@ -282,16 +282,21 @@ public interface IEntries where TEq : IEq internal const int MinEntriesCapacity = 2; - public struct SingleArrayEntries : IEntries where TEq : struct, IEq + /// Stores the entries in a single dynamically reallocated array + public struct SingleArrayEntries : IEntries where TEq : struct, IEq { int _entryCount; internal Entry[] _entries; + + /// public void Init(byte capacityBitShift) => _entries = new Entry[1 << capacityBitShift]; + /// [MethodImpl((MethodImplOptions)256)] public int GetCount() => _entryCount; + /// [MethodImpl((MethodImplOptions)256)] public ref Entry GetSurePresentEntryRef(int index) { @@ -302,6 +307,7 @@ public ref Entry GetSurePresentEntryRef(int index) #endif } + /// [MethodImpl((MethodImplOptions)256)] public ref V AddKeyAndGetValueRef(K key) { @@ -325,6 +331,7 @@ public ref V AddKeyAndGetValueRef(K key) return ref e.Value; } + /// Tombstones the entry key [MethodImpl((MethodImplOptions)256)] public void TombstoneOrRemoveSurePresentEntry(int index) { @@ -334,12 +341,13 @@ public void TombstoneOrRemoveSurePresentEntry(int index) } // todo: @improve make it configurable - const byte ChunkCapacityBitShift = 8; // 8 bits == 256 - const int ChunkCapacity = 1 << ChunkCapacityBitShift; - const int ChunkCapacityMask = ChunkCapacity - 1; + /// The capacity of chunk in bits for + public const byte ChunkCapacityBitShift = 8; // 8 bits == 256 + internal const int ChunkCapacity = 1 << ChunkCapacityBitShift; + internal const int ChunkCapacityMask = ChunkCapacity - 1; // todo: @perf research on the similar growable indexed collection with append-to-end semantics - /// The array of array buckets, where bucket is the fixed size. + /// The array of array buckets, where bucket is the fixed size. /// It enables adding the new bucket without for the new entries without reallocating the existing data. /// It may allow to drop the empty bucket as well, reclaiming the memory after remove. /// The structure is similar to Hashed Array Tree (HAT) @@ -347,12 +355,15 @@ public struct ChunkedArrayEntries : IEntries where TEq : s { int _entryCount; Entry[][] _entries; + /// public void Init(byte capacityBitShift) => _entries = new[] { new Entry[(1 << capacityBitShift) & ChunkCapacityMask] }; + /// [MethodImpl((MethodImplOptions)256)] public int GetCount() => _entryCount; + /// [MethodImpl((MethodImplOptions)256)] public ref Entry GetSurePresentEntryRef(int index) { @@ -364,6 +375,7 @@ public ref Entry GetSurePresentEntryRef(int index) #endif } + /// public ref V AddKeyAndGetValueRef(K key) { var index = _entryCount++; @@ -426,6 +438,7 @@ public ref V AddKeyAndGetValueRef(K key) } } + /// Tombstones the entry key [MethodImpl((MethodImplOptions)256)] public void TombstoneOrRemoveSurePresentEntry(int index) {