org.knowceans.map
Class RankingMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.TreeMap<X,java.util.Set<Y>>
          extended by org.knowceans.map.TreeMultiMap<X,Y>
              extended by org.knowceans.map.InvertibleTreeMultiMap<K,V>
                  extended by org.knowceans.map.RankingMap<K,V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,java.util.Set<V>>, java.util.NavigableMap<K,java.util.Set<V>>, java.util.SortedMap<K,java.util.Set<V>>, IMultiMap<K,V>
Direct Known Subclasses:
IndexRanking

public class RankingMap<K,V>
extends InvertibleTreeMultiMap<K,V>

RankingMap allows sorting of two lists of items simultaneously.

TODO: build ParallelCollection (or for primitive types a ParallelArray)

Author:
gregor
See Also:
Serialized Form

Nested Class Summary
 class RankingMap.RankEntry
          RankEntry is a special pendent to Map.Entry with a wider purpose and validity also after change of the RankingMap
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
RankingMap()
           
RankingMap(boolean reverse)
          Init with reverse ordering (reverse is not evaluated).
RankingMap(java.util.Comparator<? super K> comp)
          Init and specify Comparator for keys.
RankingMap(java.util.Map<K,java.util.Set<V>> map)
          Create a ranking map from the map.
RankingMap(java.util.Map<K,java.util.Set<V>> map, java.util.Comparator<? super K> comp)
          Create a ranking map from the map.
 
Method Summary
 java.util.List<? extends RankingMap.RankEntry> entryList()
           
 java.util.List<? extends RankingMap.RankEntry> entryList(int count)
          Get sorted key-value pairs with duplicate scores resolved
 RankingMap<K,V> headMap(int count)
          creates a new map with count values referenced (but not
 RankingMap<K,V> headMap(K fromKey)
           
static void main(java.lang.String[] args)
           
 void put(K[] keys, V[] values)
          Put the two arrays (of equal size) into the map
 void put(java.util.List<K> keys, java.util.List<V> values)
          put keys and values
 java.util.List<K> sortedKeys()
          Get sorted keys.
 java.util.List<K> sortedKeys(int count)
          Get a maximum of count sorted keys.
 java.util.List<V> sortedValues()
          Get sorted values
 java.util.List<V> sortedValues(int count)
          Get a maximum of count sorted values.
 RankingMap<K,V> tailMap(K fromKey)
           
 
Methods inherited from class org.knowceans.map.InvertibleTreeMultiMap
add, clear, getInverse, getInverse, getInverseValue, put, remove, remove
 
Methods inherited from class java.util.TreeMap
ceilingEntry, ceilingKey, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, get, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, putAll, size, subMap, subMap, tailMap, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, size, values
 

Constructor Detail

RankingMap

public RankingMap()

RankingMap

public RankingMap(boolean reverse)
Init with reverse ordering (reverse is not evaluated).


RankingMap

public RankingMap(java.util.Comparator<? super K> comp)
Init and specify Comparator for keys.

Parameters:
comp -

RankingMap

public RankingMap(java.util.Map<K,java.util.Set<V>> map)
Create a ranking map from the map.

Parameters:
map -

RankingMap

public RankingMap(java.util.Map<K,java.util.Set<V>> map,
                  java.util.Comparator<? super K> comp)
Create a ranking map from the map.

Parameters:
map -
Method Detail

main

public static void main(java.lang.String[] args)

sortedKeys

public java.util.List<K> sortedKeys(int count)
Get a maximum of count sorted keys. For key-based truncation, cf. headMap; For key-based truncation, cf. headMap and subMap. If scores are doubled, there is no guarantee of the key order.

Parameters:
count -
Returns:

sortedKeys

public java.util.List<K> sortedKeys()
Get sorted keys.

Returns:

entryList

public java.util.List<? extends RankingMap.RankEntry> entryList(int count)
Get sorted key-value pairs with duplicate scores resolved

Parameters:
count - maximum number of entries returned
Returns:

entryList

public java.util.List<? extends RankingMap.RankEntry> entryList()

sortedValues

public java.util.List<V> sortedValues(int count)
Get a maximum of count sorted values. For key-based truncation, cf. headMap and subMap;

Parameters:
count -
Returns:

sortedValues

public java.util.List<V> sortedValues()
Get sorted values

Returns:

headMap

public RankingMap<K,V> headMap(int count)
creates a new map with count values referenced (but not

Parameters:
count -

headMap

public RankingMap<K,V> headMap(K fromKey)
Specified by:
headMap in interface java.util.NavigableMap<K,java.util.Set<V>>
Specified by:
headMap in interface java.util.SortedMap<K,java.util.Set<V>>
Overrides:
headMap in class java.util.TreeMap<K,java.util.Set<V>>

tailMap

public RankingMap<K,V> tailMap(K fromKey)
Specified by:
tailMap in interface java.util.NavigableMap<K,java.util.Set<V>>
Specified by:
tailMap in interface java.util.SortedMap<K,java.util.Set<V>>
Overrides:
tailMap in class java.util.TreeMap<K,java.util.Set<V>>

put

public void put(K[] keys,
                V[] values)
Put the two arrays (of equal size) into the map

Parameters:
keys -
values -

put

public void put(java.util.List<K> keys,
                java.util.List<V> values)
put keys and values

Parameters:
keys -
values -