当前位置: 首页>>代码示例>>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;未经允许,请勿转载。