org.apache.commons.collections4.OrderedMap Java Examples

The following examples show how to use org.apache.commons.collections4.OrderedMap. 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: CommonsExample.java    From pragmatic-java-engineer with GNU General Public License v3.0 6 votes vote down vote up
public static void collections() {
    List<String> list = Lists.newArrayList();
    List<String> list2 = Lists.newArrayList();

    if (CollectionUtils.isNotEmpty(list)) {
        CollectionUtils.subtract(list, list2);
        CollectionUtils.subtract(list, list2);
        CollectionUtils.retainAll(list, list2);
    }

    OrderedMap map = new LinkedMap();
    map.put("1", "1");
    map.put("2", "2");
    map.put("3", "3");
    map.firstKey();
    map.nextKey("1");
}
 
Example #2
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 6 votes vote down vote up
public void testLastKey() {
    resetEmpty();
    OrderedMap<K, V> ordered = getMap();
    try {
        ordered.lastKey();
        fail();
    } catch (final NoSuchElementException ex) {}

    resetFull();
    ordered = getMap();
    K confirmedLast = null;
    for (final Iterator<K> it = confirmed.keySet().iterator(); it.hasNext();) {
        confirmedLast = it.next();
    }
    assertEquals(confirmedLast, ordered.lastKey());
}
 
Example #3
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 5 votes vote down vote up
public void testFirstKey() {
    resetEmpty();
    OrderedMap<K, V> ordered = getMap();
    try {
        ordered.firstKey();
        fail();
    } catch (final NoSuchElementException ex) {}

    resetFull();
    ordered = getMap();
    final K confirmedFirst = confirmed.keySet().iterator().next();
    assertEquals(confirmedFirst, ordered.firstKey());
}
 
Example #4
Source File: MavenizationService.java    From windup with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sorts the submodules of given Pom so that their cross-dependencies are satisfied if built in that order.
 * TODO - MIGR-236.
 */
private OrderedMap<String, Pom> sortSubmodulesToReflectDependencies(Pom pom)
{
    Set<MavenCoord> dependenciesMet = new HashSet();
    dependenciesMet.add(pom.coord);

    SortedSet<MavenCoord> dependenciesSatisfied = new TreeSet<>();

    for (Dependency dep : pom.dependencies)
    {
        // Traverse the tree, depth-first, take items at node exit.
    }

    throw new UnsupportedOperationException("Not implemented yet.");
}
 
Example #5
Source File: PatriciaTrie2Test.java    From jesterj with Apache License 2.0 4 votes vote down vote up
@Override
public OrderedMap<CharSequence, V> makeObject() {
  return new PatriciaTrie<>();
}
 
Example #6
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public OrderedMap<K, V> makeFullMap() {
    return (OrderedMap<K, V>) super.makeFullMap();
}
 
Example #7
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 4 votes vote down vote up
@Override
public OrderedMap<K, V> getMap() {
    // assumes makeFullMapIterator() called first
    return AbstractOrderedMapTest.this.getMap();
}
 
Example #8
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public OrderedMap<K, V> getMap() {
    return (OrderedMap<K, V>) super.getMap();
}
 
Example #9
Source File: OrderedMapUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
private void loadOrderedMapOfRunners(OrderedMap<String, Integer> runners) {
    for (int i = 0; i < RUNNERS_COUNT; i++) {
        runners.put(this.names[i], this.ages[i]);
    }
}
 
Example #10
Source File: Pom.java    From windup with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Contains submodules of this Maven module.
 */
public OrderedMap<String, Pom> getSubmodules()
{
    return submodules;
}
 
Example #11
Source File: Pom.java    From windup with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Contains submodules of this Maven module.
 */
public Pom setSubmodules(OrderedMap<String, Pom> submodules)
{
    this.submodules = submodules;
    return this;
}
 
Example #12
Source File: AbstractOrderedMapTest.java    From jesterj with Apache License 2.0 2 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public abstract OrderedMap<K, V> makeObject();