public class IntRangeToIntMap extends java.lang.Object implements IntToIntMap
Constructor and Description |
---|
IntRangeToIntMap(int capacity)
Create an empty map, with given initial capacity
|
IntRangeToIntMap(int[] startPoints,
int[] endPoints)
Create an IntRangeSet given the start points and end points of the integer ranges.
|
Modifier and Type | Method and Description |
---|---|
void |
addEntry(int start,
int end,
int value)
Add an entry to the map.
|
void |
clear()
Clear the map.
|
boolean |
contains(int value)
Finds whether a key is present in the map.
|
int |
get(int value)
Gets the value for this key.
|
int |
getDefaultValue()
Get the default value used to indicate an unused entry
|
int[] |
getEndPoints()
Get the end points of the ranges
|
int |
getNumberOfRanges()
Get the number of ranges actually in use
|
int[] |
getStartPoints()
Get the start points of the ranges
|
boolean |
isEmpty() |
IntIterator |
keyIterator()
Get an iterator over the integer key values held in the hash map
|
void |
put(int key,
int value)
Adds a key-value pair to the map.
|
boolean |
remove(int value)
Removes a key from the map.
|
void |
setDefaultValue(int defaultValue)
Set the value to be returned to indicate an unused entry
|
int |
size()
Gets the size of the map.
|
java.lang.String |
toString() |
public IntRangeToIntMap(int capacity)
capacity
- the initial capacitypublic IntRangeToIntMap(int[] startPoints, int[] endPoints)
startPoints
- the start points of the integer rangesendPoints
- the end points of the integer rangesjava.lang.IllegalArgumentException
- if the two arrays are different lengths. Other error conditions
in the input are not currently detected.public void setDefaultValue(int defaultValue)
setDefaultValue
in interface IntToIntMap
defaultValue
- the value to be returned by get(int)
if no entry
exists for the supplied keypublic int getDefaultValue()
getDefaultValue
in interface IntToIntMap
get(int)
if no entry
exists for the supplied keypublic void clear()
IntToIntMap
clear
in interface IntToIntMap
public int size()
IntToIntMap
size
in interface IntToIntMap
public boolean isEmpty()
public boolean contains(int value)
IntToIntMap
contains
in interface IntToIntMap
value
- Keypublic int get(int value)
IntToIntMap
get
in interface IntToIntMap
value
- Keypublic boolean remove(int value)
IntToIntMap
remove
in interface IntToIntMap
value
- Key to removepublic void addEntry(int start, int end, int value)
start
- the start of the range to be addedend
- the end of the range to be addedvalue
- the value corresponding to this range of integer keyspublic java.lang.String toString()
toString
in class java.lang.Object
public int[] getStartPoints()
public int[] getEndPoints()
public int getNumberOfRanges()
public void put(int key, int value)
put
in interface IntToIntMap
key
- Keyvalue
- Valuepublic IntIterator keyIterator()
keyIterator
in interface IntToIntMap
Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.