本文整理了Java中java.util.SortedSet.size()
方法的一些代码示例,展示了SortedSet.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SortedSet.size()
方法的具体详情如下:
包路径:java.util.SortedSet
类名称:SortedSet
方法名:size
暂无
代码示例来源:origin: loklak/loklak_server
private static SortedSet<File> tailSet(SortedSet<File> set, int count) {
if (count >= set.size()) return set;
TreeSet<File> t = new TreeSet<File>();
Iterator<File> fi = set.iterator();
for (int i = 0; i < set.size() - count; i++) fi.next();
while (fi.hasNext()) t.add(fi.next());
return t;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Find the requested number of available ports for this {@code SocketType},
* each randomly selected from the range [{@code minPort}, {@code maxPort}].
* @param numRequested the number of available ports to find
* @param minPort the minimum port number
* @param maxPort the maximum port number
* @return a sorted set of available port numbers for this socket type
* @throws IllegalStateException if the requested number of available ports could not be found
*/
SortedSet<Integer> findAvailablePorts(int numRequested, int minPort, int maxPort) {
Assert.isTrue(minPort > 0, "'minPort' must be greater than 0");
Assert.isTrue(maxPort > minPort, "'maxPort' must be greater than 'minPort'");
Assert.isTrue(maxPort <= PORT_RANGE_MAX, "'maxPort' must be less than or equal to " + PORT_RANGE_MAX);
Assert.isTrue(numRequested > 0, "'numRequested' must be greater than 0");
Assert.isTrue((maxPort - minPort) >= numRequested,
"'numRequested' must not be greater than 'maxPort' - 'minPort'");
SortedSet<Integer> availablePorts = new TreeSet<>();
int attemptCount = 0;
while ((++attemptCount <= numRequested + 100) && availablePorts.size() < numRequested) {
availablePorts.add(findAvailablePort(minPort, maxPort));
}
if (availablePorts.size() != numRequested) {
throw new IllegalStateException(String.format(
"Could not find %d available %s ports in the range [%d, %d]",
numRequested, name(), minPort, maxPort));
}
return availablePorts;
}
}
代码示例来源:origin: wildfly/wildfly
public static void main(String[] args) {
SortedSet<Integer> set=new TreeSet<>();
for(int i=0; i < args.length; i++) {
set.add(Integer.parseInt(args[i]));
}
int low=set.first(), high=set.last();
System.out.println("input has " + set.size() + " numbers, low=" + low + ", high=" + high);
Set<Integer> correct_set=new HashSet<>();
for(int i=low; i < high; i++) {
correct_set.add(i);
}
correct_set.removeAll(set);
System.out.println("missing seqnos: " + correct_set);
}
}
代码示例来源:origin: log4j/log4j
final long start = System.currentTimeMillis();
final List filtered = new ArrayList();
final int size = mAllEvents.size();
final Iterator it = mAllEvents.iterator();
final EventDetails event = (EventDetails) it.next();
if (matchFilter(event)) {
filtered.add(event);
代码示例来源:origin: linkedin/cruise-control
private List<Long> toWindows(SortedSet<Long> windowIndexes) {
List<Long> windows = new ArrayList<>(windowIndexes.size());
windowIndexes.forEach(i -> windows.add(i * _windowMs));
return windows;
}
代码示例来源:origin: oracle/opengrok
if (projects.isEmpty()) {
name = new String[]{"/"};
} else if (projects.size() == 1) {
name = new String[]{projects.first()};
} else {
name = new String[projects.size()];
int ii = 0;
for (String proj : projects) {
|| (s.defs != null && s.defs.length > 0)
|| (s.refs != null && s.refs.length > 0)) {
res.add(s);
代码示例来源:origin: apache/hive
ImmutableBitSet.of(bottomGroupSet).cardinality(),
relBuilder.peek(), null, aggCall.name);
bottomAggregateCalls.add(newCall);
List<Integer> newArgList = new ArrayList<>();
for (int arg : aggCall.getArgList()) {
newArgList.add(bottomGroupSet.headSet(arg).size());
Lists.newArrayList(bottomGroupSet.size() + nonDistinctAggCallProcessedSoFar);
if (aggCall.getAggregation().getKind() == SqlKind.COUNT) {
newCall =
topAggregateCalls.add(newCall);
代码示例来源:origin: apache/hive
strings.add(info.db);
if(!isPartOfDynamicPartitionInsert && info.type == LockType.SHARED_WRITE) {
writeSet.add(info);
SortedSet<LockInfo> lockSet = new TreeSet<LockInfo>(new LockInfoComparator());
while (rs.next()) {
lockSet.add(new LockInfo(rs));
LockInfo[] locks = lockSet.toArray(new LockInfo[lockSet.size()]);
if(LOG.isTraceEnabled()) {
LOG.trace("Locks to check(full): ");
代码示例来源:origin: apache/hbase
Address firstServer = servers.iterator().next();
RSGroupInfo srcGrp = rsGroupInfoManager.getRSGroupOfServer(firstServer);
if (srcGrp == null) {
if (srcGrp.getServers().size() <= servers.size() && srcGrp.getTables().size() > 0) {
throw new ConstraintException("Cannot leave a RSGroup " + srcGrp.getName() +
" that contains tables without servers to host them.");
foundRegionsToMove = false;
for (Iterator<Address> iter = editableMovedServers.iterator(); iter.hasNext();) {
Address rs = iter.next();
代码示例来源:origin: wildfly/wildfly
.map(set -> set.iterator().next()).collect(Collectors.toList()));
if(coords.size() <= 1) {
log.trace("%s: cancelling merge as we only have 1 coordinator: %s", local_addr, coords);
return;
if(max_participants_in_merge > 0 && coords.size() > max_participants_in_merge) {
int old_size=coords.size();
coords.removeIf(next -> coords.size() > max_participants_in_merge);
log.trace("%s: reduced %d coords to %d", local_addr, old_size, max_participants_in_merge);
代码示例来源:origin: hibernate/hibernate-orm
Baz baz = new Baz();
SortedSet stringSet = new TreeSet();
stringSet.add("foo");
stringSet.add("bar");
Set fooSet = new HashSet();
for (int i=0; i<3; i++) {
Baz baz3 = new Baz();
stringSet = new TreeSet();
stringSet.add("foo");
stringSet.add("baz");
baz3.setStringSet(stringSet);
assertTrue( baz3.getStringSet().contains("baz") );
assertTrue( Hibernate.isInitialized(baz.getStringSet()) && Hibernate.isInitialized(baz2.getStringSet()) && Hibernate.isInitialized(baz3.getStringSet()));
assertTrue( baz.getStringSet().size()==2 && baz2.getStringSet().size()==0 );
s.delete(baz);
s.delete(baz2);
s.delete(baz3);
Iterator iter = new JoinedIterator( new Iterator[] { baz.getFooSet().iterator(), baz2.getFooSet().iterator() } );
while ( iter.hasNext() ) s.delete( iter.next() );
s.getTransaction().commit();
s.close();
代码示例来源:origin: apache/accumulo
private void validateEntries(SortedMap<KeyExtent,String> tablets) throws AccumuloException {
SortedSet<KeyExtent> tabletsKeys = (SortedSet<KeyExtent>) tablets.keySet();
// sanity check of metadata table entries
// make sure tablets has no holes, and that it starts and ends w/ null
if (tabletsKeys.size() == 0)
throw new AccumuloException(
"No entries found in metadata table for table " + getServicedTableId());
if (tabletsKeys.first().getPrevEndRow() != null)
throw new AccumuloException("Problem with metadata table, first entry for table "
+ getServicedTableId() + "- " + tabletsKeys.first() + " - has non null prev end row");
if (tabletsKeys.last().getEndRow() != null)
throw new AccumuloException("Problem with metadata table, last entry for table "
+ getServicedTableId() + "- " + tabletsKeys.first() + " - has non null end row");
Iterator<KeyExtent> tabIter = tabletsKeys.iterator();
Text lastEndRow = tabIter.next().getEndRow();
while (tabIter.hasNext()) {
KeyExtent tabke = tabIter.next();
if (tabke.getPrevEndRow() == null)
throw new AccumuloException(
"Problem with metadata table, it has null prev end row in middle of table " + tabke);
if (!tabke.getPrevEndRow().equals(lastEndRow))
throw new AccumuloException("Problem with metadata table, it has a hole "
+ tabke.getPrevEndRow() + " != " + lastEndRow);
lastEndRow = tabke.getEndRow();
}
// end METADATA table sanity check
}
代码示例来源:origin: apache/incubator-druid
@Override
public DimFilter optimize()
{
InDimFilter inFilter = optimizeLookup();
if (inFilter.values.size() == 1) {
return new SelectorDimFilter(inFilter.dimension, inFilter.values.first(), inFilter.getExtractionFn());
}
return inFilter;
}
代码示例来源:origin: aragozin/jvm-tools
long[] getBiggestObjectsByRetainedSize(int number) {
SortedSet<RetainedSizeEntry> bigObjects = new TreeSet<RetainedSizeEntry>();
long[] bigIds = new long[number];
long min = 0;
for (long index=0;index<fileSize;index+=ENTRY_SIZE) {
long id = getID(index);
if (id != 0) {
long retainedSize = createEntry(index).getRetainedSize();
if (bigObjects.size()<number) {
bigObjects.add(new RetainedSizeEntry(id,retainedSize));
min = ((RetainedSizeEntry)bigObjects.last()).retainedSize;
} else if (retainedSize>min) {
bigObjects.remove(bigObjects.last());
bigObjects.add(new RetainedSizeEntry(id,retainedSize));
min = ((RetainedSizeEntry)bigObjects.last()).retainedSize;
}
}
}
int i = 0;
Iterator<RetainedSizeEntry> it = bigObjects.iterator();
while(it.hasNext()) {
bigIds[i++]=((RetainedSizeEntry)it.next()).instanceId;
}
return bigIds;
}
代码示例来源:origin: Graylog2/graylog2-server
@GET
@Timed
@ApiOperation(value = "Get a list of all index ranges")
@Produces(MediaType.APPLICATION_JSON)
public IndexRangesResponse list() {
final SortedSet<IndexRange> all = indexRangeService.findAll();
final List<IndexRangeSummary> ranges = Lists.newArrayListWithCapacity(all.size());
for (IndexRange range : all) {
if (!isPermitted(RestPermissions.INDEXRANGES_READ, range.indexName())) {
continue;
}
final IndexRangeSummary indexRange = IndexRangeSummary.create(
range.indexName(),
range.begin(),
range.end(),
range.calculatedAt(),
range.calculationDuration()
);
ranges.add(indexRange);
}
return IndexRangesResponse.create(ranges.size(), ranges);
}
代码示例来源:origin: apache/kylin
public static ArrayList<Range<Integer>> buildRanges(SortedSet<Integer> values) {
ArrayList<Range<Integer>> ranges = Lists.newArrayList();
if (values == null || values.isEmpty())
return ranges;
Iterator<Integer> iter = values.iterator();
int lastBegin = iter.next();
int lastEnd = lastBegin;
int temp = 0;
for (int index = 1; index < values.size(); index++) {
temp = iter.next();
if (temp - lastEnd != 1) {
ranges.add(Range.closed(lastBegin, lastEnd));
lastBegin = temp;
}
lastEnd = temp;
}
ranges.add(Range.closed(lastBegin, lastEnd));
return ranges;
}
}
代码示例来源:origin: pentaho/mondrian
constrainedColumn,
true);
} else if (values.size() == 1) {
predicate =
new ValueColumnPredicate(
constrainedColumn,
values.first());
} else {
final List<StarColumnPredicate> valuePredicateList =
new ArrayList<StarColumnPredicate>();
for (Object value : values) {
valuePredicateList.add(
new ValueColumnPredicate(
constrainedColumn,
valuePredicateList);
predicateList.add(predicate);
代码示例来源:origin: pentaho/mondrian
if (keepColumns.contains(column.columnExpression)) {
final AxisInfo axisInfo = new AxisInfo();
axes.add(axisInfo);
axisInfo.src = j;
axisInfo.column = column;
axis.valueSet.toArray(new Comparable[axis.valueSet.size()]);
valueArrays[z] = keepColumns.contains(
firstHeaderConstrainedColumns.get(z).columnExpression)
? set.toArray(new Comparable[set.size()])
: null;
++z;
final int targetOrdinal;
if (axes.get(z).hasNull && ordinal == valueArray.length) {
targetOrdinal = axes.get(z).valueSet.size();
} else {
final Comparable value = valueArray[ordinal];
if (value == null) {
targetOrdinal = axes.get(z).valueSet.size();
} else {
targetOrdinal =
cellValues.get(ck).add(vEntry.getValue());
addedIntersections.add(colValues);
代码示例来源:origin: apache/hbase
String targetGroupName) throws IOException {
Address firstServer = servers.iterator().next();
RSGroupInfo tmpSrcGrp = rsGroupInfoManager.getRSGroupOfServer(firstServer);
if (tmpSrcGrp == null) {
if (srcGrp.getServers().size() <= servers.size() && srcGrp.getTables().size() > tables.size()) {
throw new ConstraintException("Cannot leave a RSGroup " + srcGrp.getName() +
" that contains tables without servers to host them.");
代码示例来源:origin: apache/geode
/**
* @return a list of region names hosted on the system
*/
public String[] listAllRegionPaths() {
if (distrRegionMap.values().size() == 0) {
return ManagementConstants.NO_DATA_STRING;
}
// Sort region paths
SortedSet<String> regionPathsSet = new TreeSet<>();
for (DistributedRegionBridge bridge : distrRegionMap.values()) {
regionPathsSet.add(bridge.getFullPath());
}
String[] regionPaths = new String[regionPathsSet.size()];
regionPaths = regionPathsSet.toArray(regionPaths);
regionPathsSet.clear();
return regionPaths;
}
内容来源于网络,如有侵权,请联系作者删除!