public void ContainsTest() { for (int i = 0; i < 4; i++) { set.Add(i); } Assert.AreEqual(true, set.Contains(3)); Assert.AreEqual(false, set.Contains(4)); }
public virtual void TestAdd() { NUnit.Framework.Assert.IsTrue(set.Contains(5)); NUnit.Framework.Assert.IsFalse(set.Contains(4)); for (int i = 0; i < 11; ++i) { set.Add(i); } // 0..10, existing elements should not be readded NUnit.Framework.Assert.AreEqual(11, set.Count); NUnit.Framework.Assert.IsTrue(set.Contains(5)); NUnit.Framework.Assert.IsTrue(set.Contains(4)); }
static Person Finder(ArraySet arrset, string id = null) { if (id == null) { id = numInput("\nEnter the ID of the record you want:"); } Person person = new Person(id, "", "", 0, "", 0); if (arrset.Contains(person)) { int bucket = Math.Abs(person.GetHashCode()) % arrset.Buckets; int pos = arrset.BinarySearch(person); if (arrset.ArrSet[bucket][pos] != null) { person = arrset.ArrSet[bucket][pos]; Console.WriteLine(person); } } else { person.Id = ""; Console.WriteLine("That record doesn't exist."); } return(person); /* foreach (var item in Person) * { * * if (item.Id == id) * { * * person = item; * Console.WriteLine(person); * * } * * } * * if (person.Id == "") Console.WriteLine("That record doesn't exist."); * * return person; */ }