Class AbstractSortedMap<K,V>
- java.lang.Object
-
- AbstractMap<K,V>
-
- AbstractSortedMap<K,V>
-
- All Implemented Interfaces:
- Map<K,V>
- Direct Known Subclasses:
- SortedTableMap, TreeMap
public abstract class AbstractSortedMap<K,V> extends AbstractMap<K,V>
An abstract base class to ease the implementation of the SortedMap interface. The base class provides four means of support: 1) It defines a PQEntry class as a concrete implementation of the entry interface 2) It provides an instance variable for a general Comparator and protected methods, compare(a, b), that can compare either two entries or two keys using the comparator. 3) It provides a boolean checkKey method that verifies that a given key is appropriate for use with the comparator
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.MapEntry<K,V>
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
AbstractSortedMap()
Initializes the map with a default comparator.protected
AbstractSortedMap(java.util.Comparator<K> c)
Initializes the comparator for the map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description protected boolean
checkKey(K key)
Determines whether a key is valid.protected int
compare(Entry<K,V> a, Entry<K,V> b)
Method for comparing two entries according to keyprotected int
compare(Entry<K,V> a, K b)
Method for comparing a key and an entry's keyprotected int
compare(K a, Entry<K,V> b)
Method for comparing a key and an entry's keyprotected int
compare(K a, K b)
Method for comparing two keys-
Methods inherited from class AbstractMap
isEmpty
-
-
-
-
Field Detail
-
comp
private java.util.Comparator<K> comp
The comparator defining the ordering of keys in the map.
-
-
Constructor Detail
-
AbstractSortedMap
protected AbstractSortedMap()
Initializes the map with a default comparator.
-
AbstractSortedMap
protected AbstractSortedMap(java.util.Comparator<K> c)
Initializes the comparator for the map.- Parameters:
c
- comparator defining the order of keys in the map
-
-