@Override public SortedSet<V> get() { return new TreeSet<V>(comparator); } }
TreeSet<String> set = new TreeSet<String>(); set.add("lol"); set.add("cat"); // automatically sorts natural order when adding for (String s : set) { System.out.println(s); } // Prints out "cat" and "lol"
/** * Sorted list of unique max-versions in the data set. For select list in jelly. */ @Restricted(NoExternalUse.class) public Iterator<VersionNumber> getVersionList() { TreeSet<VersionNumber> set = new TreeSet<VersionNumber>(); for (VersionRange vr : data.values()) { if (vr.max != null) { set.add(vr.max); } } return set.iterator(); }
/** * Returns the vertices that are "leftmost, rightmost" Note this requires that the IndexedFeatureLabels present actually have * ordering information. * TODO: can be done more efficiently? */ public static Pair<IndexedWord, IndexedWord> leftRightMostChildVertices(IndexedWord startNode, SemanticGraph sg) { TreeSet<IndexedWord> vertices = new TreeSet<>(); for (IndexedWord vertex : sg.descendants(startNode)) { vertices.add(vertex); } return Pair.makePair(vertices.first(), vertices.last()); }
/** * Returns the vertice that is "leftmost." Note this requires that the IndexedFeatureLabels present actually have * ordering information. * TODO: can be done more efficiently? */ public static IndexedWord leftMostChildVertice(IndexedWord startNode, SemanticGraph sg) { TreeSet<IndexedWord> vertices = new TreeSet<>(); for (IndexedWord vertex : sg.descendants(startNode)) { vertices.add(vertex); } return vertices.first(); }
/** * Returns a list of plugins that should be shown in the "available" tab, grouped by category. * A plugin with multiple categories will appear multiple times in the list. */ public PluginEntry[] getCategorizedAvailables() { TreeSet<PluginEntry> entries = new TreeSet<PluginEntry>(); for (Plugin p : getAvailables()) { if (p.categories==null || p.categories.length==0) entries.add(new PluginEntry(p, getCategoryDisplayName(null))); else for (String c : p.categories) entries.add(new PluginEntry(p, getCategoryDisplayName(c))); } return entries.toArray(new PluginEntry[entries.size()]); }
public CategoryDataset build() { DefaultCategoryDataset ds = new DefaultCategoryDataset(); TreeSet<Row> rowSet = new TreeSet<Row>(rows); TreeSet<Column> colSet = new TreeSet<Column>(columns); Comparable[] _rows = rowSet.toArray(new Comparable[rowSet.size()]); Comparable[] _cols = colSet.toArray(new Comparable[colSet.size()]); // insert rows and columns in the right order for (Comparable r : _rows) ds.setValue(null, r, _cols[0]); for (Comparable c : _cols) ds.setValue(null, _rows[0], c); for( int i=0; i<values.size(); i++ ) ds.addValue( values.get(i), rows.get(i), columns.get(i) ); return ds; } }
public void add(PartitionChunk<T> chunk) { holderSet.add(chunk); }
private void processPartitionMovement(TopicPartition partition, String newConsumer, Map<String, List<TopicPartition>> currentAssignment, TreeSet<String> sortedCurrentSubscriptions, Map<TopicPartition, String> currentPartitionConsumer) { String oldConsumer = currentPartitionConsumer.get(partition); sortedCurrentSubscriptions.remove(oldConsumer); sortedCurrentSubscriptions.remove(newConsumer); partitionMovements.movePartition(partition, oldConsumer, newConsumer); currentAssignment.get(oldConsumer).remove(partition); currentAssignment.get(newConsumer).add(partition); currentPartitionConsumer.put(partition, newConsumer); sortedCurrentSubscriptions.add(newConsumer); sortedCurrentSubscriptions.add(oldConsumer); }
@Override public int size() { return treeSet.size(); }
public Builder( User base ) { name = base.name; credential = base.credential; flags.addAll( base.flags ); }