Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,4 @@ ASALocalRun/

# Local History for Visual Studio Code
.history/
experiments/
9 changes: 5 additions & 4 deletions csharp/Platform.Collections/Lists/IListExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,18 @@ public static void ForEach<T>(this IList<T> list, Action<T> action)
/// <para>Хэш-код списка.</para>
/// </returns>
/// <remarks>
/// Based on http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode
/// Uses System.HashCode for optimal hash combining as recommended in modern .NET applications.
/// This provides better distribution and collision resistance compared to simple multiplicative hashing.
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GenerateHashCode<T>(this IList<T> list)
{
var hashAccumulator = 17;
var hash = new HashCode();
for (var i = 0; i < list.Count; i++)
{
hashAccumulator = unchecked((hashAccumulator * 23) + list[i].GetHashCode());
hash.Add(list[i]);
}
return hashAccumulator;
return hash.ToHashCode();
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions csharp/Platform.Collections/Platform.Collections.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description>LinksPlatform's Platform.Collections Class Library</Description>
<Copyright>konard;tynkute</Copyright>
<AssemblyTitle>Platform.Collections</AssemblyTitle>
<VersionPrefix>0.4.0</VersionPrefix>
<VersionPrefix>0.5.0</VersionPrefix>
<Authors>konard;tynkute</Authors>
<TargetFramework>net8</TargetFramework>
<AssemblyName>Platform.Collections</AssemblyName>
Expand All @@ -24,7 +24,7 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<LangVersion>latest</LangVersion>
<PackageReleaseNotes>Update target framework from net7 to net8.</PackageReleaseNotes>
<PackageReleaseNotes>Improve hash function quality by replacing simple multiplicative algorithm with System.HashCode for better distribution and collision resistance.</PackageReleaseNotes>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Loading