本文整理了Java中java.util.TreeSet.size()
方法的一些代码示例,展示了TreeSet.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeSet.size()
方法的具体详情如下:
包路径:java.util.TreeSet
类名称:TreeSet
方法名:size
[英]Returns the number of elements in this TreeSet.
[中]返回此树集中的元素数。
代码示例来源:origin: apache/storm
public String getDescription() {
final int size = data.size();
if (size > 0) {
final TimeData first = data.first();
final TimeData last = data.last();
return "Total " + size + " items: " + first + " to " + last;
}
return "Total " + size + " items.";
}
代码示例来源:origin: apache/hbase
public byte[][] getColumns() {
return columns.toArray(new byte[columns.size()][]);
}
代码示例来源:origin: alibaba/jstorm
@SuppressWarnings("unchecked")
@Override
public TreeSet<T> update(Number object, TreeSet<T> cache, Object... others) {
// TODO Auto-generated method stub
if (cache == null) {
cache = new TreeSet<T>(comparator);
}
cache.add((T) object);
if (cache.size() > n) {
cache.remove(cache.last());
}
return cache;
}
代码示例来源:origin: org.apache.commons/commons-math3
/**
* Returns an array consisting of the unique values in {@code data}.
* The return array is sorted in descending order. Empty arrays
* are allowed, but null arrays result in NullPointerException.
* Infinities are allowed. NaN values are allowed with maximum
* sort order - i.e., if there are NaN values in {@code data},
* {@code Double.NaN} will be the first element of the output array,
* even if the array also contains {@code Double.POSITIVE_INFINITY}.
*
* @param data array to scan
* @return descending list of values included in the input array
* @throws NullPointerException if data is null
* @since 3.6
*/
public static double[] unique(double[] data) {
TreeSet<Double> values = new TreeSet<Double>();
for (int i = 0; i < data.length; i++) {
values.add(data[i]);
}
final int count = values.size();
final double[] out = new double[count];
Iterator<Double> iterator = values.iterator();
int i = 0;
while (iterator.hasNext()) {
out[count - ++i] = iterator.next();
}
return out;
}
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testMixedElevationExtraction() throws IOException {
MockDimensionReader reader = new MockDimensionReader();
reader.metadata.put(GridCoverage2DReader.HAS_ELEVATION_DOMAIN, "true");
reader.metadata.put(GridCoverage2DReader.ELEVATION_DOMAIN, "0/0/0,10,15/20/1");
ReaderDimensionsAccessor accessor = new ReaderDimensionsAccessor(reader);
TreeSet<Object> domain = accessor.getElevationDomain();
assertEquals(3, domain.size());
Iterator<Object> it = domain.iterator();
Number firstEntry = (Number) it.next();
assertEquals(0, firstEntry.doubleValue(), 0d);
Number secondEntry = (Number) it.next();
assertEquals(10, secondEntry.doubleValue(), 0d);
NumberRange thirdEntry = (NumberRange) it.next();
assertEquals(15, thirdEntry.getMinimum(), 0d);
assertEquals(20, thirdEntry.getMaximum(), 0d);
}
代码示例来源:origin: geotools/geotools
while (it.hasNext()) {
IncludeHandler inc = (IncludeHandler) it.next();
logger.finest("compressing include " + inc.getSchemaLocation());
it = this.imports.iterator();
while (it.hasNext()) {
Object obj = it.next();
TreeSet tmp = new TreeSet(SchemaComparator.getInstance());
tmp.addAll(imports);
schema1.imports = (Schema[]) tmp.toArray(new Schema[tmp.size()]);
schema1.simpleTypes = (SimpleType[]) tmp.toArray(new SimpleType[tmp.size()]);
tmp.addAll(attributeGroups);
schema1.attributeGroups =
(AttributeGroup[]) tmp.toArray(new AttributeGroup[tmp.size()]);
schema1.attributes = (Attribute[]) tmp.toArray(new Attribute[tmp.size()]);
schema1.complexTypes = (ComplexType[]) tmp.toArray(new ComplexType[tmp.size()]);
schema1.elements = (Element[]) tmp.toArray(new Element[tmp.size()]);
schema1.groups = (Group[]) tmp.toArray(new Group[tmp.size()]);
代码示例来源:origin: apache/kylin
@Override
public String next() {
String r = input.next();
if (cache.size() < card) {
cache.add(r);
return r;
}
r = cache.floor(r);
return r == null ? cache.first() : r;
}
}
代码示例来源:origin: apache/storm
@Override
protected String getCompletedOffset() {
String offset = null;
if (pending.size() > 0) {
//find the smallest offset in pending list
offset = pending.keySet().iterator().next();
}
if (toResend.size() > 0) {
//find the smallest offset in toResend list
String offset2 = toResend.first().getMessageId().getOffset();
if (offset == null || offset2.compareTo(offset) < 0) {
offset = offset2;
}
}
if (offset == null) {
offset = lastOffset;
}
return offset;
}
}
代码示例来源:origin: apache/phoenix
private void validateTraces(List<Span> spans, Connection conn, long traceid, String tableName)
throws Exception {
TraceReader reader = new TraceReader(conn, tableName);
Collection<TraceHolder> traces = reader.readAll(1);
assertEquals("Got an unexpected number of traces!", 1, traces.size());
// make sure the trace matches what we wrote
TraceHolder trace = traces.iterator().next();
assertEquals("Got an unexpected traceid", traceid, trace.traceid);
assertEquals("Got an unexpected number of spans", spans.size(), trace.spans.size());
validateTrace(spans, trace);
}
代码示例来源:origin: apache/kylin
@Override
public Long[] listAllVersions() throws IOException {
if (!fileSystem.exists(basePath)) {
return new Long[0]; // for the removed SegmentAppendTrieDictBuilder
}
FileStatus[] versionDirs = fileSystem.listStatus(basePath, new PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().startsWith(VERSION_PREFIX);
}
});
TreeSet<Long> versions = new TreeSet<>();
for (int i = 0; i < versionDirs.length; i++) {
Path path = versionDirs[i].getPath();
versions.add(Long.parseLong(path.getName().substring(VERSION_PREFIX.length())));
}
return versions.toArray(new Long[versions.size()]);
}
代码示例来源:origin: thinkaurelius/titan
CacheEntry<Long, V> ce = entry.getValue();
ce.lastAccessedCopy = ce.lastAccessed;
if (tree.size() < n) {
tree.add(ce);
} else {
if (ce.lastAccessedCopy < tree.first().lastAccessedCopy) {
tree.remove(tree.first());
tree.add(ce);
代码示例来源:origin: quartz-scheduler/quartz
if (timeTriggers.size() == 0)
return result;
tw = timeTriggers.first();
if (tw == null)
break;
timeTriggers.add(tw);
timeTriggers.add(tw);
break;
代码示例来源:origin: alibaba/jstorm
@Override
public TreeSet<T> merge(Collection<TreeSet<T>> objs, TreeSet<T> unflushed, Object... others) {
// TODO Auto-generated method stub
TreeSet<T> temp = new TreeSet<T>(comparator);
if (unflushed != null) {
temp.addAll(unflushed);
}
for (TreeSet<T> set : objs) {
temp.addAll(set);
}
if (temp.size() <= n) {
return temp;
}
TreeSet<T> ret = new TreeSet<T>(comparator);
int i = 0;
for (T item : temp) {
if (i < n) {
ret.add(item);
i++;
} else {
break;
}
}
return ret;
}
代码示例来源:origin: languagetool-org/languagetool
String posUnique = formattedToken.getAnalyzedToken(k).getPOSTag();
if (posUnique == null) {
wordForms.add(formattedToken.getToken());
oneForm = true;
} else {
|| PARAGRAPH_END_TAGNAME.equals(posUnique)) {
if (!oneForm) {
wordForms.add(formattedToken.getToken());
formattedString = wordForms.toArray(new String[wordForms.size()]);
formattedString = wordForms.toArray(new String[wordForms.size()]);
代码示例来源:origin: apache/hbase
List<BackupImage> depList = manifest.getDependentListByTable(table);
set.addAll(depList);
BackupImage[] arr = new BackupImage[set.size()];
set.toArray(arr);
restoreImages(arr, table, tTableArray[i], isOverwrite);
restoreImageSet.addAll(list);
代码示例来源:origin: apache/hive
if (ks.size() <= 1) {
List<String> oneList = new ArrayList<String>(1);
if (ks.size() == 1) {
oneList.add(ks.first());
new ArrayList<Operator<? extends OperatorDesc>>(ks.size());
List<List<ExprNodeDesc>> newSprayKeyLists = new ArrayList<List<ExprNodeDesc>>(ks.size());
List<List<ExprNodeDesc>> newDistinctKeyLists = new ArrayList<List<ExprNodeDesc>>(ks.size());
代码示例来源:origin: apache/hive
private int handleUpdateForSinglePriorityLevel(int remainingCount,
Iterator<Entry<Integer, TreeSet<TaskInfo>>> iterator, TaskInfo failedUpdate,
List<TaskInfo> toUpdate, boolean newValue) {
Entry<Integer, TreeSet<TaskInfo>> entry = iterator.next();
TreeSet<TaskInfo> atPriority = entry.getValue();
WM_LOG.info("At priority " + entry.getKey() + " observing " + entry.getValue().size());
Iterator<TaskInfo> atPriorityIter = newValue ? atPriority.iterator() : atPriority.descendingIterator();
TreeMap<Integer, TreeSet<TaskInfo>> toMap = newValue ? guaranteedTasks : speculativeTasks,
fromMap = newValue ? speculativeTasks : guaranteedTasks;
while (atPriorityIter.hasNext() && remainingCount > 0) {
TaskInfo taskInfo = atPriorityIter.next();
if (taskInfo == failedUpdate) continue;
atPriorityIter.remove();
代码示例来源:origin: geoserver/geoserver
@Test
public void testMixedTimeExtraction() throws IOException, ParseException {
MockDimensionReader reader = new MockDimensionReader();
reader.metadata.put(GridCoverage2DReader.HAS_TIME_DOMAIN, "true");
reader.metadata.put(
GridCoverage2DReader.TIME_DOMAIN,
"2016-02-23T03:00:00.000Z/2016-02-23T03:00:00.000Z/PT1S,2016-02-23T06:00:00.000Z,2016-02-23T09:00:00.000Z/2016-02-23T12:00:00.000Z/PT1S");
ReaderDimensionsAccessor accessor = new ReaderDimensionsAccessor(reader);
TreeSet<Object> domain = accessor.getTimeDomain();
assertEquals(3, domain.size());
Iterator<Object> it = domain.iterator();
Date firstEntry = (Date) it.next();
assertEquals(accessor.getTimeFormat().parse("2016-02-23T03:00:00.000Z"), firstEntry);
Date secondEntry = (Date) it.next();
assertEquals(accessor.getTimeFormat().parse("2016-02-23T06:00:00.000Z"), secondEntry);
DateRange thirdEntry = (DateRange) it.next();
assertEquals(
accessor.getTimeFormat().parse("2016-02-23T09:00:00.000Z"),
thirdEntry.getMinValue());
assertEquals(
accessor.getTimeFormat().parse("2016-02-23T12:00:00.000Z"),
thirdEntry.getMaxValue());
}
代码示例来源:origin: robovm/robovm
@Override
public String[] childrenNames() throws BackingStoreException {
synchronized (lock) {
checkState();
TreeSet<String> result = new TreeSet<String>(cachedNode.keySet());
String[] names = childrenNamesSpi();
for (int i = 0; i < names.length; i++) {
result.add(names[i]);
}
return result.toArray(new String[result.size()]);
}
}
代码示例来源:origin: cmusphinx/sphinx4
public void add(T item) {
items.add(item);
if (items.size() > maxSize)
items.pollFirst();
}
内容来源于网络,如有侵权,请联系作者删除!