Daily update on 20260307-020120 by Nitload Youmu. Additional Message : None
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="SwissTable"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -43,14 +43,12 @@ namespace StgSharp.Collections
|
||||
private const int BucketCount = 1 << EntryMaskWidth;
|
||||
private const int BucketSize = 16;
|
||||
private const uint CrcMagic = 0xffff9961; // Magic number for CRC32C, used in hash computation
|
||||
private const int EntryMaskWidth = 16; // 65536 entries total, 16 per bucket
|
||||
private const int EntryMaskWidth = 10; // 1024 entries total, 16 per bucket
|
||||
public const int MaxCapacity = BucketCount * BucketSize; // 256 entries per bucket, 1024 buckets
|
||||
|
||||
private readonly Entry* _entries;
|
||||
|
||||
private SwissTable(
|
||||
Entry* buffer
|
||||
)
|
||||
private SwissTable(Entry* buffer)
|
||||
{
|
||||
_entries = buffer;
|
||||
}
|
||||
@@ -66,11 +64,7 @@ namespace StgSharp.Collections
|
||||
return new SwissTable(buffer);
|
||||
}
|
||||
|
||||
public bool TryAddOrSet(
|
||||
nint key,
|
||||
nint value,
|
||||
out bool isNewKey
|
||||
)
|
||||
public bool TryAddOrSet(nint key, nint value, out bool isNewKey)
|
||||
{
|
||||
uint hash = BitOperations.Crc32C(CrcMagic, (ulong)key);
|
||||
ushort entry = (ushort)(hash & (BucketCount - 1));
|
||||
@@ -78,10 +72,7 @@ namespace StgSharp.Collections
|
||||
return IBucketScanner.Current.TrySet(key, hash, bucket, value, out isNewKey);
|
||||
}
|
||||
|
||||
public bool TryGet(
|
||||
nint key,
|
||||
out nint value
|
||||
)
|
||||
public bool TryGet(nint key, out nint value)
|
||||
{
|
||||
uint hash = BitOperations.Crc32C(CrcMagic, (ulong)key);
|
||||
ushort entry = (ushort)(hash & (BucketCount - 1));
|
||||
@@ -96,10 +87,7 @@ namespace StgSharp.Collections
|
||||
*/
|
||||
}
|
||||
|
||||
public bool TryRemove(
|
||||
nint key,
|
||||
out nint value
|
||||
)
|
||||
public bool TryRemove(nint key, out nint value)
|
||||
{
|
||||
uint hash = BitOperations.Crc32C(CrcMagic, (ulong)key);
|
||||
ushort entry = (ushort)(hash & (BucketCount - 1));
|
||||
@@ -134,27 +122,11 @@ namespace StgSharp.Collections
|
||||
|
||||
static IBucketScanner Current { get; } = Create();
|
||||
|
||||
bool TryFind(
|
||||
nint key,
|
||||
uint Hash,
|
||||
Bucket* bucket,
|
||||
out nint value
|
||||
);
|
||||
bool TryFind(nint key, uint Hash, Bucket* bucket, out nint value);
|
||||
|
||||
unsafe bool TryRemove(
|
||||
nint key,
|
||||
uint hash,
|
||||
Bucket* bucket,
|
||||
out nint value
|
||||
);
|
||||
unsafe bool TryRemove(nint key, uint hash, Bucket* bucket, out nint value);
|
||||
|
||||
bool TrySet(
|
||||
nint key,
|
||||
uint hash,
|
||||
Bucket* bucket,
|
||||
nint value,
|
||||
out bool isNewKey
|
||||
);
|
||||
bool TrySet(nint key, uint hash, Bucket* bucket, nint value, out bool isNewKey);
|
||||
|
||||
private static IBucketScanner Create()
|
||||
{
|
||||
@@ -197,4 +169,4 @@ namespace StgSharp.Collections
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user