|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.collection.RangeMap
public class RangeMap
A Map whose keys are doubles and whose values are Objects. Objects are
inserted with an implied range, relative to the other objects inserted.
So,
map.put(0, obj1);
map.put(.5, obj2);
map.put(11.2, obj3);
associates obj1 with the range [0, .5) (inclusive of 0 and exclusive of .5),
and obj2 with the range [.5, 11.2) and obj3 with [11.2, pos_infinity).
Getting an object is done with a key as in other types of maps. However,
here the object returned is the object within whose range the key falls.
So,
will return obj1.
map.get(.25);
The data structure used here is redblack tree implemented without removal. The implementation is largely a port of the C++ code in Mark Allen Weiss, _Algorithms, Data Structures, and Problem Solving with C++_.
| Field Summary | |
|---|---|
static int |
BLACK
|
static int |
RED
|
| Constructor Summary | |
|---|---|
RangeMap()
Constructs an empty range map. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all the entries in the map. |
java.lang.Object |
get(double key)
Gets the Object within whose range the specified key falls. |
boolean |
isEmpty()
Is this RangeMap empty. |
void |
print()
Prints a representation of this RangeMap to the console. |
void |
print(BinaryNode node)
Prints a representation of this RangeMap to the console, beginning with the specified node. |
void |
put(double key,
java.lang.Object obj)
Puts an object in the map and associates it with a range. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int BLACK
public static final int RED
| Constructor Detail |
|---|
public RangeMap()
| Method Detail |
|---|
public void clear()
public void print()
public void print(BinaryNode node)
public java.lang.Object get(double key)
key - the number within the range whose associated object is
returned
public void put(double key,
java.lang.Object obj)
key - the inclusive lower bound the range to associate with
the inserted objectobj - the object to insert and associate with the rangepublic boolean isEmpty()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||