I am trying to store a score for a large about of players. So I will need a map that is sorted based on the value, but because of the amount of players it's inefficient to sort it each time I retrieve it. I would also like the ability to find a players rank in the map. It would be very similar to the score datatype in redis. Something like:
    ScoreMap<String, Integer> scores = new ScoreMap<String, Integer>();
    scores.put("Bill", 2);
    scores.put("Tom", 6);
    scores.put("Jim", 3);
    scores.put("Jake", 3);
    System.out.println("Rank = " + scores.getRank("Bill"));
    System.out.println();
    System.out.println("All:");
    for (Entry<String, Integer> entry : scores.entrySet()) {
        System.out.println(entry.getKey() + " => " + entry.getValue());
    }
    System.out.println();
    System.out.println("Rank Range:");
    for (Entry<String, Integer> entry : scores.entryRankRange(0, 2)) {
        System.out.println(entry.getKey() + " => " + entry.getValue());
    }
    System.out.println();
    System.out.println("Score Range:");
    for (Entry<String, Integer> entry : scores.entryScoreRange(2, 3)) {
        System.out.println(entry.getKey() + " => " + entry.getValue());
    }
This would return
    Rank = 3
    All:
    Tom => 6
    Jake => 3
    Jim => 3
    Bill => 2
    Rank Range:
    Tom => 6
    Jake => 3
    Jim => 3
    Score Range:
    Jake => 3
    Jim => 3
    Bill => 2
I know this is kinda specific and I will probably have to make a custom data-structure. But a point in the right direction would be much appreciated. :)
 
     
     
    