Skip to content

Instantly share code, notes, and snippets.

@Konard
Created May 8, 2014 15:13
Show Gist options
  • Save Konard/c9477200c55ccc991cb6 to your computer and use it in GitHub Desktop.
Save Konard/c9477200c55ccc991cb6 to your computer and use it in GitHub Desktop.
Структура описывающая уникальную пару.
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