Exemplo n.º 1
0
        public void testVersusHashMap()
        {
            IDictionary <Integer, String> actual   = new FastMap <Integer, String>(1, 1000000);
            IDictionary <Integer, String> expected = Maps.newHashMapWithExpectedSize(1000000);
            Random r = RandomUtils.getRandom();

            for (int i = 0; i < 1000000; i++)
            {
                double  d   = r.nextDouble();
                Integer key = r.nextInt(100);
                if (d < 0.4)
                {
                    Assert.AreEqual(expected.get(key), actual.get(key));
                }
                else
                {
                    if (d < 0.7)
                    {
                        Assert.AreEqual(expected.put(key, "foo"), actual.put(key, "foo"));
                    }
                    else
                    {
                        Assert.AreEqual(expected.remove(key), actual.remove(key));
                    }
                    Assert.AreEqual(expected.Count, actual.Count);
                    Assert.AreEqual(expected.isEmpty(), actual.isEmpty());
                }
            }
        }
Exemplo n.º 2
0
 public void testRemove() {
   IDictionary<String, String> map = new FastMap<String, String>();
   map.put("foo", "bar");
   map.remove("foo");
   Assert.AreEqual(0, map.Count);
   Assert.True(map.isEmpty());
   Assert.IsNull(map.get("foo"));
 }
Exemplo n.º 3
0
        public void testRehash()
        {
            FastMap <String, String> map = buildTestFastMap();

            map.remove("foo");
            map.rehash();
            Assert.IsNull(map.get("foo"));
            Assert.AreEqual("bang", map.get("baz"));
        }
Exemplo n.º 4
0
        public void testRemove()
        {
            IDictionary <String, String> map = new FastMap <String, String>();

            map.put("foo", "bar");
            map.remove("foo");
            Assert.AreEqual(0, map.Count);
            Assert.True(map.isEmpty());
            Assert.IsNull(map.get("foo"));
        }
Exemplo n.º 5
0
 public void testVersusHashMap() {
   IDictionary<Integer, String> actual = new FastMap<Integer, String>(1, 1000000);
   IDictionary<Integer, String> expected = Maps.newHashMapWithExpectedSize(1000000);
   Random r = RandomUtils.getRandom();
   for (int i = 0; i < 1000000; i++) {
     double d = r.nextDouble();
     Integer key = r.nextInt(100);
     if (d < 0.4) {
       Assert.AreEqual(expected.get(key), actual.get(key));
     } else {
       if (d < 0.7) {
         Assert.AreEqual(expected.put(key, "foo"), actual.put(key, "foo"));
       } else {
         Assert.AreEqual(expected.remove(key), actual.remove(key));
       }
       Assert.AreEqual(expected.Count, actual.Count);
       Assert.AreEqual(expected.isEmpty(), actual.isEmpty());
     }
   }
 }