當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeSet類代碼示例

本文整理匯總了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;
        }
    });
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:23,代碼來源:CMMDownloadTestUtil.java

示例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);
}
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:27,代碼來源:DBSongInfo.java

示例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);
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:20,代碼來源:WorkloadSummarizer.java

示例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;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:38,代碼來源:FileContext.java

示例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);
    }
}
 
開發者ID:DomKing,項目名稱:springbootWeb,代碼行數:26,代碼來源:UpdateByPrimaryKeyWithoutBLOBsMethodGenerator.java

示例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
        });
    }
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:20,代碼來源:DeleteUnusedReservedRoutesStepTest.java

示例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);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:25,代碼來源:DataSerializableJUnitTest.java

示例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)
                )
            );
        }
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:21,代碼來源:DefaultProjectGenerator.java

示例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));
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:28,代碼來源:TransformerDebug.java

示例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);
  }
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:17,代碼來源:LookupTables.java

示例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;
	}
}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:21,代碼來源:ClassifiableObject.java

示例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;
}
 
開發者ID:jpmorganchase,項目名稱:swblocks-decisiontree,代碼行數:21,代碼來源:RuleGroupChangeBuilder.java

示例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);
  }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:18,代碼來源:TtmlNode.java

示例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();
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:17,代碼來源:TimePatternEditForm.java

示例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


注:本文中的java.util.TreeSet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。