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:technology.tikal.accounts.model.InternalAccount.java

private InternalAccount() {
    this.usedOtpTokens = new TreeSet<>();
}

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

@Test
public void testAddLine() throws Exception {
    final SortedSet<Integer> lines = new TreeSet<>();
    lines.add(1);/* w w  w . j a v a 2 s.  c  om*/
    lines.add(3);
    lines.add(5);
    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", 3, full.size());
    Assert.assertTrue("SortedSet must contain line 1", full.contains(1));
    Assert.assertTrue("SortedSet must contain line 3", full.contains(3));
    Assert.assertTrue("SortedSet must contain line 5", full.contains(5));
}

From source file:cooperativegametheory.Partition.java

public Partition(int[][] partition, PlayerSet onPlayerSet) {
    //TODO cleanup
    this.players = onPlayerSet;
    TreeSet<Integer> seen = new TreeSet<Integer>();
    for (int i = 0; i < partition.length; i++) {
        Coalition component = new Coalition(players);
        for (int j = 0; j < partition[i].length; j++) {
            if (!players.contains(partition[i][j])) {
                throw new IllegalArgumentException(
                        "agument 1 is not a proper partition (component members must be from the PlayerSet)");
            } else {
                if (!component.add(partition[i][j])) {
                    throw new IllegalArgumentException(
                            "agument 1 is not a proper partition (components must be a set)");
                }/*from  w w  w.  j  a v a 2s  . c  o  m*/
            }
            if (!seen.add(partition[i][j])) {
                throw new IllegalArgumentException(
                        "agument 1 is not a proper partition (components must be disjoint)");
            }
        }
        if (!this.add(component)) {
            throw new IllegalArgumentException(
                    "agument 1 is not a proper partition (this error should never appear ?!)");
        }
    }
    for (int i = 0; i < players.size(); i++) {
        if (!seen.contains(i)) {
            throw new IllegalArgumentException("agument 1 is not a proper partition (not complete)");
        }
    }
}

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

public Dimension(String id) {
    this.id = id;
    keywords = new TreeSet<>();
    keywordsPosition = new HashMap<>();
}

From source file:com.linkedin.pinot.operator.filter.OrOperatorTest.java

@Test
public void testUnionForTwoLists() {
    int[] docIds1 = new int[] { 2, 3, 10, 15, 16, 28 };
    int[] docIds2 = new int[] { 3, 6, 8, 20, 28 };
    TreeSet<Integer> treeSet = new TreeSet<>();
    treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds1)));
    treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds2)));
    Iterator<Integer> expectedIterator = treeSet.iterator();

    List<BaseFilterOperator> operators = new ArrayList<>();
    operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds1));
    operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds2));
    OrOperator orOperator = new OrOperator(operators);

    BlockDocIdIterator iterator = orOperator.nextBlock().getBlockDocIdSet().iterator();
    int docId;//from   w w  w.j ava2 s .c o  m
    while ((docId = iterator.next()) != Constants.EOF) {
        Assert.assertEquals(docId, expectedIterator.next().intValue());
    }
}

From source file:com.entertailion.android.shapeways.api.Request.java

public Request(String httpMethod) {
    this.httpMethod = httpMethod;
    parameters = new TreeSet<String>();
}

From source file:com.alibaba.jstorm.task.backpressure.TargetBackpressureInfo.java

public TargetBackpressureInfo() {
    this.tasks = new TreeSet<Integer>();
    this.backpressureStatus = EventType.defaultType;
    this.flowCtrlTime = -1;
    this.timeStamp = 0l;
}

From source file:com.kixeye.chassis.transport.shared.PropertiesServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    // get list of properties
    TreeSet<String> properties = new TreeSet<String>();
    AbstractConfiguration config = ConfigurationManager.getConfigInstance();
    Iterator<String> keys = config.getKeys();
    while (keys.hasNext()) {
        String key = keys.next();
        Object value = config.getProperty(key);
        if ("aws.accessId".equals(key) || "aws.secretKey".equals(key)
                || "experiments-service.secret".equals(key) || "java.class.path".equals(key)
                || key.contains("framework.securityDefinition") || key.contains("password")
                || key.contains("secret")) {
            value = "*****";
        }//from   w w w . j  a v a2s.  c o m
        properties.add(key + "=" + value.toString());
    }

    // write them out in sorted order
    for (String line : properties) {
        resp.getWriter().append(line).println();
    }
}

From source file:edu.cmu.sphinx.speakerid.SpeakerCluster.java

public SpeakerCluster(SpeakerCluster c) {
    this.segmentSet = new TreeSet<Segment>();
    this.featureMatrix = new Array2DRowRealMatrix(c.getFeatureMatrix().getData());
    Iterator<Segment> it = c.segmentSet.iterator();
    while (it.hasNext())
        this.addSegment(it.next());
}

From source file:io.dockstore.webservice.helpers.EntryLabelHelper.java

public T updateLabels(T entry, String labelStrings) {

    if (labelStrings.length() == 0) {
        entry.setLabels(new TreeSet<>());
    } else {// www  . j a  va 2s. c  o m
        Set<String> labelStringSet = new HashSet<>(
                Arrays.asList(labelStrings.toLowerCase().split("\\s*,\\s*")));
        final String labelStringPattern = "^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$";

        // This matches the restriction on labels to 255 characters
        // if this is changed then the java object/mapped db schema needs to be changed
        final int labelMaxLength = 255;
        SortedSet<Label> labels = new TreeSet<>();
        for (final String labelString : labelStringSet) {
            if (labelString.length() <= labelMaxLength && labelString.matches(labelStringPattern)) {
                Label label = labelDAO.findByLabelValue(labelString);
                if (label != null) {
                    labels.add(label);
                } else {
                    label = new Label();
                    label.setValue(labelString);
                    long id = labelDAO.create(label);
                    labels.add(labelDAO.findById(id));
                }
            } else {
                throw new CustomWebApplicationException("Invalid label format", HttpStatus.SC_BAD_REQUEST);
            }
        }
        entry.setLabels(labels);
    }

    return entry;
}