本文整理匯總了Java中java.util.TreeSet類的典型用法代碼示例。如果您正苦於以下問題:Java TreeSet類的具體用法?Java TreeSet怎麽用?Java TreeSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TreeSet類屬於java.util包,在下文中一共展示了TreeSet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDownloadEntries
import java.util.TreeSet; //導入依賴的package包/類
public Set<String> getDownloadEntries(final NodeRef downloadNode)
{
return transactionHelper.doInTransaction(new RetryingTransactionCallback<Set<String>>()
{
@Override
public Set<String> execute() throws Throwable
{
Set<String> entryNames = new TreeSet<String>();
ContentReader reader = contentService.getReader(downloadNode, ContentModel.PROP_CONTENT);
try (ZipArchiveInputStream zipInputStream = new ZipArchiveInputStream(reader.getContentInputStream()))
{
ZipArchiveEntry zipEntry = null;
while ((zipEntry = zipInputStream.getNextZipEntry()) != null)
{
String name = zipEntry.getName();
entryNames.add(name);
}
}
return entryNames;
}
});
}
示例2: descSortByLastPlayTime
import java.util.TreeSet; //導入依賴的package包/類
/**
* 按最後播放時間降序排序
*/
public static List<DBSongInfo> descSortByLastPlayTime(List<DBSongInfo> list) {
TreeSet<DBSongInfo> set = new TreeSet<>(new Comparator<DBSongInfo>() {
@Override
public int compare(DBSongInfo o1, DBSongInfo o2) {
int rs;
if (o1.lastPlayTime > o2.lastPlayTime) {
rs = -1;
} else if (o1.lastPlayTime < o2.lastPlayTime) {
rs = 1;
} else {
rs = -1; // equals set 不能重複,會丟失數據
}
return rs;
}
});
for (DBSongInfo s : list) {
set.add(s);
}
return new ArrayList<>(set);
}
示例3: getTransactionTraceSignature
import java.util.TreeSet; //導入依賴的package包/類
protected String getTransactionTraceSignature(Procedure catalog_proc, TransactionTrace txn_trace, Integer interval) {
SortedSet<String> queries = new TreeSet<String>();
for (QueryTrace query_trace : txn_trace.getQueries()) {
Statement catalog_stmt = query_trace.getCatalogItem(catalog_db);
queries.add(this.getQueryTraceSignature(catalog_stmt, query_trace));
} // FOR
String signature = catalog_proc.getName() + "->";
if (interval != null) signature += "INT[" + interval + "]";
signature += this.getParamSignature(txn_trace, this.target_proc_params.get(catalog_proc));
for (String q : queries) {
signature += "\n" + q;
} // FOR
if (trace.val) LOG.trace(txn_trace + " ==> " + signature);
return (signature);
}
示例4: deleteOnExit
import java.util.TreeSet; //導入依賴的package包/類
/**
* Mark a path to be deleted on JVM shutdown.
*
* @param f the existing path to delete.
*
* @return true if deleteOnExit is successful, otherwise false.
*
* @throws AccessControlException If access is denied
* @throws UnsupportedFileSystemException If file system for <code>f</code> is
* not supported
* @throws IOException If an I/O error occurred
*
* Exceptions applicable to file systems accessed over RPC:
* @throws RpcClientException If an exception occurred in the RPC client
* @throws RpcServerException If an exception occurred in the RPC server
* @throws UnexpectedServerException If server implementation throws
* undeclared exception to RPC server
*/
public boolean deleteOnExit(Path f) throws AccessControlException,
IOException {
if (!this.util().exists(f)) {
return false;
}
synchronized (DELETE_ON_EXIT) {
if (DELETE_ON_EXIT.isEmpty()) {
ShutdownHookManager.get().addShutdownHook(FINALIZER, SHUTDOWN_HOOK_PRIORITY);
}
Set<Path> set = DELETE_ON_EXIT.get(this);
if (set == null) {
set = new TreeSet<Path>();
DELETE_ON_EXIT.put(this, set);
}
set.add(f);
}
return true;
}
示例5: addInterfaceElements
import java.util.TreeSet; //導入依賴的package包/類
@Override
public void addInterfaceElements(Interface interfaze) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
FullyQualifiedJavaType parameterType = new FullyQualifiedJavaType(
introspectedTable.getBaseRecordType());
importedTypes.add(parameterType);
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(introspectedTable.getUpdateByPrimaryKeyStatementId());
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
context.getCommentGenerator().addGeneralMethodComment(method,
introspectedTable);
addMapperAnnotations(interfaze, method);
if (context.getPlugins()
.clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(method,
interfaze, introspectedTable)) {
interfaze.addImportedTypes(importedTypes);
interfaze.addMethod(method);
}
}
示例6: getParameters
import java.util.TreeSet; //導入依賴的package包/類
@Parameters
public static Iterable<Object[]> getParameters() {
return Arrays.asList(new Object[][] {
// @formatter:off
// (0) There aren't any unused ports:
{
new StepInput("apps-to-deploy-02.json", new TreeSet<>(Arrays.asList(10002, 10003)), true), new StepOutput(new TreeSet<>(Arrays.asList(10002, 10003))),
},
// (1) There are unused ports:
{
new StepInput("apps-to-deploy-02.json", new TreeSet<>(Arrays.asList(10001, 10002, 10003)), true), new StepOutput(new TreeSet<>(Arrays.asList(10002, 10003))),
},
// (2) Host based routing:
{
new StepInput("apps-to-deploy-02.json", Collections.emptySet(), false), new StepOutput(Collections.emptySet()),
},
// @formatter:on
});
}
示例7: testTreeSet
import java.util.TreeSet; //導入依賴的package包/類
/**
* Tests data serializing an {@link TreeSet}
*/
@Test
public void testTreeSet() throws Exception {
Random random = getRandom();
TreeSet set = new TreeSet();
int size = random.nextInt(50);
for (int i = 0; i < size; i++) {
set.add(new Long(random.nextLong()));
}
DataOutputStream out = getDataOutput();
DataSerializer.writeTreeSet(null, out);
DataSerializer.writeTreeSet(new TreeSet(), out);
DataSerializer.writeTreeSet(set, out);
out.flush();
DataInput in = getDataInput();
assertEquals(null, DataSerializer.readTreeSet(in));
assertEquals(new TreeSet(), DataSerializer.readTreeSet(in));
TreeSet set2 = DataSerializer.readTreeSet(in);
assertEquals(set, set2);
}
示例8: addExtensions
import java.util.TreeSet; //導入依賴的package包/類
private void addExtensions(TarArchiveOutputStream tos, Integration integration) throws IOException {
final Set<String> extensions = collectDependencies(integration).stream()
.filter(Dependency::isExtension)
.map(Dependency::getId)
.collect(Collectors.toCollection(TreeSet::new));
if (!extensions.isEmpty()) {
addTarEntry(tos, "src/main/resources/loader.properties", generateExtensionLoader(extensions));
for (String extensionId : extensions) {
addTarEntry(
tos,
"extensions/" + Names.sanitize(extensionId) + ".jar",
IOUtils.toByteArray(
extensionDataManager.getExtensionBinaryFile(extensionId)
)
);
}
}
}
示例9: unavailableTransformer
import java.util.TreeSet; //導入依賴的package包/類
/**
* Called to identify a transformer that cannot be used during working out
* available transformers.
*/
public void unavailableTransformer(ContentTransformer transformer, String sourceMimetype, String targetMimetype, long maxSourceSizeKBytes)
{
if (isEnabled())
{
Deque<Frame> ourStack = ThreadInfo.getStack();
Frame frame = ourStack.peek();
if (frame != null)
{
Deque<String> isTransformableStack = ThreadInfo.getIsTransformableStack();
String name = (!isTransformableStack.isEmpty())
? isTransformableStack.getFirst()
: getName(transformer);
boolean debug = (maxSourceSizeKBytes != 0);
if (frame.unavailableTransformers == null)
{
frame.unavailableTransformers = new TreeSet<UnavailableTransformer>();
}
String priority = gePriority(transformer, sourceMimetype, targetMimetype);
frame.unavailableTransformers.add(new UnavailableTransformer(name, priority, maxSourceSizeKBytes, debug));
}
}
}
示例10: setupDepartments
import java.util.TreeSet; //導入依賴的package包/類
public static void setupDepartments(HttpServletRequest request, SessionContext context, boolean includeExternal) throws Exception {
TreeSet<Department> departments = Department.getUserDepartments(context.getUser());
if (includeExternal)
departments.addAll(Department.findAllExternal(context.getUser().getCurrentAcademicSessionId()));
List<LabelValueBean> deptList = new ArrayList<LabelValueBean>();
for (Department d: departments) {
String code = d.getDeptCode().trim();
String abbv = d.getName().trim();
if (d.isExternalManager())
deptList.add(new LabelValueBean(code + " - " + abbv + " (" + d.getExternalMgrLabel() + ")", code));
else
deptList.add(new LabelValueBean(code + " - " + abbv, code));
}
request.setAttribute(Department.DEPT_ATTR_NAME, deptList);
}
示例11: addCategory
import java.util.TreeSet; //導入依賴的package包/類
protected boolean addCategory(String id, String category, String value, String score) {
if (noData(category)) return false;
if (noData(value)) return false;
if (noData(score)) return false;
Collection<ClassificationScore> categoryCollection = categories.get(category);
if (categoryCollection == null) {
categoryCollection = new TreeSet<ClassificationScore>();
categories.put(category, categoryCollection);
}
try {
ClassificationScore classificationScore = new ClassificationScore(category, value, score);
if (!noData(id)) classificationScore.setId(id);
categoryCollection.add(classificationScore);
return true;
} catch (NumberFormatException e) {
logger.warn("Bad format for score: " + score);
return false;
}
}
示例12: getSegmentDateRanges
import java.util.TreeSet; //導入依賴的package包/類
private static List<DateRange> getSegmentDateRanges(final List<DecisionTreeRule> rules,
final Set<ValueGroup> changeGroup) {
final Set<Instant> times = new TreeSet<>();
rules.forEach(rule -> {
times.add(rule.getStart());
times.add(rule.getEnd());
});
changeGroup.forEach(group -> {
times.add(group.getRange().getStart());
times.add(group.getRange().getFinish());
});
final List<Instant> ordered = new ArrayList<>(times);
final List<DateRange> slices = new ArrayList<>(1);
for (int i = 0; i < times.size() - 1; ++i) {
final DateRange dateTimeSlice = new DateRange(ordered.get(i), ordered.get(i + 1));
slices.add(dateTimeSlice);
}
return slices;
}
示例13: getEventTimes
import java.util.TreeSet; //導入依賴的package包/類
private void getEventTimes(TreeSet<Long> out, boolean descendsPNode) {
boolean isPNode = TAG_P.equals(tag);
if (descendsPNode || isPNode) {
if (startTimeUs != UNDEFINED_TIME) {
out.add(startTimeUs);
}
if (endTimeUs != UNDEFINED_TIME) {
out.add(endTimeUs);
}
}
if (children == null) {
return;
}
for (int i = 0; i < children.size(); i++) {
children.get(i).getEventTimes(out, descendsPNode || isPNode);
}
}
示例14: dayCodes2str
import java.util.TreeSet; //導入依賴的package包/類
public static String dayCodes2str(Collection dayCodes, String delim) {
StringBuffer sb = new StringBuffer();
for (Iterator i=(new TreeSet(dayCodes)).iterator();i.hasNext();) {
int dayCode = ((TimePatternDays)i.next()).getDayCode().intValue();
int nrDays = 0;
for (int j=0;j<Constants.NR_DAYS;j++)
if ((dayCode&Constants.DAY_CODES[j])!=0) nrDays++;
for (int j=0;j<Constants.NR_DAYS;j++) {
if ((Constants.DAY_CODES[j]&dayCode)==0) continue;
sb.append(nrDays==1?CONSTANTS.days()[j]:CONSTANTS.shortDays()[j]);
}
if (i.hasNext())
sb.append(delim);
}
return sb.toString();
}
示例15: getMigrations
import java.util.TreeSet; //導入依賴的package包/類
@Override
public List<Change> getMigrations() {
Collection<String> filenames = new TreeSet<>();
for (Resource res : getResources("/*.sql")) {
filenames.add(res.getFilename());
}
filenames.remove(BOOTSTRAP_SQL);
filenames.remove(ONABORT_SQL);
return filenames.stream()
.map(this::parseChangeFromFilename)
.collect(Collectors.toList());
}
開發者ID:Bessonov,項目名稱:mybatis-migrations-spring-boot-autoconfigure,代碼行數:17,代碼來源:SpringMigrationLoader.java