chromium/third_party/icu/source/i18n/alphaindex.cpp

// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2009-2014, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*/

#include "unicode/utypes.h"

#if !UCONFIG_NO_COLLATION

#include "unicode/alphaindex.h"
#include "unicode/coll.h"
#include "unicode/localpointer.h"
#include "unicode/normalizer2.h"
#include "unicode/tblcoll.h"
#include "unicode/uchar.h"
#include "unicode/ulocdata.h"
#include "unicode/uniset.h"
#include "unicode/uobject.h"
#include "unicode/usetiter.h"
#include "unicode/utf16.h"

#include "cmemory.h"
#include "cstring.h"
#include "uassert.h"
#include "uvector.h"
#include "uvectr64.h"

//#include <string>
//#include <iostream>

U_NAMESPACE_BEGIN

namespace {

/**
 * Prefix string for Chinese index buckets.
 * See http://unicode.org/repos/cldr/trunk/specs/ldml/tr35-collation.html#Collation_Indexes
 */
const char16_t BASE[1] =;
const int32_t BASE_LENGTH =;

UBool isOneLabelBetterThanOther(const Normalizer2 &nfkdNormalizer,
                                const UnicodeString &one, const UnicodeString &other);

}  // namespace

static int32_t U_CALLCONV
collatorComparator(const void *context, const void *left, const void *right);

static int32_t U_CALLCONV
recordCompareFn(const void *context, const void *left, const void *right);

//  UVector<Record *> support function, delete a Record.
static void U_CALLCONV
alphaIndex_deleteRecord(void *obj) {}

namespace {

UnicodeString *ownedString(const UnicodeString &s, LocalPointer<UnicodeString> &owned,
                           UErrorCode &errorCode) {}

inline UnicodeString *getString(const UVector &list, int32_t i) {}

inline AlphabeticIndex::Bucket *getBucket(const UVector &list, int32_t i) {}

inline AlphabeticIndex::Record *getRecord(const UVector &list, int32_t i) {}

/**
 * Like Java Collections.binarySearch(List, String, Comparator).
 *
 * @return the index>=0 where the item was found,
 *         or the index<0 for inserting the string at ~index in sorted order
 */
int32_t binarySearch(const UVector &list, const UnicodeString &s, const Collator &coll) {}

}  // namespace

// The BucketList is not in the anonymous namespace because only Clang
// seems to support its use in other classes from there.
// However, we also don't need U_I18N_API because it is not used from outside the i18n library.
class BucketList : public UObject {};

BucketList::~BucketList() {}

AlphabeticIndex::ImmutableIndex::~ImmutableIndex() {}

int32_t
AlphabeticIndex::ImmutableIndex::getBucketCount() const {}

int32_t
AlphabeticIndex::ImmutableIndex::getBucketIndex(
        const UnicodeString &name, UErrorCode &errorCode) const {}

const AlphabeticIndex::Bucket *
AlphabeticIndex::ImmutableIndex::getBucket(int32_t index) const {}

AlphabeticIndex::AlphabeticIndex(const Locale &locale, UErrorCode &status)
        :{}


AlphabeticIndex::AlphabeticIndex(RuleBasedCollator *collator, UErrorCode &status)
        :{}



AlphabeticIndex::~AlphabeticIndex() {}


AlphabeticIndex &AlphabeticIndex::addLabels(const UnicodeSet &additions, UErrorCode &status) {}


AlphabeticIndex &AlphabeticIndex::addLabels(const Locale &locale, UErrorCode &status) {}


AlphabeticIndex::ImmutableIndex *AlphabeticIndex::buildImmutableIndex(UErrorCode &errorCode) {}

int32_t AlphabeticIndex::getBucketCount(UErrorCode &status) {}


int32_t AlphabeticIndex::getRecordCount(UErrorCode &status) {}

void AlphabeticIndex::initLabels(UVector &indexCharacters, UErrorCode &errorCode) const {}

namespace {

const UnicodeString &fixLabel(const UnicodeString &current, UnicodeString &temp) {}

UBool hasMultiplePrimaryWeights(
        const RuleBasedCollator &coll, uint32_t variableTop,
        const UnicodeString &s, UVector64 &ces, UErrorCode &errorCode) {}

}  // namespace

BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const {}

/**
 * Creates an index, and buckets and sorts the list of records into the index.
 */
void AlphabeticIndex::initBuckets(UErrorCode &errorCode) {}

void AlphabeticIndex::clearBuckets() {}

void AlphabeticIndex::internalResetBucketIterator() {}


void AlphabeticIndex::addIndexExemplars(const Locale &locale, UErrorCode &status) {}

UBool AlphabeticIndex::addChineseIndexCharacters(UErrorCode &errorCode) {}


/*
 * Return the string with interspersed CGJs. Input must have more than 2 codepoints.
 */
static const char16_t CGJ =;
UnicodeString AlphabeticIndex::separated(const UnicodeString &item) {}


bool AlphabeticIndex::operator==(const AlphabeticIndex& /* other */) const {}


bool AlphabeticIndex::operator!=(const AlphabeticIndex& /* other */) const {}


const RuleBasedCollator &AlphabeticIndex::getCollator() const {}


const UnicodeString &AlphabeticIndex::getInflowLabel() const {}

const UnicodeString &AlphabeticIndex::getOverflowLabel() const {}


const UnicodeString &AlphabeticIndex::getUnderflowLabel() const {}


AlphabeticIndex &AlphabeticIndex::setInflowLabel(const UnicodeString &label, UErrorCode &/*status*/) {}


AlphabeticIndex &AlphabeticIndex::setOverflowLabel(const UnicodeString &label, UErrorCode &/*status*/) {}


AlphabeticIndex &AlphabeticIndex::setUnderflowLabel(const UnicodeString &label, UErrorCode &/*status*/) {}


int32_t AlphabeticIndex::getMaxLabelCount() const {}


AlphabeticIndex &AlphabeticIndex::setMaxLabelCount(int32_t maxLabelCount, UErrorCode &status) {}


//
//  init() - Common code for constructors.
//

void AlphabeticIndex::init(const Locale *locale, UErrorCode &status) {}


//
//  Comparison function for UVector<UnicodeString *> sorting with a collator.
//
static int32_t U_CALLCONV
collatorComparator(const void *context, const void *left, const void *right) {}

//
//  Comparison function for UVector<Record *> sorting with a collator.
//
static int32_t U_CALLCONV
recordCompareFn(const void *context, const void *left, const void *right) {}

UVector *AlphabeticIndex::firstStringsInScript(UErrorCode &status) {}


namespace {

/**
 * Returns true if one index character string is "better" than the other.
 * Shorter NFKD is better, and otherwise NFKD-binary-less-than is
 * better, and otherwise binary-less-than is better.
 */
UBool isOneLabelBetterThanOther(const Normalizer2 &nfkdNormalizer,
                                const UnicodeString &one, const UnicodeString &other) {}

}  // namespace

//
//  Constructor & Destructor for AlphabeticIndex::Record
//
//     Records are internal only, instances are not directly surfaced in the public API.
//     This class is mostly struct-like, with all public fields.

AlphabeticIndex::Record::Record(const UnicodeString &name, const void *data)
        :{}

AlphabeticIndex::Record::~Record() {}


AlphabeticIndex & AlphabeticIndex::addRecord(const UnicodeString &name, const void *data, UErrorCode &status) {}


AlphabeticIndex &AlphabeticIndex::clearRecords(UErrorCode &status) {}

int32_t AlphabeticIndex::getBucketIndex(const UnicodeString &name, UErrorCode &status) {}


int32_t AlphabeticIndex::getBucketIndex() const {}


UBool AlphabeticIndex::nextBucket(UErrorCode &status) {}

const UnicodeString &AlphabeticIndex::getBucketLabel() const {}


UAlphabeticIndexLabelType AlphabeticIndex::getBucketLabelType() const {}


int32_t AlphabeticIndex::getBucketRecordCount() const {}


AlphabeticIndex &AlphabeticIndex::resetBucketIterator(UErrorCode &status) {}


UBool AlphabeticIndex::nextRecord(UErrorCode &status) {}


const UnicodeString &AlphabeticIndex::getRecordName() const {}

const void *AlphabeticIndex::getRecordData() const {}


AlphabeticIndex & AlphabeticIndex::resetRecordIterator() {}



AlphabeticIndex::Bucket::Bucket(const UnicodeString &label,
                                const UnicodeString &lowerBoundary,
                                UAlphabeticIndexLabelType type)
        :{}


AlphabeticIndex::Bucket::~Bucket() {}

U_NAMESPACE_END

#endif  // !UCONFIG_NO_COLLATION