Package java.util

Examples of java.util.NavigableSet


        }
    }

    public void test_AscendingSubMapEntrySet_lower() {
        Set entrySet;
        NavigableSet ascendingSubMapEntrySet;
        Iterator iterator;
        Entry entry, lowerEntry;
        int value;

        entrySet = navigableMap_startExcluded_endExcluded.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.lower(entry);
                value = (Integer) entry.getValue();
                if (value > 101) {
                    assertEquals(value - 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = navigableMap_startExcluded_endIncluded.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.lower(entry);
                value = (Integer) entry.getValue();
                if (value > 101) {
                    assertEquals(value - 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = navigableMap_startIncluded_endExcluded.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.lower(entry);
                value = (Integer) entry.getValue();
                if (value > 100) {
                    assertEquals(value - 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = navigableMap_startIncluded_endIncluded.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.lower(entry);
                value = (Integer) entry.getValue();
                if (value > 100) {
                    assertEquals(value - 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        String endKey = new Integer(2).toString();
        entrySet = tm.headMap(endKey, true).entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = entrySet.iterator();
            Entry expectedEntry = (Entry) iterator.next();
            entry = (Entry) iterator.next();
            assertEquals(expectedEntry, ascendingSubMapEntrySet.lower(entry));
        }

        // With Comparator

        entrySet = subMap_startExcluded_endExcluded_comparator.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.lower(entry);
                value = (Integer) entry.getValue();
                if (value > 101) {
                    assertEquals(value - 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = subMap_startExcluded_endIncluded_comparator.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.lower(entry);
                value = (Integer) entry.getValue();
                if (value > 101) {
                    assertEquals(value - 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = subMap_startIncluded_endExcluded_comparator.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.lower(entry);
                value = (Integer) entry.getValue();
                if (value > 100) {
                    assertEquals(value - 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = subMap_startIncluded_endIncluded_comparator.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.lower(entry);
                value = (Integer) entry.getValue();
                if (value > 100) {
                    assertEquals(value - 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
View Full Code Here


        }
    }

    public void test_AscendingSubMapEntrySet_higher() {
        Set entrySet;
        NavigableSet ascendingSubMapEntrySet;
        Iterator iterator;
        Entry entry, lowerEntry;
        int value;

        entrySet = navigableMap_startExcluded_endExcluded.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.higher(entry);
                value = (Integer) entry.getValue();
                if (value < 108) {
                    assertEquals(value + 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = navigableMap_startExcluded_endIncluded.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.higher(entry);
                value = (Integer) entry.getValue();
                if (value < 109) {
                    assertEquals(value + 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = navigableMap_startIncluded_endExcluded.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.higher(entry);
                value = (Integer) entry.getValue();
                if (value < 108) {
                    assertEquals(value + 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = navigableMap_startIncluded_endIncluded.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.higher(entry);
                value = (Integer) entry.getValue();
                if (value < 109) {
                    assertEquals(value + 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        String endKey = new Integer(2).toString();
        entrySet = tm.headMap(endKey, true).entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = entrySet.iterator();
            entry = (Entry) iterator.next();
            Entry expectedEntry = (Entry) iterator.next();
            assertEquals(expectedEntry, ascendingSubMapEntrySet.higher(entry));
        }

        // With Comparator
        entrySet = subMap_startExcluded_endExcluded_comparator.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.higher(entry);
                value = (Integer) entry.getValue();
                if (value < 108) {
                    assertEquals(value + 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = subMap_startExcluded_endIncluded_comparator.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.higher(entry);
                value = (Integer) entry.getValue();
                if (value < 109) {
                    assertEquals(value + 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = subMap_startIncluded_endExcluded_comparator.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.higher(entry);
                value = (Integer) entry.getValue();
                if (value < 108) {
                    assertEquals(value + 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
                }
            }
        }

        entrySet = subMap_startIncluded_endIncluded_comparator.entrySet();
        if (entrySet instanceof NavigableSet) {
            ascendingSubMapEntrySet = (NavigableSet) entrySet;
            iterator = ascendingSubMapEntrySet.iterator();
            while (iterator.hasNext()) {
                entry = (Entry) iterator.next();
                lowerEntry = (Entry) ascendingSubMapEntrySet.higher(entry);
                value = (Integer) entry.getValue();
                if (value < 109) {
                    assertEquals(value + 1, lowerEntry.getValue());
                } else {
                    assertNull(lowerEntry);
View Full Code Here

    /**
     * descending iterator of descendingKeySet is ordered
     */
    public void testDescendingKeySetDescendingIteratorOrder() {
        COWSortedMap map = map5();
        NavigableSet s = map.descendingKeySet();
        Iterator i = s.descendingIterator();
        Integer last = (Integer)i.next();
        assertEquals(last, one);
        int count = 1;
        while (i.hasNext()) {
            Integer k = (Integer)i.next();
View Full Code Here

TOP

Related Classes of java.util.NavigableSet

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.