Example usage for java.util TreeSet TreeSet

List of usage examples for java.util TreeSet TreeSet

Introduction

In this page you can find the example usage for java.util TreeSet TreeSet.

Prototype

public TreeSet() 

Source Link

Document

Constructs a new, empty tree set, sorted according to the natural ordering of its elements.

Usage

From source file:de.shadowhunt.sonar.plugins.ignorecode.model.IssuePatternTest.java

@Test
public void testAddLines() throws Exception {
    final SortedSet<Integer> lines = new TreeSet<>();
    IssuePattern.addLines(lines, 2, 2);/*from w w w .  j av a 2 s  .co m*/
    IssuePattern.addLines(lines, 4, 6);
    final IssuePattern pattern = new IssuePattern("resourcePattern", "rulePattern", lines);

    final SortedSet<Integer> full = pattern.getLines();
    Assert.assertNotNull("SortedSet must not be null", full);
    Assert.assertEquals("SortedSet must contain the exact number of entries", 4, full.size());
    Assert.assertTrue("SortedSet must contain line 2", full.contains(2));
    Assert.assertTrue("SortedSet must contain line 4", full.contains(4));
    Assert.assertTrue("SortedSet must contain line 5", full.contains(5));
    Assert.assertTrue("SortedSet must contain line 6", full.contains(6));
}

From source file:fi.smaa.libror.PerformanceMatrix.java

private void initializeLevelIndices() {
    for (int i = 0; i < getNrCrit(); i++) {
        SortedSet<Double> s = new TreeSet<Double>();
        for (Double d : levels[i].toArray()) {
            s.add(d);//from  ww  w  . j a va2s  . c om
        }
        Double[] arr = s.toArray(new Double[0]);
        int[] colIndices = new int[getNrAlts()];
        for (int j = 0; j < getNrAlts(); j++) {
            for (int k = 0; k < arr.length; k++) {
                if (arr[k] == matrix.getEntry(j, i)) {
                    colIndices[j] = k;
                    break;
                }
            }
        }
        levelIndices.add(colIndices);
    }
}

From source file:edu.pitt.dbmi.deep.phe.i2b2.I2b2OntologyBuilder.java

private TreeSet<PartialPath> extractOntologyPartialPaths() throws OWLOntologyCreationException, IOException {

    final TreeSet<PartialPath> partialPaths = new TreeSet<PartialPath>();

    OWLOntologyManager m = OWLManager.createOWLOntologyManager();
    // OWLOntology o = m.loadOntologyFromOntologyDocument(pizza_iri);
    OWLOntology o = loadDeepPheOntology(m);
    OWLReasonerFactory reasonerFactory;//from   w w w. j a  v  a 2  s. c om
    reasonerFactory = new StructuralReasonerFactory();
    OWLReasoner reasoner = reasonerFactory.createReasoner(o);
    OWLDataFactory fac = m.getOWLDataFactory();
    OWLClass elementConcept = fac.getOWLClass(IRI.create(CONST_TOP_LEVEL_ENTRY));

    final Queue<PartialPath> partialPathQueue = new LinkedList<PartialPath>();
    NodeSet<OWLClass> subClses = reasoner.getSubClasses(elementConcept, true);
    for (Node<OWLClass> subCls : subClses) {
        PartialPath path = new PartialPath();
        path.setReasoner(reasoner);
        path.setCls(subCls.getRepresentativeElement());
        path.setLevel(1);
        partialPathQueue.add(path);
    }

    while (true) {
        PartialPath path;
        path = partialPathQueue.poll();
        if (path == null) {
            break;
        } else {
            partialPathQueue.addAll(path.expand());
        }
        partialPaths.add(path);
    }

    PartialPath topLevel = new PartialPath();
    topLevel.setPath("\\DEEPPHE");
    topLevel.setLevel(0);
    topLevel.setLeaf(false);
    partialPaths.add(topLevel);

    return partialPaths;
}

From source file:edu.umass.cs.reconfiguration.reconfigurationutils.ReconfigurableSampleNodeConfig.java

@Override
public Set<Integer> getReconfigurators() {
    Set<Integer> allNodes = this.getNodeIDs();
    Set<Integer> generatedRCs = new TreeSet<Integer>();
    int count = 0;
    for (Integer id : allNodes) {
        generatedRCs.add(numberToRC(id));
        if (++count == this.numRCs)
            break;
    }/*from   w  ww.j  av  a2 s . c o m*/
    return generatedRCs;
}

From source file:com.jaeksoft.searchlib.autocompletion.AutoCompletionManager.java

public AutoCompletionManager(Config config) throws SearchLibException, IOException {
    this.config = config;
    autoCompletionDirectory = new File(config.getDirectory(), autoCompletionSubDirectory);
    if (!autoCompletionDirectory.exists())
        autoCompletionDirectory.mkdir();
    autoCompItems = new TreeSet<AutoCompletionItem>();
    File[] autoCompFiles = autoCompletionDirectory.listFiles((FileFilter) new SuffixFileFilter(".xml"));
    if (autoCompFiles == null)
        return;//from  w w w.ja v  a 2s  .com
    for (File autoCompFile : autoCompFiles) {
        try {
            add(new AutoCompletionItem(config, autoCompFile));
        } catch (InvalidPropertiesFormatException e) {
            Logging.warn("Invalid autocompletion file: " + autoCompFile.getAbsolutePath());
        }
    }
}

From source file:com.mycsense.carbondb.domain.Group.java

public Group(DimensionSet dimSet) {
    this(dimSet, new TreeSet<Keyword>());
}

From source file:com.jaeksoft.searchlib.user.User.java

public User() {
    indexRoles = new TreeSet<IndexRole>();
}

From source file:com.thoughtworks.go.config.ResourceConfigs.java

public List<String> resourceNames() {
    Set<String> names = new TreeSet<>();
    for (ResourceConfig resourceConfig : this) {
        names.add(resourceConfig.getName());
    }// w  ww  .  java2s  . co m
    return new ArrayList<>(names);
}

From source file:org.apache.streams.messaging.aggregation.ActivityAggregator.java

public void updateSubscriber(ActivityStreamsSubscriber subscriber) {
    Set<String> activities = new TreeSet<String>();
    activities.addAll(activityService.getActivitiesForFilters(
            subscriber.getActivityStreamsSubscriberConfiguration().getFilters(), subscriber.getLastUpdated()));
    //TODO: an activity posted in between the cql query and setting the lastUpdated field will be lost
    subscriber.setLastUpdated(new Date());
    subscriber.receive(new ArrayList<String>(activities));
}

From source file:com.thoughtworks.go.config.Resources.java

public List<String> resourceNames() {
    Set<String> names = new TreeSet<String>();
    for (Resource resource : this) {
        names.add(resource.getName());//from  ww w. j  a va  2s  .  c  om
    }
    return new ArrayList<String>(names);
}