-
-
Save Konard/c9477200c55ccc991cb6 to your computer and use it in GitHub Desktop.
Структура описывающая уникальную пару.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Links.Core.Structures | |
{ | |
/// <summary> | |
/// Структура описывающая уникальную пару. | |
/// </summary> | |
public struct Pair : IEquatable<Pair> | |
{ | |
public readonly ulong Source; | |
public readonly ulong Target; | |
public Pair(ulong source, ulong target) | |
{ | |
Source = source; | |
Target = target; | |
} | |
static public Pair Create(ulong source, ulong target) | |
{ | |
return new Pair(source, target); | |
} | |
public override int GetHashCode() | |
{ | |
var hash = 17; | |
hash = hash * 31 + (int)Source; | |
hash = hash * 31 + (int)Target; | |
return hash; | |
} | |
public override bool Equals(object other) | |
{ | |
return other is Pair && Equals((Pair)other); | |
} | |
public bool Equals(Pair other) | |
{ | |
return Source == other.Source && | |
Target == other.Target; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment