org.apache.commons.collections4.keyvalue.DefaultMapEntry Java Examples

The following examples show how to use org.apache.commons.collections4.keyvalue.DefaultMapEntry. 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: AbstractMapTest.java    From jesterj with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that the {@link Map#entrySet} set is backed by
 * the underlying map by removing from the entrySet set
 * and testing if the entry was removed from the map.
 */
public void testEntrySetRemoveChangesMap() {
    resetFull();
    final K[] sampleKeys = getSampleKeys();
    final V[] sampleValues = getSampleValues();
    final Set<Map.Entry<K, V>> entrySet = getMap().entrySet();
    for (int i = 0; i < sampleKeys.length; i++) {
        try {
            entrySet.remove(new DefaultMapEntry<>(sampleKeys[i], sampleValues[i]));
        } catch (final UnsupportedOperationException e) {
            // if entrySet removal is unsupported, just skip this test
            return;
        }
        assertTrue(
                "Entry should have been removed from the underlying map.",
                !getMap().containsKey(sampleKeys[i]));
    }
}
 
Example #2
Source File: AbstractNavigableMapTest.java    From adaptive-radix-tree with MIT License 5 votes vote down vote up
private Map.Entry<K, V> removeIth(Map<K, V> m, int pos) {
	Iterator<Map.Entry<K, V>> it = m.entrySet().iterator();
	Map.Entry<K, V> toRemove = null;
	for (int j = 0; j <= pos; j++) {
		toRemove = it.next();
	}
	DefaultMapEntry<K, V> removed = new DefaultMapEntry<>(toRemove);
	it.remove();
	return removed;
}