static void Main(string[] args) { try { const int NumberOfItems = 10; BiDictionary<string, string, int> collection = new BiDictionary<string, string, int>(); for (int i = 0; i < NumberOfItems; i++) { collection.Add("K1" + i, "K2" + i, i); } for (int i = 0; i < NumberOfItems; i++) { collection.Add("K1" + i, "K2" + i, i * 7); } Console.WriteLine(collection.Find("K29").Count()); Console.WriteLine(collection.Find("K19", "K29").Count()); Console.WriteLine(collection.Find("K199").Count()); } catch (InvalidOperationException iex) { Console.WriteLine(iex.Message); } }
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"); // [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() { 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"); // [] }
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)); }
public static void Main() { var biDictionary = new BiDictionary<int, string, string>(); biDictionary.Add(5, "da", "Value as value"); biDictionary.Add(3, "ne", "Another value"); biDictionary.Add(3, "da", "HAHAHAHA"); Console.WriteLine(biDictionary.Find(3)); Console.WriteLine(biDictionary.Find("da")); biDictionary.Find(3, "ne").ToList().ForEach(Console.WriteLine); }
static void Main() { var collection = new BiDictionary<int, double, string>(); collection.Add(0, 0, "test"); collection.Add(2, 1.5, "test1"); collection.Add(1, 1, "test2"); Console.WriteLine(collection.Find(1)); Console.WriteLine(collection.Find(1.5)); Console.WriteLine(collection.Find(1)); Console.ReadKey(); }
public static void Main() { BiDictionary<string, int, string> myDictionary = new BiDictionary<string, int, string>(); myDictionary.Add("name", 1, "pesho"); Console.WriteLine(myDictionary.Find(1)); Console.WriteLine(myDictionary.Find("name")); Console.WriteLine(myDictionary.Find("name", 1)); //throws exception when key not found. //Console.WriteLine(myDictionary.Find(34)); //Console.WriteLine(myDictionary.Find("dsfs")); }
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)); }
static void Main() { // for keys from the same type it(find) doesn`t work var myDict = new BiDictionary<string, int, int>(); var twitchKeyWord = "twitch"; var threeKeyWord = 3; myDict.Add(twitchKeyWord, threeKeyWord, 1); myDict.Add(twitchKeyWord, threeKeyWord, 2); myDict.Add(twitchKeyWord, threeKeyWord, 3); var registerKeyWord = "register"; var fourKeyWord = 4; myDict.Add(registerKeyWord, fourKeyWord, 1); myDict.Add(registerKeyWord, fourKeyWord, 2); myDict.Add(registerKeyWord, fourKeyWord, 3); myDict.Add(registerKeyWord, fourKeyWord, 4); myDict.Add(registerKeyWord, fourKeyWord, 5); //var resultFromFirstKeySearch = myDict.Find(myDictFirstSectionFirstKey); //Console.WriteLine(resultFromFirstKeySearch.Count); var myOtherDict = new BiDictionary<string, int, int>(); var baseKeyWord = "base"; var oneKeyNumber = 1; myOtherDict.Add(baseKeyWord, oneKeyNumber, 1); myOtherDict.Add(baseKeyWord, oneKeyNumber, 2); myOtherDict.Add(baseKeyWord, oneKeyNumber, 3); myOtherDict.Add(baseKeyWord, oneKeyNumber, 4); var airKeyWord = "air"; var twoKeyNumber = 2; myOtherDict.Add(airKeyWord, twoKeyNumber, 1); myOtherDict.Add(airKeyWord, twoKeyNumber, 17); myOtherDict.Add(airKeyWord, twoKeyNumber, 3); myOtherDict.Add(airKeyWord, twoKeyNumber, 5); myOtherDict.Add(airKeyWord, twoKeyNumber, 11); var resultFromOneKeyWordSearch = myOtherDict.Find(airKeyWord); Console.WriteLine(string.Join(", ", resultFromOneKeyWordSearch)); var resultFromTwoKeyWordsSearch = myOtherDict.Find(airKeyWord, twoKeyNumber); Console.WriteLine(string.Join(", ", resultFromTwoKeyWordsSearch)); // throws error //var resultFromTwoKeyWordSearchWrongSecondKey = myOtherDict.Find(airKeyWord, fourKeyWord); }
public static void Main(string[] args) { BiDictionary<int, string, string> dictionary = new BiDictionary<int, string, string>(); var key1 = 1; var key2 = "2"; dictionary.Add(key1, key2, "valid keys 1"); dictionary.Add(key1, key2, "valid keys 2"); Console.WriteLine("==========Find(key1)=========="); Console.WriteLine(dictionary.Find(key1)); Console.WriteLine("==========Find(key2)=========="); Console.WriteLine(dictionary.Find(key2)); Console.WriteLine("==========Find(key1, key2)=========="); Console.WriteLine(dictionary.Find(key1, key2)); var key3 = 1; var key4 = "4"; dictionary.Add(key3, key4, "default value INVALID"); }
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.FindByFirstKey("Sofia"); // [443, 468, 490, 145, 383] var distancesToBourgas = distances.FindBySecondKey("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.FindByFirstKey("Sofia"); // [145, 383] var distancesToVarna = distances.FindBySecondKey("Varna"); // [] var distancesSofiaVarnaAgain = distances.Find("Sofia", "Varna"); // [] }
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"))); // [] }
public static void Main(string[] args) { var myBiDictionary = new BiDictionary <int, int, string>(); myBiDictionary.Add(11, 21, "1"); myBiDictionary.Add(11, 22, "2"); myBiDictionary.Add(11, 23, "3"); myBiDictionary.Add(12, 21, "4"); myBiDictionary.Add(13, 21, "5"); myBiDictionary.Add(14, 21, "6"); myBiDictionary.Add(15, 21, "7"); // find all key11 values for first key var res1 = myBiDictionary.Find(key1: 11); // find all key21 values for second key var res2 = myBiDictionary.Find(key2: 21); // find all key11 and key21 values for both keys var res3 = myBiDictionary.Find(11, 21); }
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)); }
static void Main(string[] args) { BiDictionary<string, string, int> distances = new BiDictionary<string, string, int>(); distances.Add("Sofia", "Bourgas", 480); distances.Add("Sofia", "Bourgas", 500); var sofiaToBourgas = distances.Find("Sofia", "Bourgas"); Console.WriteLine(string.Join(", ", sofiaToBourgas)); bool removeIsSuccessful = distances.Remove("Sofia", "Bourgas"); Console.WriteLine(removeIsSuccessful); removeIsSuccessful = distances.Remove("Sofia", "Bourgas"); Console.WriteLine(removeIsSuccessful); }
public static void Main() { var biDictionary = new BiDictionary<int, int, string>(); biDictionary.Add(1, 1, "Value 1") .Add(1, 2, "Value 2") .Add(1, 3, "Value 3") .Add(2, 1, "Value 4") .Add(2, 2, "Value 5") .Add(2, 3, "Value 6") .Add(3, 3, "Value 7") .Add(3, 4, "Value 8") .Add(3, 5, "Value 9") .Add(2, 1, "Value 10"); var xKey = 2; Console.WriteLine("Values with keyX = {0} :\n\r {1}", xKey, string.Join(Environment.NewLine + " ", biDictionary.FindByXKey(xKey))); var yKey = 1; Console.WriteLine("Values with keyY = {0} :\n\r {1}", yKey, string.Join(Environment.NewLine + " ", biDictionary.FindByYKey(yKey))); Console.WriteLine("Values with keyX = {0} and keyY = {1} :\n\r {2}", xKey, yKey, string.Join(Environment.NewLine + " ", biDictionary.Find(xKey , yKey))); }
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(); }