org.apache.commons.collections4.OrderedMapIterator Java Examples

The following examples show how to use org.apache.commons.collections4.OrderedMapIterator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractOrderedMapIteratorTest.java    From jesterj with Apache License 2.0 6 votes vote down vote up
/**
 * Test that the empty list iterator contract is correct.
 */
@Override
public void testEmptyMapIterator() {
    if (!supportsEmptyIterator()) {
        return;
    }

    super.testEmptyMapIterator();

    final OrderedMapIterator<K, V> it = makeEmptyIterator();
    assertEquals(false, it.hasPrevious());
    try {
        it.previous();
        fail();
    } catch (final NoSuchElementException ex) {}
}
 
Example #2
Source File: OrderedMapUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenALinkedMap_whenIteratedWithMapIterator_thenPreservesOrder() {
    // Tests that the order in map iterator is the same
    // as defined in the constant arrays of names and ages:

    OrderedMapIterator<String, Integer> runnersIterator = this.runnersLinkedMap.mapIterator();
    int i = 0;
    while (runnersIterator.hasNext()) {
        runnersIterator.next();
        assertEquals(runnersIterator.getKey(), this.names[i]);
        assertEquals(runnersIterator.getValue(), this.ages[i]);
        i++;
    }
}
 
Example #3
Source File: OrderedMapUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenAListOrderedMap_whenIteratedWithMapIterator_thenPreservesOrder() {
    // Tests that the order in map iterator is the same
    // as defined in the constant arrays of names and ages:

    OrderedMapIterator<String, Integer> runnersIterator = this.runnersListOrderedMap.mapIterator();
    int i = 0;
    while (runnersIterator.hasNext()) {
        runnersIterator.next();
        assertEquals(runnersIterator.getKey(), this.names[i]);
        assertEquals(runnersIterator.getValue(), this.ages[i]);
        i++;
    }
}
 
Example #4
Source File: CommandManager.java    From riiablo with Apache License 2.0 4 votes vote down vote up
public OrderedMapIterator<String, Command> mapIterator() {
  return COMMANDS.mapIterator();
}
 
Example #5
Source File: AbstractPatriciaTrie.java    From jesterj with Apache License 2.0 4 votes vote down vote up
public OrderedMapIterator<K, V> mapIterator() {
    return new TrieMapIterator();
}
 
Example #6
Source File: UnmodifiableTrie.java    From jesterj with Apache License 2.0 4 votes vote down vote up
public OrderedMapIterator<K, V> mapIterator() {
    final OrderedMapIterator<K, V> it = delegate.mapIterator();
    return UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it);
}
 
Example #7
Source File: AbstractOrderedMapIteratorTest.java    From jesterj with Apache License 2.0 4 votes vote down vote up
@Override
public abstract OrderedMapIterator<K, V> makeEmptyIterator();
 
Example #8
Source File: AbstractOrderedMapIteratorTest.java    From jesterj with Apache License 2.0 4 votes vote down vote up
@Override
public abstract OrderedMapIterator<K, V> makeObject();
 
Example #9
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 4 votes vote down vote up
@Override
public OrderedMapIterator<K, V> makeEmptyIterator() {
    resetEmpty();
    return AbstractOrderedMapTest.this.getMap().mapIterator();
}
 
Example #10
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 4 votes vote down vote up
@Override
public OrderedMapIterator<K, V> makeObject() {
    resetFull();
    return AbstractOrderedMapTest.this.getMap().mapIterator();
}