本文整理汇总了Java中edu.emory.mathcs.backport.java.util.Collections.sort方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.sort方法的具体用法?Java Collections.sort怎么用?Java Collections.sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.emory.mathcs.backport.java.util.Collections
的用法示例。
在下文中一共展示了Collections.sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sortSteps
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
public List<String> sortSteps(Map<String, Map<String, String>> testData,
String indexColumn, String valueColumn) {
List<String> sortedSteps = new ArrayList<>();
Map<String, Integer> elementSteps = testData.values().stream()
.collect(Collectors.toMap(o -> o.get(indexColumn),
o -> Integer.parseInt(o.get(valueColumn))));
/*
elementSteps = testData.keySet().stream().collect(Collectors.toMap(o -> o,
o -> Integer.parseInt(testData.get(o).get(valueColumn))));
*/
List<Entry<String, Integer>> stepNumbers = new ArrayList<>();
stepNumbers.addAll(elementSteps.entrySet());
Collections.sort(stepNumbers, new Comparator<Entry<String, Integer>>() {
public int compare(Entry<String, Integer> obj_left,
Entry<String, Integer> obj_right) {
return obj_left.getValue().compareTo(obj_right.getValue());
}
});
return stepNumbers.stream().map(e -> e.getKey())
.collect(Collectors.toList());
}
示例2: get
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
/**
* Get a sorted PostProcessors by generic type
* @param targetType the generic type of a registered PostProcessor.
* @param <T> the type.
* @return the List of PostProcessor
*/
@SuppressWarnings("unchecked")
public <T> List<PostProcessor<T>> get(Class<T> targetType) {
List<PostProcessor<T>> selected = new ArrayList<>();
for (PostProcessor postProcessor : postProcessors) {
Type type = postProcessor.getTargetClass();
if (TypeToken.of(targetType).isSubtypeOf(TypeToken.of(type))) {
selected.add(postProcessor);
}
}
Collections.sort(selected);
return selected;
}
示例3: removeTaskFromList
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
private void removeTaskFromList(ArrayList<Integer> deletedIds) {
if (deletedIds.size() == 1) {
controller.importantList.remove(controller.indexMatch.get(deletedIds.get(0)));
controller.relayFb(String.format(Constants.CMD_SUCCESS_DELETED_1, deletedIds.get(0)), MsgType.SUCCESS);
} else {
int count = 0;
int indexCount;
String indices = "";
Collections.sort(deletedIds, Collections.reverseOrder());
for (int screenId : deletedIds) {
indexCount = controller.indexMatch.get(screenId);
indices += "#" + String.valueOf(screenId);
count++;
if (count == deletedIds.size() - 1) {
indices += " and ";
} else if (!(count == deletedIds.size())) {
indices += ", ";
}
controller.importantList.remove(indexCount);
}
controller.relayFb(String.format(Constants.CMD_SUCCESS_DELETED_2, indices), MsgType.SUCCESS);
}
}
示例4: compile
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
@Override
public OOPSourceCodeModel compile(SourceFiles rawData) throws Exception {
final OOPSourceCodeModel srcModel = new OOPSourceCodeModel();
final List<RawFile> files = rawData.getFiles();
if (files.size() < 1) {
return srcModel;
} else {
List<String> projectFileTypes = getProjectFileSymbols(files);
// sort fileTypes by length in desc order so that the longest types are at the
// top.
Collections.sort(projectFileTypes, new LengthComp());
// compile code based on number of workers
compileFiles(files, srcModel, projectFileTypes);
/**
* In GoLang, interfaces are implemented implicitly. As a result, we handle
* their detection in the following way: Once we have parsed the entire code
* base, we compare every parsed interface to every parsed struct to see if
* there is a match. Then we modify the source code model to represent our
* findings accordingly.
*/
resolveInterfaces(srcModel);
}
return srcModel;
}
示例5: renderClassMembers
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
private void renderClassMembers(StringBuilder sb, Class<?> aClass) {
List<String> fields = new ArrayList<>();
List<String> methods = new ArrayList<>();
List<String> constructors = new ArrayList<>();
addMembers(aClass.getDeclaredFields(), fields);
addMembers(aClass.getDeclaredConstructors(), constructors);
addMembers(aClass.getDeclaredMethods(), methods);
Collections.sort(fields);
Collections.sort(methods);
Collections.sort(constructors);
for (String field : fields) {
sb.append(field + "\n");
}
sb.append("--\n");
for (String constructor : constructors) {
sb.append(constructor + "\n");
}
for (String method : methods) {
sb.append(method + "\n");
}
}
示例6: serializeList
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
public String serializeList(List<HouseNumber> houseNumberList){
if (houseNumberList==null || houseNumberList.size()==0){
return null;
}
Collections.sort(houseNumberList,comparator);
StringBuffer sb = new StringBuffer();
for (HouseNumber houseNumber:houseNumberList){
if (houseNumber==null || houseNumber.getNumber()==null || houseNumber.getLocation()==null){
continue;
}
String serialized = serialize(houseNumber);
if (serialized!=null){
sb.append(serialized)
.append(HOUSE_NUMBERS_SEPARATOR);
}
}
return sb.toString().trim();
}
示例7: compare
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
@Test
public void compare() {
HouseNumber h1 = new HouseNumber();
h1.setNumber("1");
HouseNumber h2 = new HouseNumber();
h2.setNumber("2");
HouseNumber h0 = new HouseNumber();
HouseNumber hnull= null;
List<HouseNumber> houseNumbers = new ArrayList<HouseNumber>();
houseNumbers.add(h1);
houseNumbers.add(h2);
houseNumbers.add(h0);
houseNumbers.add(hnull);
Collections.sort(houseNumbers,new HouseNumberComparator());
Assert.assertEquals(h1, houseNumbers.get(0));
Assert.assertEquals(h2, houseNumbers.get(1));
Assert.assertEquals(h0, houseNumbers.get(2));
Assert.assertEquals(hnull, houseNumbers.get(3));
}
示例8: addAllFields
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
/**
* Add all fields from the available list to the selected fields tree
*/
private void addAllFields()
{
ArrayList<ODKFieldInterface> fields = (ArrayList<ODKFieldInterface>) availableFieldsModel.getAllFields();
if(fields==null || fields.size()==0) return;
Collections.sort(fields, new ODKFieldComparator());
Collections.reverse(fields);
for(ODKFieldInterface field : fields)
{
//log.debug("Adding field "+field.getFieldName()+" to tree");
//selectedFieldsTreeModel.addNodeToRoot(field);
AbstractODKTreeNode newChild = new ODKFieldNode(field);
selectedFieldsTreeModel.insertNodeInto(newChild, (MutableTreeNode) selectedFieldsTreeModel.getRoot(), 0);
}
this.selectedFieldsTreeModel.reload();
availableFieldsModel.removeFields(fields);
expandTree();
}
示例9: ODKTridasSampleType
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
public ODKTridasSampleType()
{
super(ODKDataType.SELECT_ONE, "tridas_sample_type", "Sample type", Documentation.getDocumentation("sample.type"), null);
@SuppressWarnings("unchecked")
List<ControlledVoc> types = Dictionary.getMutableDictionary("sampleTypeDictionary");
ArrayList<Object> objects = new ArrayList<Object>();
for(ControlledVoc type: types)
{
objects.add(type);
}
Collections.sort(objects, new TridasDictionaryEntityProperty.ControlledVocComparator());
this.setPossibleChoices(SelectableChoice.makeObjectsSelectable(objects));
}
示例10: ODKTridasElementTaxon
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
public ODKTridasElementTaxon()
{
super(ODKDataType.SELECT_ONE, "tridas_element_taxon", "Taxon", Documentation.getDocumentation("element.taxon"), null);
@SuppressWarnings("unchecked")
List<ControlledVoc> types = Dictionary.getMutableDictionary("taxonDictionary");
ArrayList<Object> objects = new ArrayList<Object>();
for(ControlledVoc type: types)
{
objects.add(type);
}
Collections.sort(objects, new TridasDictionaryEntityProperty.ControlledVocComparator());
this.setPossibleChoices(SelectableChoice.makeObjectsSelectable(objects));
}
示例11: getRemarks
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
/**
* Lazily-build the list of remarks
* @return a list of remarks
*/
public static List<Remark> getRemarks() {
if(remarks != null)
return remarks;
remarks = new ArrayList<Remark>();
// add tridas remarks
for(NormalTridasRemark n : NormalTridasRemark.values())
remarks.add(new TridasReadingRemark(n));
// add dictionary remarks
List<?> dictionaryRemarks = Dictionary.getDictionary("readingNoteDictionary");
List<TridasRemark> tellervoRemarks = ListUtil.subListOfType(dictionaryRemarks, TridasRemark.class);
for(TridasRemark r : tellervoRemarks) {
// only tellervo remarks for now
if("Tellervo".equals(r.getNormalStd()) || "Corina".equals(r.getNormalStd()) || "FHX".equals(r.getNormalStd()) )
remarks.add(new TellervoReadingRemark(r));
}
Collections.sort(remarks, new ReadingRemarkComparator());
return remarks;
}
示例12: getImportDataOnlyMenu
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
/**
* Get a submenu containing menu items for importing data only from legacy data file
*
* @return
*/
private JMenu getImportDataOnlyMenu()
{
JMenu fileimportdataonly = Builder.makeMenu("menus.file.importdataonly", "fileimport.png");
ArrayList<AbstractDendroFileReader> readers = TridasIO.getInstantiatedReaders();
Collections.sort(readers);
for(AbstractDendroFileReader r : readers)
{
final AbstractDendroFileReader reader = r;
FileImportLegacyFile action = new FileImportLegacyFile(reader, editor);
JMenuItem importitem = new JMenuItem(action);
fileimportdataonly.add(importitem);
}
return fileimportdataonly;
}
示例13: testGetSnippets
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
@Test
public void testGetSnippets() throws SpdxCollectionException, InvalidSPDXAnalysisException {
SpdxFileCollector collector = new SpdxFileCollector( null );
List<SpdxSnippet> snippets = collector.getSnippets();
assertEquals( 0, snippets.size() );
collector.collectFiles( this.fileSets, this.directory.getAbsolutePath(), this.defaultFileInformation,
new HashMap<String, SpdxDefaultFileInformation>(),
spdxPackage, RelationshipType.GENERATES, container );
snippets = collector.getSnippets();
assertEquals( filePaths.length, snippets.size() );
Collections.sort( snippets );
for ( int i = 0; i < snippets.size(); i++ ) {
assertEquals( SNIPPET_NAMES, snippets.get( i ).getName() );
assertEquals( DEFAULT_SNIPPET_COMMENT, snippets.get( i ).getComment() );
assertEquals( DEFAULT_SNIPPET_CONCLUDED_LICENSE, snippets.get( i ).getLicenseConcluded().toString() );
assertEquals( DEFAULT_SNIPPET_COPYRIGHT, snippets.get( i ).getCopyrightText() );
assertEquals( DEFAULT_SNIPPET_DECLARED_LICENSE, snippets.get( i ).getLicenseInfoFromFiles()[0].toString() );
assertEquals( DEFAULT_SNIPPET_LICENSE_COMMENT, snippets.get( i ).getLicenseComments() );
assertEquals( DEFAULT_SNIPPET_BYTE_RANGE, startEndPointerToString( snippets.get( i ).getByteRange() ) );
assertEquals( DEFAULT_SNIPPET_LINE_RANGE, startEndPointerToString( snippets.get( i ).getLineRange() ) );
}
}
示例14: setupGeneOntology
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
private static Gene setupGeneOntology(Gene gene, String geneOntologies) {
String[] arr = geneOntologies.split(";");
Collection<GeneOntology> geneOntologyCollection = new ArrayList<GeneOntology>();
for ( int i=0;i<arr.length;i++ ) {
if( arr[i].indexOf("[") != -1) {
GeneOntology geneOntology = new GeneOntology();
geneOntology.setId(Long.valueOf(arr[i].substring(arr[i].indexOf(":")+1, arr[i].indexOf("[")).trim()));
geneOntology.setName(arr[i].substring(arr[i].lastIndexOf(":") + 1, arr[i].indexOf("]")).trim());
geneOntologyCollection.add(geneOntology);
}
}
Collections.sort((ArrayList)geneOntologyCollection, new Comparator() {
public int compare(Object go1, Object go2) {
//ascending order
return ((GeneOntology)go1).getId().compareTo(((GeneOntology)go2).getId());
}
});
gene.setGeneOntologyCollection(geneOntologyCollection);
return gene;
}
示例15: sort
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
/**
* 根據 story column 的值來排序
*
* @param stories
* @param sortedColumn
* @return sorted stories
*/
private ArrayList<StoryObject> sort(ArrayList<StoryObject> stories,
String sortedColumn) {
if (sortedColumn.equals("EST")) {
Collections.sort(stories, new StoryComparator(
StoryComparator.TYPE_EST));
} else if (sortedColumn.equals("IMP")) {
Collections.sort(stories, new StoryComparator(
StoryComparator.TYPE_IMP));
} else if (sortedColumn.equals("VAL")) {
Collections.sort(stories, new StoryComparator(
StoryComparator.TYPE_VAL));
} else {
Collections.sort(stories, new StoryComparator(
StoryComparator.TYPE_ID));
}
return stories;
}