Top Description Fields Constructors Methods
com.ibm.icu.impl

public final Class BMPSet

extends Object
Class Inheritance
Imports
com.ibm.icu.text.UnicodeSet.SpanCondition, com.ibm.icu.util.OutputInt

Helper class for frozen UnicodeSets, implements contains() and span() optimized for BMP code points. Latin-1: Look up bytes. 2-byte characters: Bits organized vertically. 3-byte characters: Use zero/one/mixed data per 64-block in U+0000..U+FFFF, with mixed for illegal ranges. Supplementary characters: Binary search over the supplementary part of the parent set's inversion list.

Field Summary

Modifier and TypeField and Description
private int[]
bmpBlockBits

One bit per 64 BMP code points.

private boolean[]
latin1Contains

One boolean ('true' or 'false') per Latin-1 character.

private final int[]
list

The inversion list of the parent set, for the slower contains() implementation for mixed BMP blocks and for supplementary code points.

private int[]
list4kStarts

Inversion list indexes for restricted binary searches in findCodePoint(), from findCodePoint(U+0800, U+1000, U+2000, .., U+F000, U+10000).

private final int
private int[]
table7FF

One bit per code point from U+0000..U+07FF.

public static int

Constructor Summary

AccessConstructor and Description
public
BMPSet(final int[] parentList, int parentListLength)

public
BMPSet(final BMPSet otherBMPSet, final int[] newParentList, int newParentListLength)

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(int c)

private final boolean
containsSlow(int c, int lo, int hi)

private int

Returns:

the smallest integer i in the range lo..hi, inclusive, such that c < list[i]
findCodePoint
(int
a character in a subrange of MIN_VALUE..MAX_VALUE
c
,
int
The lowest index to be returned.
lo
,
int
The highest index to be returned.
hi
)

Same as UnicodeSet.findCodePoint(int c) except that the binary search is restricted for finding code points in a certain range.

private void
private static void
set32x64Bits(int[] table, int start, int limit)

Set bits in a bit rectangle in "vertical" bit organization.

public final int

Returns:

the limit (exclusive end) of the span NOTE: to reduce the overhead of function call to contains(c), it is manually inlined here. Check for sufficient length for trail unit for each surrogate pair. Handle single surrogates as surrogate code points as usual in ICU.
span
(CharSequence s, int
The start index
start
,
UnicodeSet.SpanCondition spanCondition, OutputInt
If not null: Receives the number of code points in the span.
outCount
)

Deprecated as a consequence of OutputInt being deprecated.
Span the initial substring for which each character c has spanCondition==contains(c).
public final int

Returns:

The string index which starts the span (i.e. inclusive).
spanBack
(CharSequence s, int limit, UnicodeSet.SpanCondition spanCondition)

Symmetrical with span().

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bmpBlockBitsback to summary
private int[] bmpBlockBits

One bit per 64 BMP code points. The bits are organized vertically; consecutive 64-code point blocks correspond to the same bit position in consecutive table words. With code point parts lead=c{15..12} t1=c{11..6} test bits (lead+16) and lead in bmpBlockBits[t1]. If the upper bit is 0, then the lower bit indicates if contains(c) for all code points in the 64-block. If the upper bit is 1, then the block is mixed and set.contains(c) must be called. Bits for 0..7FF are unused (0).

latin1Containsback to summary
private boolean[] latin1Contains

One boolean ('true' or 'false') per Latin-1 character.

listback to summary
private final int[] list

The inversion list of the parent set, for the slower contains() implementation for mixed BMP blocks and for supplementary code points. The list is terminated with list[listLength-1]=0x110000.

list4kStartsback to summary
private int[] list4kStarts

Inversion list indexes for restricted binary searches in findCodePoint(), from findCodePoint(U+0800, U+1000, U+2000, .., U+F000, U+10000). U+0800 is the first 3-byte-UTF-8 code point. Code points below U+0800 are always looked up in the bit tables. The last pair of indexes is for finding supplementary code points.

listLengthback to summary
private final int listLength
table7FFback to summary
private int[] table7FF

One bit per code point from U+0000..U+07FF. The bits are organized vertically; consecutive code points correspond to the same bit positions in consecutive table words. With code point parts lead=c{10..6} trail=c{5..0} it is set.contains(c)==(table7FF[trail] bit lead) Bits for 0..FF are unused (0).

U16_SURROGATE_OFFSETback to summary
public static int U16_SURROGATE_OFFSET

Constructor Detail

BMPSetback to summary
public BMPSet(final int[] parentList, int parentListLength)
BMPSetback to summary
public BMPSet(final BMPSet otherBMPSet, final int[] newParentList, int newParentListLength)

Method Detail

containsback to summary
public boolean contains(int c)
containsSlowback to summary
private final boolean containsSlow(int c, int lo, int hi)
findCodePointback to summary
private int findCodePoint(int c, int lo, int hi)

Same as UnicodeSet.findCodePoint(int c) except that the binary search is restricted for finding code points in a certain range. For restricting the search for finding in the range start..end, pass in lo=findCodePoint(start) and hi=findCodePoint(end) with 0<=lo<=hi

Parameters
c:int

a character in a subrange of MIN_VALUE..MAX_VALUE

lo:int

The lowest index to be returned.

hi:int

The highest index to be returned.

Returns:int

the smallest integer i in the range lo..hi, inclusive, such that c < list[i]

initBitsback to summary
private void initBits()
set32x64Bitsback to summary
private static void set32x64Bits(int[] table, int start, int limit)

Set bits in a bit rectangle in "vertical" bit organization. start

spanback to summary
public final int span(CharSequence s, int start, UnicodeSet.SpanCondition spanCondition, OutputInt outCount)

Deprecated

as a consequence of OutputInt being deprecated. See corresponding docs for further information.

Span the initial substring for which each character c has spanCondition==contains(c). It must be spanCondition==0 or 1.

Parameters
start:int

The start index

outCount:OutputInt

If not null: Receives the number of code points in the span.

Returns:int

the limit (exclusive end) of the span NOTE: to reduce the overhead of function call to contains(c), it is manually inlined here. Check for sufficient length for trail unit for each surrogate pair. Handle single surrogates as surrogate code points as usual in ICU.

spanBackback to summary
public final int spanBack(CharSequence s, int limit, UnicodeSet.SpanCondition spanCondition)

Symmetrical with span(). Span the trailing substring for which each character c has spanCondition==contains(c). It must be s.length >= limit and spanCondition==0 or 1.

Returns:int

The string index which starts the span (i.e. inclusive).