public void Add(bool a, int b, long val) { NKeyHash <bool, int, long> cube = new NKeyHash <bool, int, long>(); cube.Add(a, b, val); Assert.AreEqual(val, cube.Get(a, b)); }
public void Forloop4() { List <Expected4> data4 = new List <Expected4>(); data4.Add(new Expected4 { E1 = 1, E2 = 3, E3 = 5, E4 = "zxcv" }); data4.Add(new Expected4 { E1 = 5, E2 = 2, E3 = 15, E4 = "asdf" }); data4.Add(new Expected4 { E1 = 3, E2 = 6, E3 = -5, E4 = "4t6a" }); NKeyHash <long, decimal, float, string> cube4 = new NKeyHash <long, decimal, float, string>(); foreach (Expected4 x in data4) { cube4.Add(x.E1, x.E2, x.E3, x.E4); } foreach (NKeyValue <long, decimal, float, string> cc4 in cube4) { Assert.IsTrue(data4.Contains(new Expected4 { E1 = cc4.Key0, E2 = cc4.Key1, E3 = cc4.Key2, E4 = cc4.Value }), "Cube4 does not contain what Data4 contains"); } foreach (Expected4 x in data4) { Assert.AreEqual(x.E4, cube4.Get(x.E1, x.E2, x.E3), "Data4 does not contain what Cube4 contains"); } }
public void Delete(bool a, int b, long val) { NKeyHash <bool, int, long> cube = new NKeyHash <bool, int, long>(); cube.Add(a, b, val); Assert.IsTrue(cube.ContainsKey(a, b)); cube.Delete(a, b); Assert.IsFalse(cube.ContainsKey(a, b)); }
public void Upsert(bool a, int b, long val) { NKeyHash <bool, int, long> cube = new NKeyHash <bool, int, long>(); long newValue = 0; cube.Add(a, b, val); cube.Upsert(a, b, newValue); Assert.AreEqual(newValue, cube.Get(a, b)); }
public void Forloop(double[] a, int[] b, double[] c, long[] val) { NKeyHash <double, int, double, long> cube = new NKeyHash <double, int, double, long>(UnderlyingHashType.Dictionary); cube.Add(a[0], b[0], c[0], val[0]); cube.Add(a[1], b[1], c[1], val[1]); cube.Add(a[2], b[2], c[2], val[2]); cube.Add(a[3], b[3], c[3], val[3]); cube.Add(a[4], b[4], c[4], val[4]); cube.Add(a[5], b[5], c[5], val[5]); bool[] found = new bool[6]; foreach (NKeyValue <double, int, double, long> mkv in cube) { if (found[0] == false && mkv.Key0 == a[0] && mkv.Key1 == b[0] && mkv.Key2 == c[0] && mkv.Value == val[0]) { found[0] = true; continue; } if (found[1] == false && mkv.Key0 == a[1] && mkv.Key1 == b[1] && mkv.Key2 == c[1] && mkv.Value == val[1]) { found[1] = true; continue; } if (found[2] == false && mkv.Key0 == a[2] && mkv.Key1 == b[2] && mkv.Key2 == c[2] && mkv.Value == val[2]) { found[2] = true; continue; } if (found[3] == false && mkv.Key0 == a[3] && mkv.Key1 == b[3] && mkv.Key2 == c[3] && mkv.Value == val[3]) { found[3] = true; continue; } if (found[4] == false && mkv.Key0 == a[4] && mkv.Key1 == b[4] && mkv.Key2 == c[4] && mkv.Value == val[4]) { found[4] = true; continue; } if (found[5] == false && mkv.Key0 == a[5] && mkv.Key1 == b[5] && mkv.Key2 == c[5] && mkv.Value == val[5]) { found[5] = true; continue; } throw new System.Exception("Too many found"); } bool allFound = found[0] && found[1] && found[2] && found[3] && found[4] && found[5]; Assert.IsTrue(allFound); }