List of usage examples for java.util Collections reverse
@SuppressWarnings({ "rawtypes", "unchecked" }) public static void reverse(List<?> list)
This method runs in linear time.
From source file:net.sf.jabref.logic.journals.Abbreviations.java
public static void initializeJournalNames(JabRefPreferences jabRefPreferences) { journalAbbrev = new JournalAbbreviationRepository(); // the order of reading the journal lists is important // method: last added abbreviation wins // for instance, in the personal list one can overwrite abbreviations in the built in list // Read builtin list journalAbbrev.readJournalListFromResource(JOURNALS_FILE_BUILTIN); // read IEEE list if (jabRefPreferences.getBoolean(JabRefPreferences.USE_IEEE_ABRV)) { journalAbbrev.readJournalListFromResource(JOURNALS_IEEE_ABBREVIATION_LIST_WITH_CODE); } else {//from w w w. j a v a2s . com journalAbbrev.readJournalListFromResource(JOURNALS_IEEE_ABBREVIATION_LIST_WITH_TEXT); } // Read external lists List<String> lists = jabRefPreferences.getStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS); if (!(lists.isEmpty())) { Collections.reverse(lists); for (String filename : lists) { try { journalAbbrev.readJournalListFromFile(new File(filename)); } catch (FileNotFoundException e) { // The file couldn't be found... should we tell anyone? LOGGER.info("Cannot find external journal list file " + filename, e); } } } // Read personal list String personalJournalList = jabRefPreferences.get(JabRefPreferences.PERSONAL_JOURNAL_LIST); if ((personalJournalList != null) && !personalJournalList.trim().isEmpty()) { try { journalAbbrev.readJournalListFromFile(new File(personalJournalList)); } catch (FileNotFoundException e) { LOGGER.info("Personal journal list file '" + personalJournalList + "' not found.", e); } } }
From source file:Main.java
/** * Get the next permutation.//from w w w.ja v a 2 s . c om * <p> * This function's implementation is based on the implementation found in * the GNU ISO C++ library's implementation of <code>std::next_permutation()</code>. * */ public static <E extends Comparable<E>> boolean getNextPermutation(List<E> list) { final int first = 0; final int last = list.size(); if (first == last) return false; int i = first; ++i; if (i == last) return false; i = last; --i; for (;;) { int ii = i; --i; if (list.get(i).compareTo(list.get(ii)) < 0) { int j = last; while (!(list.get(i).compareTo(list.get(--j)) < 0)) ; // empty body swap(list, i, j); reverse(list, ii, last); return true; } if (i == first) { Collections.reverse(list); return false; } } }
From source file:io.apiman.plugins.keycloak_oauth_policy.ClaimLookup.java
private static void getProperties(Class<?> klazz, String path, Deque<Field> fieldChain) { for (Field f : klazz.getDeclaredFields()) { f.setAccessible(true);//from www . java 2 s .c om JsonProperty jsonProperty = f.getAnnotation(JsonProperty.class); if (jsonProperty != null) { fieldChain.push(f); // If the inspected type has nested @JsonProperty annotations, we need to inspect it if (hasJsonPropertyAnnotation(f)) { getProperties(f.getType(), f.getName() + ".", fieldChain); // Add "." when traversing into new object. } else { // Otherwise, just assume it's simple as the best we can do is #toString List<Field> fieldList = new ArrayList<>(fieldChain); Collections.reverse(fieldList); STANDARD_CLAIMS_FIELD_MAP.put(path + jsonProperty.value(), fieldList); fieldChain.pop(); // Pop, as we have now reached end of this chain. } } } }
From source file:com.stratio.explorer.converters.PropertiesToStringConverter.java
private String deleteHeaderLine(String string) { String[] strings = string.split("\\n"); List<String> withOutHeader = Arrays.asList(Arrays.copyOfRange(strings, 1, strings.length)); Collections.reverse(withOutHeader); return StringUtils.join(withOutHeader, lineSeparator); }
From source file:com.baasbox.service.query.PartsParser.java
public JsonNode json(JsonNode bodyJson) { Collections.reverse(this.parts); ObjectNode on = Json.newObject();/* w ww . j a v a 2 s . co m*/ Part last = null; for (Part p : parts) { if (last == null) { on.put(p.getName(), bodyJson); last = p; } else { ObjectNode cont = Json.newObject(); cont.put(p.getName(), on); on = cont; } } return on; }
From source file:ch.cyberduck.core.local.AbstractTemporaryFileService.java
@Override public void shutdown() { final List<Local> list = new ArrayList<>(files); Collections.reverse(list); for (Local f : list) { try {/*from w w w .j ava2 s.c om*/ f.delete(); } catch (AccessDeniedException e) { log.warn(String.format("Failure deleting file %s in shutdown hook. %s", f, e.getMessage())); } } }
From source file:org.openmrs.module.rheapocadapter.web.controller.TransactionServiceController.java
@RequestMapping("/module/rheapocadapter/manageQueue.form") public String listAllQueues(ModelMap map) { EnteredHandler enteredHandler = new EnteredHandler(); List<ArchiveTransaction> archiveTransactions = new ArrayList<ArchiveTransaction>(); archiveTransactions = (List<ArchiveTransaction>) enteredHandler.getArchiveQueue(); Collections.reverse(archiveTransactions); map.addAttribute("archiveTransactions", archiveTransactions); log.info("Archive Transaction Size " + archiveTransactions.size()); return "/module/rheapocadapter/manageQueue"; }
From source file:com.jaspersoft.studio.compatibility.JRXmlWriterHelper.java
public static String[][] getVersions() { List<String> sl = new ArrayList<String>(writers); Collections.sort(sl);/*from w w w. j av a 2 s . c o m*/ Collections.reverse(sl); String[][] r = new String[sl.size() + 1][2]; r[0] = new String[] { Messages.JRXmlWriterHelper_1, "last" }; //$NON-NLS-2$ int i = 1; for (String key : sl) { r[i][0] = "JasperReports " + key.replace('_', '.'); //$NON-NLS-1$ if (i == 1) r[i][0] += Messages.JRXmlWriterHelper_4; r[i][1] = key; i++; } return r; }
From source file:com.lovejoy777sarootool.rootool.utils.SortUtils.java
public static void sortList(ArrayList<String> content, String current) { int len = content != null ? content.size() : 0; int index = 0; String[] items = new String[len]; content.toArray(items);/* w w w . j av a2s . c o m*/ switch (Settings.mSortType) { case SORT_ALPHA: Arrays.sort(items, Comparator_ALPH); content.clear(); Collections.addAll(content, items); break; case SORT_SIZE: Arrays.sort(items, Comparator_SIZE); content.clear(); for (String a : items) { if (new File(current + "/" + a).isDirectory()) content.add(index++, a); else content.add(a); } break; case SORT_TYPE: Arrays.sort(items, Comparator_TYPE); content.clear(); for (String a : items) { if (new File(current + "/" + a).isDirectory()) content.add(index++, a); else content.add(a); } break; case SORT_DATE: Arrays.sort(items, Comparator_DATE); content.clear(); for (String a : items) { if (new File(current + "/" + a).isDirectory()) content.add(index++, a); else content.add(a); } break; } if (Settings.reverseListView()) { Collections.reverse(content); } }
From source file:org.osmtools.ra.segment.SegmentFactory.java
private ConnectableSegment createFixedSegment(Way way, boolean reverse) { if (reverse) { List<Node> nodes = new ArrayList<Node>(way.getNodes()); Collections.reverse(nodes); return new FixedWay(nodes); } else//from w ww. j a v a 2 s.c o m return new FixedWay(way.getNodes()); }