Package edu.stanford.ppl.concurrent

Examples of edu.stanford.ppl.concurrent.SnapTreeMap$SubMap


    /**
     * tailMap returns map with keys in requested range
     */
    public void testTailMapContents() {
        SnapTreeMap map = map5();
        NavigableMap sm = map.tailMap(two, true);
        assertFalse(sm.containsKey(one));
        assertTrue(sm.containsKey(two));
        assertTrue(sm.containsKey(three));
        assertTrue(sm.containsKey(four));
        assertTrue(sm.containsKey(five));
        Iterator i = sm.keySet().iterator();
        Object k;
        k = (Integer)(i.next());
        assertEquals(two, k);
        k = (Integer)(i.next());
        assertEquals(three, k);
        k = (Integer)(i.next());
        assertEquals(four, k);
        k = (Integer)(i.next());
        assertEquals(five, k);
        assertFalse(i.hasNext());
        Iterator r = sm.descendingKeySet().iterator();
        k = (Integer)(r.next());
        assertEquals(five, k);
        k = (Integer)(r.next());
        assertEquals(four, k);
        k = (Integer)(r.next());
        assertEquals(three, k);
        k = (Integer)(r.next());
        assertEquals(two, k);
        assertFalse(r.hasNext());

        Iterator ei = sm.entrySet().iterator();
        Map.Entry e;
        e = (Map.Entry)(ei.next());
        assertEquals(two, e.getKey());
        assertEquals("B", e.getValue());
        e = (Map.Entry)(ei.next());
        assertEquals(three, e.getKey());
        assertEquals("C", e.getValue());
        e = (Map.Entry)(ei.next());
        assertEquals(four, e.getKey());
        assertEquals("D", e.getValue());
        e = (Map.Entry)(ei.next());
        assertEquals(five, e.getKey());
        assertEquals("E", e.getValue());
        assertFalse(i.hasNext());

        NavigableMap ssm = sm.tailMap(four, true);
        assertEquals(four, ssm.firstKey());
        assertEquals(five, ssm.lastKey());
        assertEquals("D", ssm.remove(four));
        assertEquals(1, ssm.size());
        assertEquals(3, sm.size());
        assertEquals(4, map.size());
    }
View Full Code Here


    /**
     * Create a map from Integers -5 to -1 to Strings "A"-"E".
     */
    private static ConcurrentNavigableMap dmap5() {
        SnapTreeMap map = new SnapTreeMap();
        assertTrue(map.isEmpty());
        map.put(m1, "A");
        map.put(m5, "E");
        map.put(m3, "C");
        map.put(m2, "B");
        map.put(m4, "D");
        assertFalse(map.isEmpty());
        assertEquals(5, map.size());
        return map.descendingMap();
    }
View Full Code Here

        assertEquals(5, map.size());
        return map.descendingMap();
    }

    private static ConcurrentNavigableMap map0() {
        SnapTreeMap map = new SnapTreeMap();
        assertTrue(map.isEmpty());
        return map.tailMap(one, true);
    }
View Full Code Here

        assertTrue(map.isEmpty());
        return map.tailMap(one, true);
    }

    private static ConcurrentNavigableMap dmap0() {
        SnapTreeMap map = new SnapTreeMap();
        assertTrue(map.isEmpty());
        return map;
    }
View Full Code Here

    /**
     * Create a map from Integers 1-5 to Strings "A"-"E".
     */
    private static ConcurrentNavigableMap map5() {
        SnapTreeMap map = new SnapTreeMap();
        assertTrue(map.isEmpty());
        map.put(zero, "Z");
        map.put(one, "A");
        map.put(five, "E");
        map.put(three, "C");
        map.put(two, "B");
        map.put(four, "D");
        map.put(seven, "F");
        assertFalse(map.isEmpty());
        assertEquals(7, map.size());
        return map.subMap(one, true, seven, false);
    }
View Full Code Here

        testMap(new LinkedHashMap());
        testMap(new WeakHashMap());
        testMap(new IdentityHashMap());
        testMap(new ConcurrentHashMap());
        testMap(new ConcurrentSkipListMap());
        testMap(new SnapTreeMap());
        testMap(new TreeMap());
    }
View Full Code Here

                    new WeakHashMap(16),
                    new Hashtable(16),
                    new TreeMap(),
                    new ConcurrentHashMap(16),
                    new ConcurrentSkipListMap(),
                    new SnapTreeMap() });

            for (int j = 0; j < 10; j++)
                put(maps, r.nextInt(100), r.nextInt(100));
            removeLastTwo(maps);
        }
View Full Code Here

TOP

Related Classes of edu.stanford.ppl.concurrent.SnapTreeMap$SubMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.