Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uchicago.src.collection
Class RangeMap

    java.lang.Object
      uchicago.src.collection.RangeMap

    public class RangeMap

extends java.lang.Object

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, ``

     map.get(.25);

will return obj1.

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++_.

Version:
  $Revision: 1.7 $ $Date: 2004/11/03 19:51:00 $

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

### BLACK

    public static final int BLACK

See Also:
  Constant Field Values

### RED

    public static final int RED

See Also:
  Constant Field Values

Constructor Detail

### RangeMap

    public RangeMap()

  Constructs an empty range map.

Method Detail

### clear

    public void clear()

  Removes all the entries in the map.

### print

    public void print()

  Prints a representation of this RangeMap to the console.

### print

    public void print(BinaryNode node)

  Prints a representation of this RangeMap to the console, beginning with the specified node.

### get

    public java.lang.Object get(double key)

  Gets the Object within whose range the specified key falls. If the key is not within any objects range, then return null.

  Parameters:
    `key` - the number within the range whose associated object is returned

### put

    public void put(double key,
                    java.lang.Object obj)

  Puts an object in the map and associates it with a range. The specified key defines the inclusive lower bound of the range. The exclusive upper bound is the next highest lower bound of any other inserted object. If there is no lower bound higher than the specified lower, then the exclusive upper bound is Double.POSITIVE_INFINITY.

  Parameters:
    `key` - the inclusive lower bound the range to associate with the inserted object
    `obj` - the object to insert and associate with the range

### isEmpty

    public boolean isEmpty()

  Is this RangeMap empty.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD