| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationConnectionOwnerKey.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using System; |
| | | 9 | | using SwiftCollections.Utility; |
| | | 10 | | |
| | | 11 | | namespace Trailblazer.Pathing; |
| | | 12 | | |
| | | 13 | | /// <summary>Identifies one source-map-owned explicit connection.</summary> |
| | | 14 | | internal readonly struct NavigationConnectionOwnerKey : IEquatable<NavigationConnectionOwnerKey>, IComparable<Navigation |
| | | 15 | | { |
| | | 16 | | internal NavigationConnectionOwnerKey(string mapId, string connectionId) |
| | | 17 | | { |
| | 26311 | 18 | | MapId = mapId; |
| | 26311 | 19 | | ConnectionId = connectionId; |
| | 26311 | 20 | | } |
| | | 21 | | |
| | | 22 | | internal string MapId { get; } |
| | | 23 | | |
| | | 24 | | internal string ConnectionId { get; } |
| | | 25 | | |
| | | 26 | | public int CompareTo(NavigationConnectionOwnerKey other) |
| | | 27 | | { |
| | 52 | 28 | | int map = string.CompareOrdinal(MapId, other.MapId); |
| | 52 | 29 | | return map != 0 ? map : string.CompareOrdinal(ConnectionId, other.ConnectionId); |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | public bool Equals(NavigationConnectionOwnerKey other) => |
| | 4 | 33 | | string.Equals(MapId, other.MapId, StringComparison.Ordinal) |
| | 4 | 34 | | && string.Equals(ConnectionId, other.ConnectionId, StringComparison.Ordinal); |
| | | 35 | | |
| | | 36 | | public override int GetHashCode() |
| | | 37 | | { |
| | 5 | 38 | | var comparer = SwiftHashTools.GetDeterministicStringEqualityComparer(); |
| | 5 | 39 | | return SwiftHashTools.CombineHashCodes( |
| | 5 | 40 | | comparer.GetHashCode(MapId), |
| | 5 | 41 | | comparer.GetHashCode(ConnectionId)); |
| | | 42 | | } |
| | | 43 | | } |