ICU 4.8.1.1  4.8.1.1
Data Structures | Public Member Functions | Friends
UCharsTrie Class Reference

Light-weight, non-const reader class for a UCharsTrie. More...

#include <ucharstrie.h>

Inheritance diagram for UCharsTrie:
UMemory

Data Structures

class  Iterator
 Iterator for all of the (string, value) pairs in a UCharsTrie. More...
class  State
 UCharsTrie state object, for saving a trie's current state and resetting the trie back to this state later. More...

Public Member Functions

 UCharsTrie (const UChar *trieUChars)
 Constructs a UCharsTrie reader instance.
 ~UCharsTrie ()
 Destructor.
 UCharsTrie (const UCharsTrie &other)
 Copy constructor, copies the other trie reader object and its state, but not the UChar array which will be shared.
UCharsTriereset ()
 Resets this trie to its initial state.
const UCharsTriesaveState (State &state) const
 Saves the state of this trie.
UCharsTrieresetToState (const State &state)
 Resets this trie to the saved state.
UStringTrieResult current () const
 Determines whether the string so far matches, whether it has a value, and whether another input UChar can continue a matching string.
UStringTrieResult first (int32_t uchar)
 Traverses the trie from the initial state for this input UChar.
UStringTrieResult firstForCodePoint (UChar32 cp)
 Traverses the trie from the initial state for the one or two UTF-16 code units for this input code point.
UStringTrieResult next (int32_t uchar)
 Traverses the trie from the current state for this input UChar.
UStringTrieResult nextForCodePoint (UChar32 cp)
 Traverses the trie from the current state for the one or two UTF-16 code units for this input code point.
UStringTrieResult next (const UChar *s, int32_t length)
 Traverses the trie from the current state for this string.
int32_t getValue () const
 Returns a matching string's value if called immediately after current()/first()/next() returned USTRINGTRIE_INTERMEDIATE_VALUE or USTRINGTRIE_FINAL_VALUE.
UBool hasUniqueValue (int32_t &uniqueValue) const
 Determines whether all strings reachable from the current state map to the same value.
int32_t getNextUChars (Appendable &out) const
 Finds each UChar which continues the string from the current state.

Friends

class UCharsTrieBuilder

Detailed Description

Light-weight, non-const reader class for a UCharsTrie.

Traverses a UChar-serialized data structure with minimal state, for mapping strings (16-bit-unit sequences) to non-negative integer values.

This class owns the serialized trie data only if it was constructed by the builder's build() method. The public constructor and the copy constructor only alias the data (only copy the pointer). There is no assignment operator.

This class is not intended for public subclassing.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 48 of file ucharstrie.h.


Constructor & Destructor Documentation

UCharsTrie::UCharsTrie ( const UChar trieUChars) [inline]

Constructs a UCharsTrie reader instance.

The trieUChars must contain a copy of a UChar sequence from the UCharsTrieBuilder, starting with the first UChar of that sequence. The UCharsTrie object will not read more UChars than the UCharsTrieBuilder generated in the corresponding build() call.

The array is not copied/cloned and must not be modified while the UCharsTrie object is in use.

Parameters:
trieUCharsThe UChar array that contains the serialized trie.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 64 of file ucharstrie.h.

Destructor.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UCharsTrie::UCharsTrie ( const UCharsTrie other) [inline]

Copy constructor, copies the other trie reader object and its state, but not the UChar array which will be shared.

(Shallow copy.)

Parameters:
otherAnother UCharsTrie object.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 80 of file ucharstrie.h.


Member Function Documentation

Determines whether the string so far matches, whether it has a value, and whether another input UChar can continue a matching string.

Returns:
The match/value Result.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Traverses the trie from the initial state for this input UChar.

Equivalent to reset().next(uchar).

Parameters:
ucharInput char value. Values below 0 and above 0xffff will never match.
Returns:
The match/value Result.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 162 of file ucharstrie.h.

Referenced by firstForCodePoint().

Traverses the trie from the initial state for the one or two UTF-16 code units for this input code point.

Equivalent to reset().nextForCodePoint(cp).

Parameters:
cpA Unicode code point 0..0x10ffff.
Returns:
The match/value Result.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 175 of file ucharstrie.h.

References first(), next(), U16_LEAD, U16_TRAIL, USTRINGTRIE_HAS_NEXT, and USTRINGTRIE_NO_MATCH.

Finds each UChar which continues the string from the current state.

That is, each UChar c for which it would be next(c)!=USTRINGTRIE_NO_MATCH now.

Parameters:
outEach next UChar is appended to this object.
Returns:
the number of UChars which continue the string from here
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
int32_t UCharsTrie::getValue ( ) const [inline]

Returns a matching string's value if called immediately after current()/first()/next() returned USTRINGTRIE_INTERMEDIATE_VALUE or USTRINGTRIE_FINAL_VALUE.

getValue() can be called multiple times.

Do not call getValue() after USTRINGTRIE_NO_MATCH or USTRINGTRIE_NO_VALUE!

Returns:
The value for the string so far.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 232 of file ucharstrie.h.

UBool UCharsTrie::hasUniqueValue ( int32_t uniqueValue) const [inline]

Determines whether all strings reachable from the current state map to the same value.

Parameters:
uniqueValueReceives the unique value, if this function returns TRUE. (output-only)
Returns:
TRUE if all strings reachable from the current state map to the same value.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 249 of file ucharstrie.h.

References FALSE, and NULL.

Traverses the trie from the current state for this input UChar.

Parameters:
ucharInput char value. Values below 0 and above 0xffff will never match.
Returns:
The match/value Result.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Referenced by firstForCodePoint(), and nextForCodePoint().

UStringTrieResult UCharsTrie::next ( const UChar s,
int32_t  length 
)

Traverses the trie from the current state for this string.

Equivalent to

 Result result=current();
 for(each c in s)
   if(!USTRINGTRIE_HAS_NEXT(result)) return USTRINGTRIE_NO_MATCH;
   result=next(c);
 return result;
Parameters:
sA string. Can be NULL if length is 0.
lengthThe length of the string. Can be -1 if NUL-terminated.
Returns:
The match/value Result.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Traverses the trie from the current state for the one or two UTF-16 code units for this input code point.

Parameters:
cpA Unicode code point 0..0x10ffff.
Returns:
The match/value Result.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 198 of file ucharstrie.h.

References next(), U16_LEAD, U16_TRAIL, USTRINGTRIE_HAS_NEXT, and USTRINGTRIE_NO_MATCH.

UCharsTrie& UCharsTrie::reset ( void  ) [inline]

Resets this trie to its initial state.

Returns:
*this
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 89 of file ucharstrie.h.

UCharsTrie& UCharsTrie::resetToState ( const State state) [inline]

Resets this trie to the saved state.

If the state object contains no state, or the state of a different trie, then this trie remains unchanged.

Parameters:
stateThe State object which holds a saved trie state.
Returns:
*this
See also:
saveState
reset
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 139 of file ucharstrie.h.

References NULL.

const UCharsTrie& UCharsTrie::saveState ( State state) const [inline]

Saves the state of this trie.

Parameters:
stateThe State object to hold the trie's state.
Returns:
*this
See also:
resetToState
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 122 of file ucharstrie.h.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines