A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1AlphabeticIndex.html below:

ICU 77.1: icu::AlphabeticIndex Class Reference

AlphabeticIndex supports the creation of a UI index appropriate for a given language. More...

  AlphabeticIndex (const Locale &locale, UErrorCode &status)   Construct an AlphabeticIndex object for the specified locale. More...
    AlphabeticIndex (RuleBasedCollator *collator, UErrorCode &status)   Construct an AlphabeticIndex that uses a specific collator. More...
  virtual AlphabeticIndexaddLabels (const UnicodeSet &additions, UErrorCode &status)   Add Labels to this Index. More...
  virtual AlphabeticIndexaddLabels (const Locale &locale, UErrorCode &status)   Add the index characters from a Locale to the index. More...
  virtual  ~AlphabeticIndex ()   Destructor. More...
  ImmutableIndexbuildImmutableIndex (UErrorCode &errorCode)   Builds an immutable, thread-safe version of this instance, without data records. More...
  virtual const RuleBasedCollatorgetCollator () const   Get the Collator that establishes the ordering of the items in this index. More...
  virtual const UnicodeStringgetInflowLabel () const   Get the default label used for abbreviated buckets between other index characters. More...
  virtual AlphabeticIndexsetInflowLabel (const UnicodeString &inflowLabel, UErrorCode &status)   Set the default label used for abbreviated buckets between other index characters. More...
  virtual const UnicodeStringgetOverflowLabel () const   Get the special label used for items that sort after the last normal label, and that would not otherwise have an appropriate label. More...
  virtual AlphabeticIndexsetOverflowLabel (const UnicodeString &overflowLabel, UErrorCode &status)   Set the label used for items that sort after the last normal label, and that would not otherwise have an appropriate label. More...
  virtual const UnicodeStringgetUnderflowLabel () const   Get the special label used for items that sort before the first normal label, and that would not otherwise have an appropriate label. More...
  virtual AlphabeticIndexsetUnderflowLabel (const UnicodeString &underflowLabel, UErrorCode &status)   Set the label used for items that sort before the first normal label, and that would not otherwise have an appropriate label. More...
  virtual int32_t  getMaxLabelCount () const   Get the limit on the number of labels permitted in the index. More...
  virtual AlphabeticIndexsetMaxLabelCount (int32_t maxLabelCount, UErrorCode &status)   Set a limit on the number of labels permitted in the index. More...
  virtual AlphabeticIndexaddRecord (const UnicodeString &name, const void *data, UErrorCode &status)   Add a record to the index. More...
  virtual AlphabeticIndexclearRecords (UErrorCode &status)   Remove all Records from the Index. More...
  virtual int32_t  getBucketCount (UErrorCode &status)   Get the number of labels in this index. More...
  virtual int32_t  getRecordCount (UErrorCode &status)   Get the total number of Records in this index, that is, the number of <name, data> pairs added. More...
  virtual int32_t  getBucketIndex (const UnicodeString &itemName, UErrorCode &status)   Given the name of a record, return the zero-based index of the Bucket in which the item should appear. More...
  virtual int32_t  getBucketIndex () const   Get the zero based index of the current Bucket from an iteration over the Buckets of this index. More...
  virtual UBool  nextBucket (UErrorCode &status)   Advance the iteration over the Buckets of this index. More...
  virtual const UnicodeStringgetBucketLabel () const   Return the name of the Label of the current bucket from an iteration over the buckets. More...
  virtual UAlphabeticIndexLabelType  getBucketLabelType () const   Return the type of the label for the current Bucket (selected by the iteration over Buckets.) More...
  virtual int32_t  getBucketRecordCount () const   Get the number of <name, data> Records in the current Bucket. More...
  virtual AlphabeticIndexresetBucketIterator (UErrorCode &status)   Reset the Bucket iteration for this index. More...
  virtual UBool  nextRecord (UErrorCode &status)   Advance to the next record in the current Bucket. More...
  virtual const UnicodeStringgetRecordName () const   Get the name of the current Record. More...
  virtual const void *  getRecordData () const   Return the data pointer of the Record currently being iterated over. More...
  virtual AlphabeticIndexresetRecordIterator ()   Reset the Record iterator position to before the first Record in the current Bucket. More...
  virtual  ~UObject ()   Destructor. More...
  virtual UClassID  getDynamicClassID () const   ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. More...
 

AlphabeticIndex supports the creation of a UI index appropriate for a given language.

It can support either direct use, or use with a client that doesn't support localized collation. The following is an example of what an index might look like in a UI:

 ... 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  ...

 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.

Note: If you expect to have a lot of ASCII or Latin characters as well as characters from the user's language, then it is a good idea to call addLabels(Locale::getEnglish(), status).

Direct Use

The following shows an example of building an index directly. 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 ...
Client Support

Callers can also use the AlphabeticIndex::ImmutableIndex, or the AlphabeticIndex itself, to support sorting on a client that doesn't support AlphabeticIndex functionality.

The ImmutableIndex is both immutable and thread-safe. The corresponding AlphabeticIndex methods are not thread-safe because they "lazily" build the index buckets.

Stable:
ICU 4.8

Definition at line 192 of file alphaindex.h.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4