Package edu.stanford.ppl.concurrent

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


    /**
     * entrySet contains all pairs
     */
    public void testEntrySet() {
        SnapTreeMap map = map5();
        Set s = map.entrySet();
        assertEquals(5, s.size());
        Iterator it = s.iterator();
        while (it.hasNext()) {
            Map.Entry e = (Map.Entry) it.next();
            assertTrue(
View Full Code Here


    /**
     * descendingEntrySet contains all pairs
     */
    public void testDescendingEntrySet() {
        SnapTreeMap map = map5();
        Set s = map.descendingMap().entrySet();
        assertEquals(5, s.size());
        Iterator it = s.iterator();
        while (it.hasNext()) {
            Map.Entry e = (Map.Entry) it.next();
            assertTrue(
View Full Code Here

    /**
     *  entrySet.toArray contains all entries
     */
    public void testEntrySetToArray() {
        SnapTreeMap map = map5();
        Set s = map.entrySet();
        Object[] ar = s.toArray();
        assertEquals(5, ar.length);
        for (int i = 0; i < 5; ++i) {
            assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey()));
            assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue()));
        }
    }
View Full Code Here

    /**
     *  descendingEntrySet.toArray contains all entries
     */
    public void testDescendingEntrySetToArray() {
        SnapTreeMap map = map5();
        Set s = map.descendingMap().entrySet();
        Object[] ar = s.toArray();
        assertEquals(5, ar.length);
        for (int i = 0; i < 5; ++i) {
            assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey()));
            assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue()));
        }
    }
View Full Code Here

    /**
     *   putAll  adds all key-value pairs from the given map
     */
    public void testPutAll() {
        SnapTreeMap empty = new SnapTreeMap();
        SnapTreeMap map = map5();
        empty.putAll(map);
        assertEquals(5, empty.size());
        assertTrue(empty.containsKey(one));
        assertTrue(empty.containsKey(two));
        assertTrue(empty.containsKey(three));
View Full Code Here

    /**
     *   putIfAbsent works when the given key is not present
     */
    public void testPutIfAbsent() {
        SnapTreeMap map = map5();
        map.putIfAbsent(six, "Z");
        assertTrue(map.containsKey(six));
    }
View Full Code Here

    /**
     *   putIfAbsent does not add the pair if the key is already present
     */
    public void testPutIfAbsent2() {
        SnapTreeMap map = map5();
        assertEquals("A", map.putIfAbsent(one, "Z"));
    }
View Full Code Here

    /**
     *   replace fails when the given key is not present
     */
    public void testReplace() {
        SnapTreeMap map = map5();
        assertNull(map.replace(six, "Z"));
        assertFalse(map.containsKey(six));
    }
View Full Code Here

    /**
     *   replace succeeds if the key is already present
     */
    public void testReplace2() {
        SnapTreeMap map = map5();
        assertNotNull(map.replace(one, "Z"));
        assertEquals("Z", map.get(one));
    }
View Full Code Here

    /**
     * replace value fails when the given key not mapped to expected value
     */
    public void testReplaceValue() {
        SnapTreeMap map = map5();
        assertEquals("A", map.get(one));
        assertFalse(map.replace(one, "Z", "Z"));
        assertEquals("A", map.get(one));
    }
View Full Code Here

TOP

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

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.