ICU 4.8.1.1  4.8.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Public Member Functions
UCharsTrieBuilder Class Reference

Builder class for UCharsTrie. More...

#include <ucharstriebuilder.h>

Inheritance diagram for UCharsTrieBuilder:
StringTrieBuilder UObject UMemory

Public Member Functions

 UCharsTrieBuilder (UErrorCode &errorCode)
 Constructs an empty builder. More...
 
virtual ~UCharsTrieBuilder ()
 Destructor. More...
 
UCharsTrieBuilderadd (const UnicodeString &s, int32_t value, UErrorCode &errorCode)
 Adds a (string, value) pair. More...
 
UCharsTriebuild (UStringTrieBuildOption buildOption, UErrorCode &errorCode)
 Builds a UCharsTrie for the add()ed data. More...
 
UnicodeStringbuildUnicodeString (UStringTrieBuildOption buildOption, UnicodeString &result, UErrorCode &errorCode)
 Builds a UCharsTrie for the add()ed data and UChar-serializes it. More...
 
UCharsTrieBuilderclear ()
 Removes all (string, value) pairs. More...
 
- Public Member Functions inherited from UObject
virtual ~UObject ()
 Destructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from StringTrieBuilder
static UBool hashNode (const void *node)
 
static UBool equalNodes (const void *left, const void *right)
 
- Static Public Member Functions inherited from UMemory
static void * operator new (size_t size)
 Override for ICU4C C++ memory management. More...
 
static void * operator new[] (size_t size)
 Override for ICU4C C++ memory management. More...
 
static void operator delete (void *p)
 Override for ICU4C C++ memory management. More...
 
static void operator delete[] (void *p)
 Override for ICU4C C++ memory management. More...
 
static void * operator new (size_t, void *ptr)
 Override for ICU4C C++ memory management for STL. More...
 
static void operator delete (void *, void *)
 Override for ICU4C C++ memory management for STL. More...
 
- Protected Member Functions inherited from StringTrieBuilder
 StringTrieBuilder ()
 
virtual ~StringTrieBuilder ()
 
void createCompactBuilder (int32_t sizeGuess, UErrorCode &errorCode)
 
void deleteCompactBuilder ()
 
void build (UStringTrieBuildOption buildOption, int32_t elementsLength, UErrorCode &errorCode)
 
int32_t writeNode (int32_t start, int32_t limit, int32_t unitIndex)
 
int32_t writeBranchSubNode (int32_t start, int32_t limit, int32_t unitIndex, int32_t length)
 
NodemakeNode (int32_t start, int32_t limit, int32_t unitIndex, UErrorCode &errorCode)
 
NodemakeBranchSubNode (int32_t start, int32_t limit, int32_t unitIndex, int32_t length, UErrorCode &errorCode)
 
NoderegisterNode (Node *newNode, UErrorCode &errorCode)
 Makes sure that there is only one unique node registered that is equivalent to newNode. More...
 
NoderegisterFinalValue (int32_t value, UErrorCode &errorCode)
 Makes sure that there is only one unique FinalValueNode registered with this value. More...
 
- Protected Attributes inherited from StringTrieBuilder
UHashtable * nodes
 
- Static Protected Attributes inherited from StringTrieBuilder
static const int32_t kMaxBranchLinearSubNodeLength =5
 
static const int32_t kMaxSplitBranchLevels =14
 

Detailed Description

Builder class for UCharsTrie.

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 33 of file ucharstriebuilder.h.

Constructor & Destructor Documentation

UCharsTrieBuilder::UCharsTrieBuilder ( UErrorCode errorCode)

Constructs an empty builder.

Parameters
errorCodeStandard ICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
virtual UCharsTrieBuilder::~UCharsTrieBuilder ( )
virtual

Destructor.

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

Member Function Documentation

UCharsTrieBuilder& UCharsTrieBuilder::add ( const UnicodeString s,
int32_t  value,
UErrorCode errorCode 
)

Adds a (string, value) pair.

The string must be unique. The string contents will be copied; the builder does not keep a reference to the input UnicodeString or its buffer.

Parameters
sThe input string.
valueThe value associated with this string.
errorCodeStandard ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)
Returns
*this
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UCharsTrie* UCharsTrieBuilder::build ( UStringTrieBuildOption  buildOption,
UErrorCode errorCode 
)

Builds a UCharsTrie for the add()ed data.

Once built, no further data can be add()ed until clear() is called.

This method passes ownership of the builder's internal result array to the new trie object. Another call to any build() variant will re-serialize the trie. After clear() has been called, a new array will be used as well.

Parameters
buildOptionBuild option, see UStringTrieBuildOption.
errorCodeStandard ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)
Returns
A new UCharsTrie for the add()ed data.
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UnicodeString& UCharsTrieBuilder::buildUnicodeString ( UStringTrieBuildOption  buildOption,
UnicodeString result,
UErrorCode errorCode 
)

Builds a UCharsTrie for the add()ed data and UChar-serializes it.

Once built, no further data can be add()ed until clear() is called.

Multiple calls to buildUnicodeString() set the UnicodeStrings to the builder's same UChar array, without rebuilding. If buildUnicodeString() is called after build(), the trie will be re-serialized into a new array. If build() is called after buildUnicodeString(), the trie object will become the owner of the previously returned array. After clear() has been called, a new array will be used as well.

Parameters
buildOptionBuild option, see UStringTrieBuildOption.
resultA UnicodeString which will be set to the UChar-serialized UCharsTrie for the add()ed data.
errorCodeStandard ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)
Returns
result
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UCharsTrieBuilder& UCharsTrieBuilder::clear ( )
inline

Removes all (string, value) pairs.

New data can then be add()ed and a new trie can be built.

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

Definition at line 111 of file ucharstriebuilder.h.


The documentation for this class was generated from the following file: