Logo Search packages:      
Sourcecode: icu version File versions

Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes

AlphabeticIndex Class Reference

#include <alphaindex.h>

Inheritance diagram for AlphabeticIndex:
Inheritance graph
[legend]
Collaboration diagram for AlphabeticIndex:
Collaboration graph
[legend]

List of all members.

Classes

struct  Bucket
struct  Record

Public Types

enum  ELangType { kNormal, kSimplified, kTraditional }

Public Member Functions

virtual AlphabeticIndexaddLabels (const UnicodeSet &additions, UErrorCode &status)
virtual AlphabeticIndexaddLabels (const Locale &locale, UErrorCode &status)
virtual AlphabeticIndexaddRecord (const UnicodeString &name, const void *data, UErrorCode &status)
 AlphabeticIndex (const Locale &locale, UErrorCode &status)
virtual AlphabeticIndexclearRecords (UErrorCode &status)
virtual int32_t getBucketCount (UErrorCode &status)
virtual int32_t getBucketIndex (const UnicodeString &itemName, UErrorCode &status)
virtual int32_t getBucketIndex () const
virtual const UnicodeStringgetBucketLabel () const
virtual UAlphabeticIndexLabelType getBucketLabelType () const
virtual int32_t getBucketRecordCount () const
virtual const RuleBasedCollatorgetCollator () const
virtual const UnicodeStringgetInflowLabel () const
virtual int32_t getMaxLabelCount () const
virtual const UnicodeStringgetOverflowComparisonString (const UnicodeString &lowerLimit, UErrorCode &status)
virtual const UnicodeStringgetOverflowLabel () const
virtual int32_t getRecordCount (UErrorCode &status)
virtual const void * getRecordData () const
virtual const UnicodeStringgetRecordName () const
virtual const UnicodeStringgetUnderflowLabel () const
virtual UBool nextBucket (UErrorCode &status)
virtual UBool nextRecord (UErrorCode &status)
virtual AlphabeticIndexresetBucketIterator (UErrorCode &status)
virtual AlphabeticIndexresetRecordIterator ()
virtual AlphabeticIndexsetInflowLabel (const UnicodeString &inflowLabel, UErrorCode &status)
virtual AlphabeticIndexsetMaxLabelCount (int32_t maxLabelCount, UErrorCode &status)
virtual AlphabeticIndexsetOverflowLabel (const UnicodeString &overflowLabel, UErrorCode &status)
virtual AlphabeticIndexsetUnderflowLabel (const UnicodeString &underflowLabel, UErrorCode &status)
virtual ~AlphabeticIndex ()

Static Public Member Functions

static ELangType langTypeFromLocale (const Locale &loc)
static void U_EXPORT2 operator delete (void *p) U_NO_THROW
static void U_EXPORT2 operator delete (void *, void *) U_NO_THROW
static void U_EXPORT2 operator delete[] (void *p) U_NO_THROW
static void *U_EXPORT2 operator new (size_t, void *ptr) U_NO_THROW
static void *U_EXPORT2 operator new (size_t size) U_NO_THROW
static void *U_EXPORT2 operator new[] (size_t size) U_NO_THROW
static void staticCleanup ()

Public Attributes

UVectorinputRecords_

Private Types

typedef const UChar PinyinLookup [24][3]

Private Member Functions

 AlphabeticIndex (const AlphabeticIndex &other)
void bucketRecords (UErrorCode &status)
void buildBucketList (UErrorCode &status)
void buildIndex (UErrorCode &status)
UVectorfirstStringsInScript (UErrorCode &status)
virtual UClassID getDynamicClassID () const
void hackName (UnicodeString &dest, const UnicodeString &name, const Collator *coll)
void init (UErrorCode &status)
void initPinyinBounds (const Collator *coll, UErrorCode &status)
virtual UBool operator!= (const AlphabeticIndex &other) const
AlphabeticIndexoperator= (const AlphabeticIndex &)
virtual UBool operator== (const AlphabeticIndex &other) const

Static Private Member Functions

static void getIndexExemplars (UnicodeSet &dest, const Locale &locale, UErrorCode &status)
static UnicodeSetgetScriptSet (UnicodeSet &dest, const UnicodeString &codePoint, UErrorCode &status)
static UnicodeString separated (const UnicodeString &item)
static void staticInit (UErrorCode &status)

Private Attributes

UHashtablealreadyIn_
UVectorbucketList_
Collatorcollator_
CollatorcollatorPrimaryOnly_
BucketcurrentBucket_
UVectorfirstScriptCharacters_
UBool indexBuildRequired_
UnicodeString inflowLabel_
UnicodeSetinitialLabels_
int32_t itemsIterIndex_
UVectorlabels_
int32_t labelsIterIndex_
ELangType langType_
Locale locale_
int32_t maxLabelCount_
UnicodeSetnoDistinctSorting_
UnicodeSetnotAlphabetic_
UnicodeString overflowComparisonString_
UnicodeString overflowLabel_
int32_t recordCounter_
UnicodeString underflowLabel_

Static Private Attributes

static UnicodeSetALPHABETIC
static UnicodeSetCORE_LATIN
static const UnicodeStringEMPTY_STRING
static UnicodeSetETHIOPIC
static PinyinLookup * HACK_PINYIN_LOOKUP = NULL
static PinyinLookup HACK_PINYIN_LOOKUP_LONG
static PinyinLookup HACK_PINYIN_LOOKUP_SHORT
static UnicodeSetHANGUL
static UnicodeSetIGNORE_SCRIPTS
static const UCharPINYIN_LOWER_BOUNDS = NULL
static UnicodeSetTO_TRY
static UnicodeSetUNIHAN

Detailed Description

class AlphabeticIndex supports the creation of a UI index appropriate for a given language, such as:

  ... A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \u00C6 \u00D8 \u00C5 ...
  A
     Addison
     Albertson
     Azensky
  B
     Baker
  ...
 

The class can generate a list of labels for use as a UI "index", that is, a list of clickable characters (or character sequences) that allow the user to see a segment (bucket) of a larger "target" list. That is, each label corresponds to a bucket in the target list, where everything in the bucket is greater than or equal to the character (according to the locale's collation). Strings can be added to the index; they will be in sorted order in the right bucket.

The class also supports having buckets for strings before the first (underflow), after the last (overflow), and between scripts (inflow). For example, if the index is constructed with labels for Russian and English, Greek characters would fall into an inflow bucket between the other two scripts.

The AlphabeticIndex class is not intended for public subclassing.

Example

The "show..." methods below are just to illustrate usage.

 // Create a simple index.  "Item" is assumed to be an application
 // defined type that the application's UI and other processing knows about,
 //  and that has a name.
 UErrorCode status = U_ZERO_ERROR;
 AlphabeticIndex index = new AlphabeticIndex(desiredLocale, status);
 index->addLabels(additionalLocale, status);
 for (Item *item in some source of Items ) {
     index->addRecord(item->name(), item, status);
 }
 ...
 // Show index at top. We could skip or gray out empty buckets
 while (index->nextBucket(status)) {
     if (showAll || index->getBucketRecordCount() != 0) {
         showLabelAtTop(UI, index->getBucketLabel());
     }
 }
  ...
 // Show the buckets with their contents, skipping empty buckets
 index->resetBucketIterator(status);
 while (index->nextBucket(status)) {
    if (index->getBucketRecordCount() != 0) {
        showLabelInList(UI, index->getBucketLabel());
        while (index->nextRecord(status)) {
            showIndexedItem(UI, static_cast<Item *>(index->getRecordData()))
 

The caller can build different UIs using this class. For example, an index character could be omitted or grayed-out if its bucket is empty. Small buckets could also be combined based on size, such as:

 ... A-F G-N O-Z ...
 

Notes:

ICU 4.8 This API might change or be removed in a future release.

Definition at line 163 of file alphaindex.h.


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

Generated by  Doxygen 1.6.0   Back to index