Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ucmp16.h File Reference

Go to the source code of this file.

Compounds

struct  CompactShortArray

Typedefs

typedef struct CompactShortArray  CompactShortArray
 class CompactATypeArray : use only on primitive data types Provides a compact way to store information that is indexed by Unicode values, such as character properties, types, keyboard values, etc.This is very useful when you have a block of Unicode data that contains significant values while the rest of the Unicode data is unused in the application or when you have a lot of redundance, such as where all 21,000 Han ideographs have the same value. More...


Functions

U_CAPI int32_t U_EXPORT2 ucmp16_getkUnicodeCount (void)
U_CAPI int32_t U_EXPORT2 ucmp16_getkBlockCount (void)
U_CAPI CompactShortArray*
U_EXPORT2 
ucmp16_open (int16_t defaultValue)
 Construct an empty CompactShortArray. More...

U_CAPI void U_EXPORT2 ucmp16_init (CompactShortArray* array, int16_t defaultValue)
U_CAPI void U_EXPORT2 ucmp16_initBogus (CompactShortArray* array)
U_CAPI CompactShortArray*
U_EXPORT2 
ucmp16_openAdopt (uint16_t *indexArray, int16_t *newValues, int32_t count, int16_t defaultValue)
 Construct a CompactShortArray from a pre-computed index and values array. More...

U_CAPI CompactShortArray*
U_EXPORT2 
ucmp16_openAdoptWithBlockShift (uint16_t *indexArray, int16_t *newValues, int32_t count, int16_t defaultValue, int32_t blockShift)
U_CAPI CompactShortArray*
U_EXPORT2 
ucmp16_openAlias (uint16_t *indexArray, int16_t *newValues, int32_t count, int16_t defaultValue )
U_CAPI CompactShortArray*
U_EXPORT2 
ucmp16_initAdopt (CompactShortArray *this_obj, uint16_t *indexArray, int16_t *newValues, int32_t count, int16_t defaultValue )
 Initialize a CompactShortArray from a pre-computed index and values array. More...

U_CAPI CompactShortArray*
U_EXPORT2 
ucmp16_initAdoptWithBlockShift (CompactShortArray *this_obj, uint16_t *indexArray, int16_t *newValues, int32_t count, int16_t defaultValue, int32_t blockShift)
U_CAPI CompactShortArray*
U_EXPORT2 
ucmp16_initAlias (CompactShortArray *this_obj, uint16_t *indexArray, int16_t *newValues, int32_t count, int16_t defaultValue )
U_CAPI CompactShortArray*
U_EXPORT2 
ucmp16_initAliasWithBlockShift (CompactShortArray *this_obj, uint16_t *indexArray, int16_t *newValues, int32_t count, int16_t defaultValue, int32_t blockShift)
U_CAPI void U_EXPORT2 ucmp16_close (CompactShortArray* array)
U_CAPI UBool U_EXPORT2 ucmp16_isBogus (const CompactShortArray* array)
 Returns TRUE if the creation of the compact array fails.

U_CAPI void U_EXPORT2 ucmp16_set (CompactShortArray *array, UChar character, int16_t value)
 Set a new value for a Unicode character. More...

U_CAPI void U_EXPORT2 ucmp16_setRange (CompactShortArray* array, UChar start, UChar end, int16_t value)
 Set new values for a range of Unicode character. More...

U_CAPI void U_EXPORT2 ucmp16_compact (CompactShortArray* array)
 Compact the array. More...

U_CAPI int16_t U_EXPORT2 ucmp16_getDefaultValue (const CompactShortArray* array)
 Get the default value.

U_CAPI uint32_t U_EXPORT2 ucmp16_getCount (const CompactShortArray* array)
 Get the number of elements in the value array. More...

U_CAPI const int16_t* U_EXPORT2 ucmp16_getArray (const CompactShortArray* array)
 Get the address of the value array. More...

U_CAPI const uint16_t* U_EXPORT2 ucmp16_getIndex (const CompactShortArray* array)
 Get the address of the index array. More...

U_CAPI uint32_t U_EXPORT2 ucmp16_flattenMem (const CompactShortArray* array, UMemoryStream *MS)
 INTERNAL USE ONLY *.

U_CAPI void U_EXPORT2 ucmp16_initFromData (CompactShortArray* array, const uint8_t **source, UErrorCode *status)


Typedef Documentation

typedef struct CompactShortArray CompactShortArray
 

class CompactATypeArray : use only on primitive data types Provides a compact way to store information that is indexed by Unicode values, such as character properties, types, keyboard values, etc.This is very useful when you have a block of Unicode data that contains significant values while the rest of the Unicode data is unused in the application or when you have a lot of redundance, such as where all 21,000 Han ideographs have the same value.

However, lookup is much faster than a hash table.

A compact array of any primitive data type serves two purposes:

  • Fast access of the indexed values.
  • Smaller memory footprint.

The index array always points into particular parts of the data array it is initially set up to point at regular block boundaries The following example uses blocks of 4 for simplicity

 Example: Expanded
 BLOCK  0   1   2   3   4
 INDEX  0   4   8   12  16 ...
 ARRAY  abcdeababcdezyabcdea...
        |   |   |   |   |   |...
 

After compression, the index will point to various places in the data array wherever there is a runs of the same elements as in the original

 Example: Compressed
 BLOCK  0   1   2   3   4
 INDEX  0   4   1   8   2 ...
 ARRAY  abcdeabazyabc...
 

If you look at the example, index number 2 in the expanded version points to data position number 8, which has elements "bcde". In the compressed version, index number 2 points to data position 1, which also has "bcde"

See also:
CompactByteArray , CompactIntArray , CompactCharArray , CompactStringArray
Version:
Revision:
1.15
8/25/98
Author(s):
Helena Shih


Function Documentation

U_CAPI void U_EXPORT2 ucmp16_close ( CompactShortArray * array )
 

U_CAPI void U_EXPORT2 ucmp16_compact ( CompactShortArray * array )
 

Compact the array.

For efficency, this method will only re-use blocks in the values array that are on a block bounday. If you want better compaction, you can do your own compaction and use the constructor that lets you pass in the pre-computed arrays.

U_CAPI uint32_t U_EXPORT2 ucmp16_flattenMem ( const CompactShortArray * array,
UMemoryStream * MS )
 

INTERNAL USE ONLY *.

U_CAPI const int16_t *U_EXPORT2 ucmp16_getArray ( const CompactShortArray * array )
 

Get the address of the value array.

Returns:
the address of the value array

U_CAPI uint32_t U_EXPORT2 ucmp16_getCount ( const CompactShortArray * array )
 

Get the number of elements in the value array.

Returns:
the number of elements in the value array.

U_CAPI int16_t U_EXPORT2 ucmp16_getDefaultValue ( const CompactShortArray * array )
 

Get the default value.

U_CAPI const uint16_t *U_EXPORT2 ucmp16_getIndex ( const CompactShortArray * array )
 

Get the address of the index array.

Returns:
the address of the index array

U_CAPI int32_t U_EXPORT2 ucmp16_getkBlockCount ( void )
 

U_CAPI int32_t U_EXPORT2 ucmp16_getkUnicodeCount ( void )
 

U_CAPI void U_EXPORT2 ucmp16_init ( CompactShortArray * array,
int16_t defaultValue )
 

U_CAPI CompactShortArray *U_EXPORT2 ucmp16_initAdopt ( CompactShortArray * this_obj,
uint16_t * indexArray,
int16_t * newValues,
int32_t count,
int16_t defaultValue )
 

Initialize a CompactShortArray from a pre-computed index and values array.

The values will be adopted by the CompactShortArray. No memory is allocated. Note: for speed, the compact method will only re-use blocks in the values array that are on a block boundary. The pre-computed arrays passed in to this constructor may re-use blocks at any position in the values array.

Parameters:
this_obj   the CompactShortArray to be initialized
indexArray   the index array to be adopted
newValues   the value array to be adopted
count   the number of entries in the value array
defaultValue   the default value for all characters not explicitly in the array
See also:
compact

U_CAPI CompactShortArray* U_EXPORT2 ucmp16_initAdoptWithBlockShift ( CompactShortArray * this_obj,
uint16_t * indexArray,
int16_t * newValues,
int32_t count,
int16_t defaultValue,
int32_t blockShift )
 

U_CAPI CompactShortArray* U_EXPORT2 ucmp16_initAlias ( CompactShortArray * this_obj,
uint16_t * indexArray,
int16_t * newValues,
int32_t count,
int16_t defaultValue )
 

U_CAPI CompactShortArray* U_EXPORT2 ucmp16_initAliasWithBlockShift ( CompactShortArray * this_obj,
uint16_t * indexArray,
int16_t * newValues,
int32_t count,
int16_t defaultValue,
int32_t blockShift )
 

U_CAPI void U_EXPORT2 ucmp16_initBogus ( CompactShortArray * array )
 

U_CAPI void U_EXPORT2 ucmp16_initFromData ( CompactShortArray * array,
const uint8_t ** source,
UErrorCode * status )
 

U_CAPI UBool U_EXPORT2 ucmp16_isBogus ( const CompactShortArray * array )
 

Returns TRUE if the creation of the compact array fails.

U_CAPI CompactShortArray *U_EXPORT2 ucmp16_open ( int16_t defaultValue )
 

Construct an empty CompactShortArray.

Parameters:
defaultValue   the default value for all characters not explicitly in the array

U_CAPI CompactShortArray *U_EXPORT2 ucmp16_openAdopt ( uint16_t * indexArray,
int16_t * newValues,
int32_t count,
int16_t defaultValue )
 

Construct a CompactShortArray from a pre-computed index and values array.

The values will be adopted by the CompactShortArray. Memory is allocated with uprv_malloc. Note: for speed, the compact method will only re-use blocks in the values array that are on a block boundary. The pre-computed arrays passed in to this constructor may re-use blocks at any position in the values array.

Parameters:
indexArray   the index array to be adopted
newValues   the value array to be adopted
count   the number of entries in the value array
defaultValue   the default value for all characters not explicitly in the array
See also:
compact

U_CAPI CompactShortArray* U_EXPORT2 ucmp16_openAdoptWithBlockShift ( uint16_t * indexArray,
int16_t * newValues,
int32_t count,
int16_t defaultValue,
int32_t blockShift )
 

U_CAPI CompactShortArray* U_EXPORT2 ucmp16_openAlias ( uint16_t * indexArray,
int16_t * newValues,
int32_t count,
int16_t defaultValue )
 

U_CAPI void U_EXPORT2 ucmp16_set ( CompactShortArray * array,
UChar character,
int16_t value )
 

Set a new value for a Unicode character.

Set automatically expands the array if it is compacted.

Parameters:
character   the character to set the mapped value with
value   the new mapped value

U_CAPI void U_EXPORT2 ucmp16_setRange ( CompactShortArray * array,
UChar start,
UChar end,
int16_t value )
 

Set new values for a range of Unicode character.

Parameters:
start   the starting offset of the range
end   the ending offset of the range
value   the new mapped value


Generated at Tue Dec 5 17:55:44 2000 for ICU by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000