Package net.sf.saxon.z
Class IntRangeToIntMap
java.lang.Object
net.sf.saxon.z.IntRangeToIntMap
- All Implemented Interfaces:
IntToIntMap
Set of int values. This implementation of IntSet uses a sorted array
of integer ranges.
-
Constructor Summary
ConstructorsConstructorDescriptionIntRangeToIntMap(int capacity) Create an empty map, with given initial capacityIntRangeToIntMap(int[] startPoints, int[] endPoints) Create an IntRangeSet given the start points and end points of the integer ranges. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntry(int start, int end, int value) Add an entry to the map.voidclear()Clear the map.booleancontains(int value) Finds whether a key is present in the map.intget(int value) Gets the value for this key.intGet the default value used to indicate an unused entryint[]Get the end points of the rangesintGet the number of ranges actually in useint[]Get the start points of the rangesbooleanisEmpty()Get an iterator over the integer key values held in the hash mapvoidput(int key, int value) Adds a key-value pair to the map.booleanremove(int value) Removes a key from the map.voidsetDefaultValue(int defaultValue) Set the value to be returned to indicate an unused entryintsize()Gets the size of the map.toString()
-
Constructor Details
-
IntRangeToIntMap
public IntRangeToIntMap(int capacity) Create an empty map, with given initial capacity- Parameters:
capacity- the initial capacity
-
IntRangeToIntMap
public IntRangeToIntMap(int[] startPoints, int[] endPoints) Create an IntRangeSet given the start points and end points of the integer ranges. The two arrays must be the same length; each must be in ascending order; and the n'th end point must be greater than the n'th start point, and less than the n+1'th start point, for all n.- Parameters:
startPoints- the start points of the integer rangesendPoints- the end points of the integer ranges- Throws:
IllegalArgumentException- if the two arrays are different lengths. Other error conditions in the input are not currently detected.
-
-
Method Details
-
setDefaultValue
public void setDefaultValue(int defaultValue) Set the value to be returned to indicate an unused entry- Specified by:
setDefaultValuein interfaceIntToIntMap- Parameters:
defaultValue- the value to be returned byget(int)if no entry exists for the supplied key
-
getDefaultValue
public int getDefaultValue()Get the default value used to indicate an unused entry- Specified by:
getDefaultValuein interfaceIntToIntMap- Returns:
- the value to be returned by
get(int)if no entry exists for the supplied key
-
clear
public void clear()Description copied from interface:IntToIntMapClear the map.- Specified by:
clearin interfaceIntToIntMap
-
size
public int size()Description copied from interface:IntToIntMapGets the size of the map.- Specified by:
sizein interfaceIntToIntMap- Returns:
- the size
-
isEmpty
public boolean isEmpty() -
contains
public boolean contains(int value) Description copied from interface:IntToIntMapFinds whether a key is present in the map.- Specified by:
containsin interfaceIntToIntMap- Parameters:
value- Key- Returns:
- true if the key is mapped
-
get
public int get(int value) Description copied from interface:IntToIntMapGets the value for this key.- Specified by:
getin interfaceIntToIntMap- Parameters:
value- Key- Returns:
- the value, or the default value if not found.
-
remove
public boolean remove(int value) Description copied from interface:IntToIntMapRemoves a key from the map.- Specified by:
removein interfaceIntToIntMap- Parameters:
value- Key to remove- Returns:
- true if the value was removed
-
addEntry
public void addEntry(int start, int end, int value) Add an entry to the map. Ranges of entries must be added in ascending numerical order- Parameters:
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 keys
-
toString
-
getStartPoints
public int[] getStartPoints()Get the start points of the ranges- Returns:
- the start points
-
getEndPoints
public int[] getEndPoints()Get the end points of the ranges- Returns:
- the end points
-
getNumberOfRanges
public int getNumberOfRanges()Get the number of ranges actually in use- Returns:
- the number of ranges
-
put
public void put(int key, int value) Adds a key-value pair to the map.- Specified by:
putin interfaceIntToIntMap- Parameters:
key- Keyvalue- Value
-
keyIterator
Get an iterator over the integer key values held in the hash map- Specified by:
keyIteratorin interfaceIntToIntMap- Returns:
- an iterator whose next() call returns the key values (in arbitrary order)
-