public static void Main() { var distances = new BiDictionary <string, string, int>(); distances.Add("Sofia", "Varna", 443); distances.Add("Sofia", "Varna", 468); distances.Add("Sofia", "Varna", 490); distances.Add("Sofia", "Plovdiv", 145); distances.Add("Sofia", "Bourgas", 383); distances.Add("Plovdiv", "Bourgas", 253); distances.Add("Plovdiv", "Bourgas", 292); var distancesFromSofia = distances.FindByKey1("Sofia"); // [443, 468, 490, 145, 383] var distancesToBourgas = distances.FindByKey2("Bourgas"); // [383, 253, 292] var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292] var distancesRousseVarna = distances.Find("Rousse", "Varna"); // [] var distancesSofiaVarna = distances.Find("Sofia", "Varna"); // [443, 468, 490] distances.Remove("Sofia", "Varna"); // true var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); // [145, 383] var distancesToVarna = distances.FindByKey2("Varna"); // [] var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // [] Console.WriteLine("Use this breakpoint to debug the results :)"); }
static void Main() { var distances = new BiDictionary <string, string, int>(); distances.Add("Sofia", "Varna", 443); distances.Add("Sofia", "Varna", 468); distances.Add("Sofia", "Varna", 490); distances.Add("Sofia", "Plovdiv", 145); distances.Add("Sofia", "Bourgas", 383); distances.Add("Plovdiv", "Bourgas", 253); distances.Add("Plovdiv", "Bourgas", 292); var distancesFromSofia = distances.FindByKey1("Sofia"); // [443, 468, 490, 145, 383] var distancesToBourgas = distances.FindByKey2("Bourgas"); // [383, 253, 292] var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292] var distancesRousseVarna = distances.Find("Rousse", "Varna"); // [] var distancesSofiaVarna = distances.Find("Sofia", "Varna"); // [443, 468, 490] distances.Remove("Sofia", "Varna"); // true var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); // [145, 383] var distancesToVarna = distances.FindByKey2("Varna"); // [] var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // [] Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofia)); Console.WriteLine("[{0}]", string.Join(", ", distancesToBourgas)); Console.WriteLine("[{0}]", string.Join(", ", distancesPlovdivBourgas)); Console.WriteLine("[{0}]", string.Join(", ", distancesRousseVarna)); Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarna)); Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofiaAgain)); Console.WriteLine("[{0}]", string.Join(", ", distancesToVarna)); Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarnaAgain)); }
static void Main(string[] args) { var distances = new BiDictionary<string, string, int>(); distances.Add("Sofia", "Varna", 443); distances.Add("Sofia", "Varna", 468); distances.Add("Sofia", "Varna", 490); distances.Add("Sofia", "Plovdiv", 145); distances.Add("Sofia", "Bourgas", 383); distances.Add("Plovdiv", "Bourgas", 253); distances.Add("Plovdiv", "Bourgas", 292); var distancesFromSofia = distances.FindByKey1("Sofia"); // [443, 468, 490, 145, 383] Print(distancesFromSofia); var distancesToBourgas = distances.FindByKey2("Bourgas"); // [383, 253, 292] Print(distancesToBourgas); var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292] Print(distancesPlovdivBourgas); var distancesRousseVarna = distances.Find("Rousse", "Varna"); // [] Print(distancesRousseVarna); var distancesSofiaVarna = distances.Find("Sofia", "Varna"); // [443, 468, 490] Print(distancesSofiaVarna); distances.Remove("Sofia", "Varna"); // true var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); // [145, 383] Print(distancesFromSofiaAgain); var distancesToVarna = distances.FindByKey2("Varna"); // [] Print(distancesToVarna); var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // [] Print(distancesSofiaVarnaAgain); }
public static void Main() { var distances = new BiDictionary<string, string, int>(); distances.Add("Sofia", "Varna", 443); distances.Add("Sofia", "Varna", 468); distances.Add("Sofia", "Varna", 490); distances.Add("Sofia", "Plovdiv", 145); distances.Add("Sofia", "Bourgas", 383); distances.Add("Plovdiv", "Bourgas", 253); distances.Add("Plovdiv", "Bourgas", 292); var distancesFromSofia = distances.FindByKey1("Sofia"); var distancesToBourgas = distances.FindByKey2("Bourgas"); var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); var distancesRousseVarna = distances.Find("Rousse", "Varna"); var distancesSofiaVarna = distances.Find("Sofia", "Varna"); var isDeletd = distances.Remove("Sofia", "Varna"); var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); var distancesToVarna = distances.FindByKey2("Varna"); var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofia)); Console.WriteLine("[{0}]",string.Join(", ", distancesToBourgas)); Console.WriteLine("[{0}]",string.Join(", ", distancesPlovdivBourgas)); Console.WriteLine("[{0}]", string.Join(", ", distancesRousseVarna)); Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarna)); Console.WriteLine(isDeletd); Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofiaAgain)); Console.WriteLine("[{0}]", string.Join(", ", distancesToVarna)); Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarnaAgain)); }
static void Main() { var distances = new BiDictionary<string, string, int>(); distances.Add("Sofia", "Varna", 443); distances.Add("Sofia", "Varna", 468); distances.Add("Sofia", "Varna", 490); distances.Add("Sofia", "Plovdiv", 145); distances.Add("Sofia", "Bourgas", 383); distances.Add("Plovdiv", "Bourgas", 253); distances.Add("Plovdiv", "Bourgas", 292); var distancesFromSofia = distances.FindByKey1("Sofia"); // [443, 468, 490, 145, 383] foreach (var distance in distancesFromSofia) { System.Console.WriteLine(distance); } var distancesToBourgas = distances.FindByKey2("Bourgas"); // [383, 253, 292] var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292] var distancesRousseVarna = distances.Find("Rousse", "Varna"); // [] var distancesSofiaVarna = distances.Find("Sofia", "Varna"); // [443, 468, 490] distances.Remove("Sofia", "Varna"); // true var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); // [145, 383] var distancesToVarna = distances.FindByKey2("Varna"); // [] var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // [] }
static void Main() { var dict = new BiDictionary<string, int, string>(); dict.Add("pesho", 1, "rabbit"); dict.Add("bai ivan", 2, "frog"); dict.Add("maria", 3, "bat"); dict.Add("maria", 2, "donkey"); dict.Add("pesho", 3, "bear"); dict.Add("bai ivan", 1, "hippo"); var peshos = dict.FindByKey1("pesho"); foreach (var item in peshos) { Console.WriteLine(item); } var marias = dict.FindByKey1AndKey2("maria", 3); foreach (var item in marias) { Console.WriteLine(item); } }
static void Main() { var distances = new BiDictionary<string, string, int>(); distances.Add("Sofia", "Varna", 443); distances.Add("Sofia", "Varna", 468); distances.Add("Sofia", "Varna", 490); distances.Add("Sofia", "Plovdiv", 145); distances.Add("Sofia", "Bourgas", 383); distances.Add("Plovdiv", "Bourgas", 253); distances.Add("Plovdiv", "Bourgas", 292); var distancesFromSofia = distances.FindByKey1("Sofia"); // [443, 468, 490, 145, 383] Console.WriteLine("Sofia"); Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofia)); var distancesToBourgas = distances.FindByKey2("Bourgas"); // [383, 253, 292] Console.WriteLine("Bourgas"); Console.WriteLine("[{0}]", string.Join(", ", distancesToBourgas)); var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292] Console.WriteLine("Plovdiv - Bourgas"); Console.WriteLine("[{0}]", string.Join(", ", distancesPlovdivBourgas)); var distancesRousseVarna = distances.Find("Rousse", "Varna"); // [] Console.WriteLine("Rousse - Varna"); Console.WriteLine("[{0}]", string.Join(", ", distancesRousseVarna)); var distancesSofiaVarna = distances.Find("Sofia", "Varna"); // [443, 468, 490] Console.WriteLine("Sofia - Varna"); Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarna)); var result = distances.Remove("Sofia", "Varna"); // true Console.WriteLine("Remove Sofia - Varna"); Console.WriteLine(result); var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); // [145, 383] Console.WriteLine("Sofia"); Console.WriteLine("[{0}]", string.Join(", ", distancesFromSofiaAgain)); var distancesToVarna = distances.FindByKey2("Varna"); // [] Console.WriteLine("Varna"); Console.WriteLine("[{0}]", string.Join(", ", distancesToVarna)); var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // [] Console.WriteLine("Sofia - Varna"); Console.WriteLine("[{0}]", string.Join(", ", distancesSofiaVarnaAgain)); }
private static void Main() { var distances = new BiDictionary<string, string, int>(); distances.Add("Sofia", "Varna", 443); distances.Add("Sofia", "Varna", 468); distances.Add("Sofia", "Varna", 490); distances.Add("Sofia", "Plovdiv", 145); distances.Add("Sofia", "Bourgas", 383); distances.Add("Plovdiv", "Bourgas", 253); distances.Add("Plovdiv", "Bourgas", 292); Console.WriteLine(string.Join(", ", distances.FindByKey1("Sofia"))); // [443, 468, 490, 145, 383] Console.WriteLine(string.Join(", ", distances.FindByKey2("Bourgas"))); // [383, 253, 292] Console.WriteLine(string.Join(", ", distances.Find("Plovdiv", "Bourgas"))); // [253, 292] Console.WriteLine(string.Join(", ", distances.Find("Rousse", "Varna"))); // [] Console.WriteLine(string.Join(", ", distances.Find("Sofia", "Varna"))); // [443, 468, 490] Console.WriteLine(distances.Remove("Sofia", "Varna")); // true Console.WriteLine(string.Join(", ", distances.FindByKey1("Sofia"))); // [145, 383] Console.WriteLine(string.Join(", ", distances.FindByKey2("Varna"))); // [] Console.WriteLine(string.Join(", ", distances.Find("Sofia", "Varna"))); // [] }
static void Main() { var distances = new BiDictionary<string, string, int>(); distances.Add("Sofia", "Varna", 443); distances.Add("Sofia", "Varna", 468); distances.Add("Sofia", "Varna", 490); distances.Add("Sofia", "Plovdiv", 145); distances.Add("Sofia", "Bourgas", 383); distances.Add("Plovdiv", "Bourgas", 253); distances.Add("Plovdiv", "Bourgas", 292); var distancesFromSofia = distances.FindByKey1("Sofia"); // [443, 468, 490, 145, 383] Console.WriteLine("Find by first key \"Sofia\" should be [443, 468, 490, 145, 383]\n" + Print(distancesFromSofia)); var distancesToBourgas = distances.FindByKey2("Bourgas"); // [383, 253, 292] Console.WriteLine("Find by second key \"Bourgas\" should be [383, 253, 292]\n" + Print(distancesToBourgas)); var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292] Console.WriteLine("Find by keys \"Plovdiv\" and \"Bourgas\" should be [253, 292]\n" + Print(distancesPlovdivBourgas)); var distancesRousseVarna = distances.Find("Rousse", "Varna"); // [] Console.WriteLine("Find by keys \"Rousse\" and \"Varna\" should be []\n" + Print(distancesRousseVarna)); var distancesSofiaVarna = distances.Find("Sofia", "Varna"); // [443, 468, 490] Console.WriteLine("Find by keys \"Sofia\" and \"Varna\" should be [443, 468, 490]\n" + Print(distancesSofiaVarna)); distances.Remove("Sofia", "Varna"); // true var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); // [145, 383] Console.WriteLine("Find by first key \"Sofia\" should be [145, 383]\n" + Print(distancesFromSofiaAgain)); var distancesToVarna = distances.FindByKey2("Varna"); // [] Console.WriteLine("Find by second key \"Varna\" should be []\n" + Print(distancesToVarna)); var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // [] Console.WriteLine("Find by keys \"Sofia\" and \"Varna\" should be []\n" + Print(distancesSofiaVarnaAgain)); }
public static void Main() { var tuple = new BiDictionary<string, string, string>(); tuple.Add("Pesho", "Peshov", "*****@*****.**"); tuple.Add("Gosho", "Goshov", "*****@*****.**"); tuple.Add("Tosho", "Toshov", "*****@*****.**"); var pesho = tuple.FindByKey1("Pesho"); Console.WriteLine(pesho); var gosho = tuple.FindByKey2("Goshov"); Console.WriteLine(gosho); var tosho = tuple.FindByTwoKeys("Tosho", "Toshov"); Console.WriteLine(tosho); }
public static void Main() { var distances = new BiDictionary<string, string, int>(); distances.Add("Sofia", "Varna", 443); distances.Add("Sofia", "Varna", 468); distances.Add("Sofia", "Varna", 490); distances.Add("Sofia", "Plovdiv", 145); distances.Add("Sofia", "Bourgas", 383); distances.Add("Plovdiv", "Bourgas", 253); distances.Add("Plovdiv", "Bourgas", 292); var distancesFromSofia = distances.FindByKey1("Sofia"); // [443, 468, 490, 145, 383] foreach(int i in distancesFromSofia) { Console.Write(i + " "); } Console.WriteLine(); var distancesToBourgas = distances.FindByKey2("Bourgas"); // [383, 253, 292] foreach (int i in distancesToBourgas) { Console.Write(i + " "); } Console.WriteLine(); var distancesPlovdivBourgas = distances.Find("Plovdiv", "Bourgas"); // [253, 292] foreach (int i in distancesPlovdivBourgas) { Console.Write(i + " "); } Console.WriteLine(); var distancesRousseVarna = distances.Find("Rousse", "Varna"); // [] foreach (int i in distancesRousseVarna) { Console.Write(i + " "); } Console.WriteLine(); var distancesSofiaVarna = distances.Find("Sofia", "Varna"); // [443, 468, 490] foreach (int i in distancesSofiaVarna) { Console.Write(i + " "); } Console.WriteLine(); Console.WriteLine(distances.Remove("Sofia", "Varna")); // true Console.WriteLine(distances.Remove("Sofia", "Varna")); // false var distancesFromSofiaAgain = distances.FindByKey1("Sofia"); // [145, 383] foreach (int i in distancesFromSofiaAgain) { Console.Write(i + " "); } Console.WriteLine(); var distancesToVarna = distances.FindByKey2("Varna"); // [] foreach (int i in distancesToVarna) { Console.Write(i + " "); } Console.WriteLine(); var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // [] foreach (int i in distancesSofiaVarnaAgain) { Console.Write(i + " "); } Console.WriteLine(); }