Example usage for org.apache.commons.collections.list TreeList TreeList

List of usage examples for org.apache.commons.collections.list TreeList TreeList

Introduction

In this page you can find the example usage for org.apache.commons.collections.list TreeList TreeList.

Prototype

public TreeList() 

Source Link

Document

Constructs a new empty list.

Usage

From source file:ListExampleV1.java

private void createLists() {
    uniqueList = SetUniqueList.decorate(new TreeList());
    cursorList = new CursorableLinkedList();
}

From source file:desmoj.core.simulator.EventTreeList.java

/**
 * Constructs an empty event-list.
 */
EventTreeList() {

    // create event-list
    eTreeList = new TreeList();

}

From source file:de.uni_potsdam.hpi.bpt.promnicat.persistenceApi.orientdbObj.index.IndexIntersection.java

/**
 * Load the intersecting referenced objects from the specified indices.
 * First load the database ids from all indices, intersect them, and load the remaining ids.
 * /*w  ww.jav a 2 s.  com*/
 * @return the resulting {@link IndexCollectionElement}s
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public Collection<IndexCollectionElement<V>> load() {

    //load dbIds only and sort them by result set size
    TreeList rawResults = new TreeList(); //no generics possible
    int maxSize = 0;
    for (AbstractIndex index : indices) {
        ResultSet<V> oneResultSet = new ResultSet<V>(index.loadIdsOnly(), index.getName());
        rawResults.add(oneResultSet);
        maxSize = Math.max(maxSize, oneResultSet.getSize());
    }

    // create a list of intersecting dbIds
    // start with the smallest result set and intersect with the second smallest, intersect this result with the third smallest a.s.o.
    HashSet<String> intersectingDbIds = new HashSet<String>(maxSize);
    for (Object r : rawResults) {
        ResultSet<V> aResult = (ResultSet<V>) r;

        if (intersectingDbIds.isEmpty()) {
            intersectingDbIds.addAll(aResult.getDbIds());
        } else {
            intersectingDbIds.retainAll(aResult.getDbIds());
        }

        if (intersectingDbIds.isEmpty()) {
            break;
        }
    }

    //create Map of IndexElements each, i.e. group by referenced id. Every group is stored in a IndexCollectedElement
    HashMap<String, IndexCollectionElement<V>> finalElements = new HashMap<String, IndexCollectionElement<V>>(
            indices.size());
    for (Object r : rawResults) {
        ResultSet<V> aResult = (ResultSet<V>) r;
        for (IndexElement indexElement : aResult.getList()) {
            String currentString = indexElement.getDbId();
            if (intersectingDbIds.contains(currentString)) {
                if (!finalElements.containsKey(currentString)) {
                    finalElements.put(currentString, new IndexCollectionElement<V>(currentString));
                }
                finalElements.get(currentString).addIndexElements(indexElement);
            }
        }
    }

    //load pojos
    for (IndexCollectionElement<V> collectionElement : finalElements.values()) {
        collectionElement.loadPojo(papi);
    }

    return finalElements.values();
}