FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
oxyplot/Source/OxyPlot/Utilities/HashCodeBuilder.cs at develop · CodingConnected/oxyplot · GitHub
CodingConnected
oxyplot
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
oxyplot
/
Source
/
OxyPlot
/
Utilities
/
HashCodeBuilder.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (34 loc) · 1.41 KB
Breadcrumbs
oxyplot
/
Source
/
OxyPlot
/
Utilities
/
HashCodeBuilder.cs
Copy path
File metadata and controls
38 lines (34 loc) · 1.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HashCodeBuilder.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// Provides functionality to calculate hash codes.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
#nullable enable
namespace
OxyPlot
{
using
System
.
Collections
.
Generic
;
using
System
.
Linq
;
/// <summary>
/// Provides functionality to calculate hash codes.
/// </summary>
public
static
class
HashCodeBuilder
{
/// <summary>
/// Calculates a hash code for the specified sequence of items.
/// </summary>
/// <param name="items">A sequence of items.</param>
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
public
static
int
GetHashCode
(
IEnumerable
<
object
>
items
)
{
// See http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode
// Overflow is fine, just wrap
unchecked
{
return
items
.
Where
(
item
=>
item
!=
null
)
.
Aggregate
(
17
,
(
current
,
item
)
=>
(
current
*
23
)
+
item
.
GetHashCode
(
)
)
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL