예제 #1
0
        public void testWeakHashMap1()
        {
            var key1 = new MyKey();
            var key2 = new MyKey();
            var value1 = new MyValue();
            var value2 = new MyValue();

            var map = new OpenWeakReferenceHashMap<MyKey, MyValue>(16);

            map.Put(key1, value1);
            map.Put(key2, value2);

            AssertEquals(value1, map.Get(key1));
            AssertEquals(value2, map.Get(key2));
            AssertEquals(2, map.Size);
        }
예제 #2
0
        public void testWeakHashMap1()
        {
            var key1   = new MyKey();
            var key2   = new MyKey();
            var value1 = new MyValue();
            var value2 = new MyValue();

            var map = new OpenWeakReferenceHashMap <MyKey, MyValue>(16);

            map.Put(key1, value1);
            map.Put(key2, value2);

            AssertEquals(value1, map.Get(key1));
            AssertEquals(value2, map.Get(key2));
            AssertEquals(2, map.Size);
        }
예제 #3
0
        private IOpenHashMap <MyKey, MyValue> CreateWeakMap()
        {
            var map = new OpenWeakReferenceHashMap <MyKey, MyValue>(16);

            map.Put(new MyKey(), new MyValue());
            return(map);
        }
예제 #4
0
        public void testWeakPutIfAbsent()
        {
            var key1 = new MyKey();
            var key2 = new MyKey();
            var value1 = new MyValue();
            var value2 = new MyValue();

            var map = new OpenWeakReferenceHashMap<MyKey, MyValue>(16);

            AssertEquals(null, map.Put(key1, value1));
            AssertEquals(value1, map.Put(key1, value2));
            AssertEquals(value2, map.Put(key1, value1));

            AssertEquals(value1, map.PutIfAbsent(key1, value2));
            AssertEquals(null, map.PutIfAbsent(key2, value2));
            AssertEquals(value2, map.PutIfAbsent(key2, value1));
        }
예제 #5
0
        public void testWeakPutIfAbsent()
        {
            var key1   = new MyKey();
            var key2   = new MyKey();
            var value1 = new MyValue();
            var value2 = new MyValue();

            var map = new OpenWeakReferenceHashMap <MyKey, MyValue>(16);

            AssertEquals(null, map.Put(key1, value1));
            AssertEquals(value1, map.Put(key1, value2));
            AssertEquals(value2, map.Put(key1, value1));

            AssertEquals(value1, map.PutIfAbsent(key1, value2));
            AssertEquals(null, map.PutIfAbsent(key2, value2));
            AssertEquals(value2, map.PutIfAbsent(key2, value1));
        }
예제 #6
0
 private IOpenHashMap<MyKey, MyValue> CreateWeakMap()
 {
     var map = new OpenWeakReferenceHashMap<MyKey, MyValue>(16);
     map.Put(new MyKey(), new MyValue());
     return map;
 }