Package com.ibm.icu.util
Class CodePointMap
java.lang.Object
com.ibm.icu.util.CodePointMap
- All Implemented Interfaces:
Iterable<CodePointMap.Range>
- Direct Known Subclasses:
CodePointTrie
,MutableCodePointTrie
Abstract map from Unicode code points (U+0000..U+10FFFF) to integer values.
This does not implement java.util.Map.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Range iteration result data.static enum
Selectors for how getRange() should report value ranges overlapping with surrogates.class
Iterates over code points of a string and fetches map values.static interface
Callback function interface: Modifies a map value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract int
get
(int c) Returns the value for a code point as stored in the map, with range checking.boolean
getRange
(int start, CodePointMap.RangeOption option, int surrogateValue, CodePointMap.ValueFilter filter, CodePointMap.Range range) Sets the range object to a range of code points beginning with the start parameter.abstract boolean
getRange
(int start, CodePointMap.ValueFilter filter, CodePointMap.Range range) Sets the range object to a range of code points beginning with the start parameter.iterator()
Convenience iterator over same-map-value code point ranges.stringIterator
(CharSequence s, int sIndex) Returns an iterator (not a java.util.Iterator) over code points of a string for fetching map values.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CodePointMap
protected CodePointMap()Protected no-args constructor.
-
-
Method Details
-
get
public abstract int get(int c) Returns the value for a code point as stored in the map, with range checking. Returns an implementation-defined error value if c is not in the range 0..U+10FFFF.- Parameters:
c
- the code point- Returns:
- the map value, or an implementation-defined error value if the code point is not in the range 0..U+10FFFF
-
getRange
public abstract boolean getRange(int start, CodePointMap.ValueFilter filter, CodePointMap.Range range) Sets the range object to a range of code points beginning with the start parameter. The range start is the same as the start input parameter (even if there are preceding code points that have the same value). The range end is the last code point such that all those from start to there have the same value. Returns false if start is not 0..U+10FFFF. Can be used to efficiently iterate over all same-value ranges in a map. (This is normally faster than iterating over code points and get()ting each value, but may be much slower than a data structure that stores ranges directly.)If the
CodePointMap.ValueFilter
parameter is not null, then the value to be delivered is passed through that filter, and the return value is the end of the range where all values are modified to the same actual value. The value is unchanged if that parameter is null.Example:
int start = 0; CodePointMap.Range range = new CodePointMap.Range(); while (map.getRange(start, null, range)) { int end = range.getEnd(); int value = range.getValue(); // Work with the range start..end and its value. start = end + 1; }
- Parameters:
start
- range startfilter
- an object that may modify the map data value, or null if the values from the map are to be used unmodifiedrange
- the range object that will be set to the code point range and value- Returns:
- true if start is 0..U+10FFFF; otherwise no new range is fetched
-
getRange
public boolean getRange(int start, CodePointMap.RangeOption option, int surrogateValue, CodePointMap.ValueFilter filter, CodePointMap.Range range) Sets the range object to a range of code points beginning with the start parameter. The range start is the same as the start input parameter (even if there are preceding code points that have the same value). The range end is the last code point such that all those from start to there have the same value. Returns false if start is not 0..U+10FFFF.Same as the simpler
getRange(int, ValueFilter, Range)
but optionally modifies the range if it overlaps with surrogate code points.- Parameters:
start
- range startoption
- defines whether surrogates are treated normally, or as having the surrogateValue; usuallyCodePointMap.RangeOption.NORMAL
surrogateValue
- value for surrogates; ignored if option==CodePointMap.RangeOption.NORMAL
filter
- an object that may modify the map data value, or null if the values from the map are to be used unmodifiedrange
- the range object that will be set to the code point range and value- Returns:
- true if start is 0..U+10FFFF; otherwise no new range is fetched
-
iterator
Convenience iterator over same-map-value code point ranges. Same as looping over all ranges withgetRange(int, ValueFilter, Range)
without filtering. Adjacent ranges have different map values.The iterator always returns the same Range object.
- Specified by:
iterator
in interfaceIterable<CodePointMap.Range>
- Returns:
- a Range iterator
-
stringIterator
Returns an iterator (not a java.util.Iterator) over code points of a string for fetching map values.- Parameters:
s
- string to iterate oversIndex
- string index where the iteration will start- Returns:
- the iterator
-