// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.Collections.Generic; namespace SixLabors.Fonts.Unicode { /// /// A simple bi-directional dictionary. /// /// Key type /// Value type internal sealed class BidiDictionary where T1 : struct where T2 : struct { public Dictionary Forward { get; } = new Dictionary(); public Dictionary Reverse { get; } = new Dictionary(); public void Clear() { this.Forward.Clear(); this.Reverse.Clear(); } public void Add(T1 key, T2 value) { this.Forward.Add(key, value); this.Reverse.Add(value, key); } public bool TryGetValue(T1 key, out T2 value) => this.Forward.TryGetValue(key, out value); public bool TryGetKey(T2 value, out T1 key) => this.Reverse.TryGetValue(value, out key); public bool ContainsKey(T1 key) => this.Forward.ContainsKey(key); public bool ContainsValue(T2 value) => this.Reverse.ContainsKey(value); } }