Java Code Examples for java.util.TreeMap#descendingMap()

The following examples show how to use java.util.TreeMap#descendingMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetCommentsTask.java    From guanggoo-android with Apache License 2.0 6 votes vote down vote up
public static Map<Integer, Comment> getCommentsFromElements(Elements elements) {
    TreeMap<Integer, Comment> comments = new TreeMap<>();

    Elements replyItems = elements.select("div.reply-item");

    for (Element replyItem : replyItems) {
        Comment comment = getCommentFromElement(replyItem);
        comments.put(comment.getMeta().getFloor(), comment);
    }

    if (PrefsUtil.getBoolean(App.getInstance(), ConstantUtil.KEY_COMMENTS_ORDER_DESC, false)) {
        return comments.descendingMap();
    } else {
        return comments;
    }
}
 
Example 2
Source File: AppInfo.java    From Sherlock with Apache License 2.0 5 votes vote down vote up
public Map<String, String> getAppDetails() {
  TreeMap<String, String> details = new TreeMap<>();
  for (Pair pair : appDetails) {
    details.put(pair.getKey(), pair.getVal());
  }
  return details.descendingMap();
}
 
Example 3
Source File: TreeSubMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a new map from Integers -5 to -1 to Strings "A"-"E".
 */
private static NavigableMap dmap5() {
    TreeMap map = new TreeMap();
    assertTrue(map.isEmpty());
    map.put(m1, "A");
    map.put(m5, "E");
    map.put(m3, "C");
    map.put(m2, "B");
    map.put(m4, "D");
    assertFalse(map.isEmpty());
    assertEquals(5, map.size());
    return map.descendingMap();
}
 
Example 4
Source File: TreeMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testDescendingMapSerialization() {
    // Updated golden value since we have a different serialVersionUID in OpenJDK.
    String s = "aced0005737200226a6176612e7574696c2e547265654d61702444657363656e6"
            + "4696e675375624d61700cab946d1f0f9d0c0200014c001172657665727365436f6"
            + "d70617261746f727400164c6a6176612f7574696c2f436f6d70617261746f723b7"
            + "87200216a6176612e7574696c2e547265654d6170244e6176696761626c6553756"
            + "24d617026617d4eacdd59330200075a000966726f6d53746172745a000b6869496"
            + "e636c75736976655a000b6c6f496e636c75736976655a0005746f456e644c00026"
            + "8697400124c6a6176612f6c616e672f4f626a6563743b4c00026c6f71007e00034"
            + "c00016d7400134c6a6176612f7574696c2f547265654d61703b787001010101707"
            + "0737200116a6176612e7574696c2e547265654d61700cc1f63e2d256ae60300014"
            + "c000a636f6d70617261746f7271007e000178707372002a6a6176612e6c616e672"
            + "e537472696e672443617365496e73656e736974697665436f6d70617261746f727"
            + "7035c7d5c50e5ce02000078707704000000027400016171007e000a74000162710"
            + "07e000b78737200286a6176612e7574696c2e436f6c6c656374696f6e732452657"
            + "665727365436f6d70617261746f7232000003fa6c354d510200014c0003636d707"
            + "1007e0001787071007e0009";
    TreeMap<String, String> map = new TreeMap<String, String>(
            String.CASE_INSENSITIVE_ORDER);
    map.put("a", "a");
    map.put("b", "b");
    NavigableMap<String, String> descendingMap = map.descendingMap();
    new SerializationTester<NavigableMap<String, String>>(descendingMap, s) {
        @Override protected void verify(NavigableMap<String, String> deserialized) {
            assertEquals("b", deserialized.navigableKeySet().first());
        }
    }.test();
}
 
Example 5
Source File: TreeSubMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new map from Integers -5 to -1 to Strings "A"-"E".
 */
private static NavigableMap dmap5() {
    TreeMap map = new TreeMap();
    assertTrue(map.isEmpty());
    map.put(m1, "A");
    map.put(m5, "E");
    map.put(m3, "C");
    map.put(m2, "B");
    map.put(m4, "D");
    assertFalse(map.isEmpty());
    assertEquals(5, map.size());
    return map.descendingMap();
}
 
Example 6
Source File: Entry.java    From ingress-apk-mod with Apache License 2.0 4 votes vote down vote up
public static Map PlayerModelUtils_onGetDefaultResonatorToDeploy(TreeMap map) {
    return Config.deployHighest ? map.descendingMap() : map;
}