public void Add(Point p, int value)
 {
     if (slotValues[p.GetHashCode()] == 0)
     {
         slotValues[p.GetHashCode()] = value;
         indexedSlot.Add(p.GetHashCode());
     }
 }
 public bool Contains(Point p)
 {
     if (slotValues[p.GetHashCode()] == 0)
         return false;
     else
         return true;
 }
 public int this[Point p]
 {
     get
     {
         return slotValues[p.GetHashCode()];
     }
 }
예제 #4
0
		public void Point()
		{
			//Do various Point method calls to cover the point class with sufficient testing
			Point p0 = new Point();
			Point p1 = new Point(0,0);
			Point p2 = new Point(450, 120);
			Assert.IsTrue(p0.IsEmpty());
			Assert.IsFalse(p1.IsEmpty());
			Assert.AreNotEqual(p0, p1);
			Assert.AreEqual(450, p2.X);
			Assert.AreEqual(120, p2.Y);
			Assert.AreNotSame(p2.Clone(), p2);
			p0 = p2.Clone();
			p0.X += 100; p0.Y = 150;
			p0[0] += p0[1];
			Assert.AreEqual(new Point(700, 150),p0);
			Assert.AreEqual(p2, p2.GetBoundingBox().Min);
			Assert.AreEqual(p2, p2.GetBoundingBox().Max);
			Assert.IsTrue(p2.IsSimple());
			Assert.IsFalse(p2.IsEmpty());
			Assert.AreEqual(2, p2.NumOrdinates);
			Assert.AreEqual(new Point(400, 100), p2 + new Point(-50, -20));
			Assert.AreEqual(new Point(500, 100), p2 - new Point(-50, 20));
			Assert.AreEqual(new Point(900, 240), p2 * 2);
			Assert.AreEqual(0, p2.Dimension);
			Assert.AreEqual(450, p2[0]);
			Assert.AreEqual(120, p2[1]);
			Assert.IsNull(p2.Boundary());
			Assert.AreEqual(p2.X.GetHashCode() ^ p2.Y.GetHashCode() ^ p2.IsEmpty().GetHashCode(), p2.GetHashCode());
			Assert.Greater(p2.CompareTo(p1), 0);
			Assert.Less(p1.CompareTo(p2), 0);
			Assert.AreEqual(p2.CompareTo(new Point(450,120)), 0);
		}
        public void TestHashCode()
        {
            int x = 2;
            int y = 4;
            var p = new Point(x, y);

            Assert.AreEqual(x ^ y, p.GetHashCode());
        }
 public void Remove(Point p)
 {
     slotValues[p.GetHashCode()] = 0;
     indexedSlot.Remove(p.GetHashCode());
 }
예제 #7
0
 public void CompareHashes(Point a, Point b, bool result)
 {
     (a.GetHashCode() == b.GetHashCode()).Should().Be(result);
 }