List of usage examples for java.util TreeMap descendingMap
NavigableMap descendingMap
To view the source code for java.util TreeMap descendingMap.
Click Source Link
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); // putting values in navigable map NavigableMap nmap = treemap.descendingMap(); System.out.println("Checking value"); System.out.println("Navigable map values: " + nmap); }
From source file:org.polymap.kaps.ui.form.RichtwertzoneProvider.java
private static Cache<GemeindeComposite, SortedMap<String, Object>> getCache() { if (gemeindeCache == null) { gemeindeCache = CacheBuilder.newBuilder().weakKeys().maximumSize(10000) .expireAfterWrite(1, TimeUnit.MINUTES) .build(new CacheLoader<GemeindeComposite, SortedMap<String, Object>>() { public SortedMap<String, Object> load(GemeindeComposite gemeinde) { Map<String, RichtwertzoneComposite> zonen = new HashMap<String, RichtwertzoneComposite>(); Iterable<RichtwertzoneComposite> iterable = RichtwertzoneComposite.Mixin .findZoneIn(gemeinde); for (RichtwertzoneComposite zone : iterable) { String prefix = zone.schl().get(); zonen.put(prefix + " - " + zone.name().get(), zone); }/*from w ww . j a v a 2s . c om*/ TreeMap<String, Object> sorted = new TreeMap<String, Object>(new RWComparator(zonen)); sorted.putAll(zonen); SortedMap<String, Object> ret = sorted.descendingMap(); return ret; } }); } return gemeindeCache; }
From source file:org.polymap.kaps.ui.form.RichtwertzoneProvider.java
/** * /*from w ww . ja v a 2 s. c o m*/ * @param gemeindeComposite * @param date * @return */ public static SortedMap<String, Object> findFor(GemeindeComposite gemeinde, Date date) { // long start = System.currentTimeMillis(); // log.info( "findFor: " + gemeinde.schl().get() + ", " + date.getDate() ); if (gemeinde == null) { throw new IllegalArgumentException("gemeinde must not be null"); } if (date == null) { throw new IllegalArgumentException("date must not be null"); } Map<String, RichtwertzoneZeitraumComposite> zonen = new HashMap<String, RichtwertzoneZeitraumComposite>(); Iterable<RichtwertzoneComposite> iterable = RichtwertzoneComposite.Mixin.findZoneIn(gemeinde); for (RichtwertzoneComposite zone : iterable) { String prefix = zone.schl().get(); // find zeitraum RichtwertzoneZeitraumComposite zeitraum = RichtwertzoneZeitraumComposite.Mixin.findZeitraumFor(zone, date); if (zeitraum != null && zeitraum.gueltigAb().get() != null) { zonen.put(prefix + " - " + zone.name().get() + " (" + KapsRepository.SHORT_DATE.format(zeitraum.gueltigAb().get()) + ")", zeitraum); } } TreeMap<String, Object> sorted = new TreeMap<String, Object>(new RWZComparator(zonen)); sorted.putAll(zonen); // log.info( "findFor: " + gemeinde.schl().get() + " needed " + (System.currentTimeMillis() - start) + "ms" ); return sorted.descendingMap(); }
From source file:org.runbuddy.tomahawk.ui.fragments.starpage.SocialActionsFragment.java
public static List<List<SocialAction>> mergeSocialActions(TreeMap<Date, List<SocialAction>> actions) { List<List<SocialAction>> mergedActionsList = new ArrayList<>(); for (List<SocialAction> socialActions : actions.descendingMap().values()) { mergedActionsList.addAll(mergeSocialActions(socialActions)); }/*from ww w . j av a2 s .com*/ return mergedActionsList; }
From source file:com.agiletec.plugins.jpcontentfeedback.aps.internalservlet.feedback.ContentFeedbackAction.java
public Map<String, Integer> getVotes() { if (null != this.getReverseVotes() && this.getReverseVotes().booleanValue()) { TreeMap<String, Integer> t = new TreeMap<String, Integer>(this._votes); NavigableMap<String, Integer> x = t.descendingMap(); return x; //return t.descendingMap(); }/* w w w . j a va 2 s .co m*/ return _votes; }
From source file:starnubserver.connections.player.session.PlayerSession.java
public void loadPermissions() { Account account = playerCharacter.getAccount(); LinkedHashSet<String> permissions = new LinkedHashSet<>(); if (account == null) { GroupsManagement.getInstance().getGROUPS().values().stream() .filter(group -> group.getType().equalsIgnoreCase("noaccount")).forEach(group -> { permissions.addAll(group.getGROUP_PERMISSIONS()); });/* w w w.j a v a2 s . c om*/ } else { List<AccountPermission> accountPermissions = AccountPermission.getAccountPermissionsByAccount(account); permissions.addAll( accountPermissions.stream().map(AccountPermission::getPermission).collect(Collectors.toList())); TreeMap<Integer, Group> allGroups = account.getAllGroupsOrderedByRank(); NavigableMap<Integer, Group> navigableMap = allGroups.descendingMap(); for (Group group : navigableMap.values()) { permissions.addAll(group.getGROUP_PERMISSIONS()); } } permissions.forEach(this::addPermissionToMap); System.out.println(PERMISSIONS); }
From source file:org.jasig.portlet.proxy.mvc.portlet.gateway.GatewayPortletEditController.java
@RenderMapping public ModelAndView displayEditView(RenderRequest request, @RequestParam(required = false) String entryName) { final ModelAndView mv = new ModelAndView(); GatewayEntry entry = getGatewayEntry(entryName); mv.addObject(GATEWAY_ENTRY, entry);/*from w ww .j ava2s . c om*/ actionScopedRequestAttributeManager.propogateAndReturnItem(request, ERROR_KEY); // Look up any GatewayPreference entries from the action processing to the render phase. If not present, // look for any user-specified preference holders that are present in the chosen gatewayEntry object. TreeMap<String, GatewayPreference> preferencesForEntry = (TreeMap<String, GatewayPreference>) actionScopedRequestAttributeManager .propogateAndReturnItem(request, GATEWAY_ENTRY_PREFERENCES); if (preferencesForEntry == null) { final PortletPreferences prefs = request.getPreferences(); preferencesForEntry = getPreferencesForEntry(entry, prefs); } // Add descendingMap so username is listed before password for the form. mv.addObject(GATEWAY_ENTRY_PREFERENCES, preferencesForEntry.descendingMap()); mv.setView(viewSelector.isMobile(request) ? mobileViewName : viewName); return mv; }
From source file:org.apache.hadoop.hbase.backup.impl.BackupManifest.java
/** * Get the image list of this backup for restore in time order. * @param reverse If true, then output in reverse order, otherwise in time order from old to new * @return the backup image list for restore in time order *//* ww w .j a va 2s.com*/ public ArrayList<BackupImage> getRestoreDependentList(boolean reverse) { TreeMap<Long, BackupImage> restoreImages = new TreeMap<Long, BackupImage>(); restoreImages.put(backupImage.startTs, backupImage); for (BackupImage image : backupImage.getAncestors()) { restoreImages.put(Long.valueOf(image.startTs), image); } return new ArrayList<BackupImage>( reverse ? (restoreImages.descendingMap().values()) : (restoreImages.values())); }
From source file:org.apache.falcon.resource.AbstractExtensionManager.java
public ExtensionJobList getExtensionJobs(String extensionName, String sortOrder, String doAsUser) { TreeMap<String, String> jobAndExtensionNames = new TreeMap<>(); List<ExtensionJobsBean> extensionJobs = null; if (StringUtils.isNoneBlank(extensionName)) { extensionJobs = ExtensionStore.getMetaStore().getJobsForAnExtension(extensionName); } else {//from w w w .j a v a 2s .c om extensionJobs = ExtensionStore.getMetaStore().getAllExtensionJobs(); } for (ExtensionJobsBean job : extensionJobs) { jobAndExtensionNames.put(job.getJobName(), job.getExtensionName()); } sortOrder = (sortOrder == null) ? ASCENDING_SORT_ORDER : sortOrder; switch (sortOrder.toLowerCase()) { case DESCENDING_SORT_ORDER: return new ExtensionJobList(extensionJobs.size(), jobAndExtensionNames.descendingMap()); default: return new ExtensionJobList(extensionJobs.size(), jobAndExtensionNames); } }
From source file:org.starnub.starnubserver.connections.player.session.PlayerSession.java
public void loadPermissions() { Account account = playerCharacter.getAccount(); LinkedHashSet<String> permissions = new LinkedHashSet<>(); if (account == null) { GroupsManagement.getInstance().getGROUPS().values().stream() .filter(group -> group.getType().equalsIgnoreCase("noaccount")).forEach(group -> { permissions.addAll(group.getGROUP_PERMISSIONS()); });//w ww. j a v a 2s. c om } else { List<AccountPermission> accountPermissions = AccountPermission.getAccountPermissionsByAccount(account); permissions.addAll( accountPermissions.stream().map(AccountPermission::getPermission).collect(Collectors.toList())); TreeMap<Integer, Group> allGroups = account.getAllGroupsOrderedByRank(); NavigableMap<Integer, Group> navigableMap = allGroups.descendingMap(); for (Group group : navigableMap.values()) { permissions.addAll(group.getGROUP_PERMISSIONS()); } } permissions.forEach(this::addPermissionToMap); }