sortedmap

Java: SortedMap, TreeMap, Comparable? How to use?

I have a list of objects I need to sort according to properties of one of their fields. I've heard that SortedMap and Comparators are the best way to do this. Do I implement Comparable with the class I'm sorting, or do I create a new class? How do I instantiate the SortedMap and pass in the Comparator? How does the sorting work? Will i...

Improving performance of merging lots of sorted maps into one sorted map - java

I have a method that gets a SortedMap as input, this map holds many SortedMap objects, the output of this method should be one SortedMap containing all elements of the maps held in the input map. the method looks like this: private SortedMap mergeSamples(SortedMap map){ SortedMap mergedMap = new TreeMap(); Iterator sampleIt = map.va...

How do I form the union of scala SortedMaps?

(I'm using Scala nightlies, and see the same behaviour in 2.8.0b1 RC4. I'm a Scala newcomer.) I have two SortedMaps that I'd like to form the union of. Here's the code I'd like to use: import scala.collection._ object ViewBoundExample { class X def combine[Y](a: SortedMap[X, Y], b: SortedMap[X, Y]): SortedMap[X, Y] = { ...

How to create sorted map in scala?

How to create sorted map in scala (mutable/immutable)? ...

Finding the first value greater than in a SortedMap

I'd like to know what is there a better way to find the first value greater than an inputted value in a large SortedMap instead of looping through all values in my example below. Or if SortedMap is a the best structure to use for this. Could this be achieved using google-collections? Thanks in advance public class mapTest { public sta...

ConcurrentSkipListMap sorting: Can it be done by the value's compareTo?

In a game, I'm trying to keep a list of users and have it sorted by score, so that I could query the list at any given time and return (for example) the top ten users by score. This list should be thread-safe. I envision using the userName string as a key and the value would be a User object which implements Comparable and has properti...