Skip to content

Commit 24538e3

Browse files
committed
commenting #57
1 parent fd94677 commit 24538e3

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

playground/Experiments/FHashMap91.cs

+18-5
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,21 @@ public interface IEntries<K, V, TEq> where TEq : IEq<K>
282282

283283
internal const int MinEntriesCapacity = 2;
284284

285-
public struct SingleArrayEntries<K, V, TEq> : IEntries<K, V, TEq> where TEq : struct, IEq<K>
285+
/// <summary>Stores the entries in a single dynamically reallocated array</summary>
286+
public struct SingleArrayEntries<K, V, TEq> : IEntries<K, V, TEq> where TEq : struct, IEq<K>
286287
{
287288
int _entryCount;
288289
internal Entry<K, V>[] _entries;
290+
291+
/// <inheritdoc/>
289292
public void Init(byte capacityBitShift) =>
290293
_entries = new Entry<K, V>[1 << capacityBitShift];
291294

295+
/// <inheritdoc/>
292296
[MethodImpl((MethodImplOptions)256)]
293297
public int GetCount() => _entryCount;
294298

299+
/// <inheritdoc/>
295300
[MethodImpl((MethodImplOptions)256)]
296301
public ref Entry<K, V> GetSurePresentEntryRef(int index)
297302
{
@@ -302,6 +307,7 @@ public ref Entry<K, V> GetSurePresentEntryRef(int index)
302307
#endif
303308
}
304309

310+
/// <inheritdoc/>
305311
[MethodImpl((MethodImplOptions)256)]
306312
public ref V AddKeyAndGetValueRef(K key)
307313
{
@@ -325,6 +331,7 @@ public ref V AddKeyAndGetValueRef(K key)
325331
return ref e.Value;
326332
}
327333

334+
/// <summary>Tombstones the entry key</summary>
328335
[MethodImpl((MethodImplOptions)256)]
329336
public void TombstoneOrRemoveSurePresentEntry(int index)
330337
{
@@ -334,25 +341,29 @@ public void TombstoneOrRemoveSurePresentEntry(int index)
334341
}
335342

336343
// todo: @improve make it configurable
337-
const byte ChunkCapacityBitShift = 8; // 8 bits == 256
338-
const int ChunkCapacity = 1 << ChunkCapacityBitShift;
339-
const int ChunkCapacityMask = ChunkCapacity - 1;
344+
/// <summary>The capacity of chunk in bits for <see cref="ChunkedArrayEntries{K, V, TEq}"/></summary>
345+
public const byte ChunkCapacityBitShift = 8; // 8 bits == 256
346+
internal const int ChunkCapacity = 1 << ChunkCapacityBitShift;
347+
internal const int ChunkCapacityMask = ChunkCapacity - 1;
340348

341349
// todo: @perf research on the similar growable indexed collection with append-to-end semantics
342-
/// <summary>The array of array buckets, where bucket is the fixed size.
350+
/// <summary>The array of array buckets, where bucket is the fixed size.
343351
/// It enables adding the new bucket without for the new entries without reallocating the existing data.
344352
/// It may allow to drop the empty bucket as well, reclaiming the memory after remove.
345353
/// The structure is similar to Hashed Array Tree (HAT)</summary>
346354
public struct ChunkedArrayEntries<K, V, TEq> : IEntries<K, V, TEq> where TEq : struct, IEq<K>
347355
{
348356
int _entryCount;
349357
Entry<K, V>[][] _entries;
358+
/// <inheritdoc/>
350359
public void Init(byte capacityBitShift) =>
351360
_entries = new[] { new Entry<K, V>[(1 << capacityBitShift) & ChunkCapacityMask] };
352361

362+
/// <inheritdoc/>
353363
[MethodImpl((MethodImplOptions)256)]
354364
public int GetCount() => _entryCount;
355365

366+
/// <inheritdoc/>
356367
[MethodImpl((MethodImplOptions)256)]
357368
public ref Entry<K, V> GetSurePresentEntryRef(int index)
358369
{
@@ -364,6 +375,7 @@ public ref Entry<K, V> GetSurePresentEntryRef(int index)
364375
#endif
365376
}
366377

378+
/// <inheritdoc/>
367379
public ref V AddKeyAndGetValueRef(K key)
368380
{
369381
var index = _entryCount++;
@@ -426,6 +438,7 @@ public ref V AddKeyAndGetValueRef(K key)
426438
}
427439
}
428440

441+
/// <summary>Tombstones the entry key</summary>
429442
[MethodImpl((MethodImplOptions)256)]
430443
public void TombstoneOrRemoveSurePresentEntry(int index)
431444
{

0 commit comments

Comments
 (0)