Clean up:
removed old comments and
redundant private methods that isn't used anywhere.

X-SVN-Rev: 5083
This commit is contained in:
Syn Wee Quek 2001-06-26 17:41:10 +00:00
parent 5cad90229b
commit 8fa2ab2060
5 changed files with 22 additions and 252 deletions

View File

@ -156,6 +156,8 @@ void CollationElementIterator::setText(const UnicodeString& source,
}
init_collIterate(m_data_->iteratordata_.coll, string, length,
&m_data_->iteratordata_);
m_data_->reset_ = TRUE;
}
// Sets the source to the new character iterator.
@ -188,6 +190,7 @@ void CollationElementIterator::setText(CharacterIterator& source,
m_data_->isWritable = TRUE;
init_collIterate(m_data_->iteratordata_.coll, buffer, length,
&m_data_->iteratordata_);
m_data_->reset_ = TRUE;
}
int32_t CollationElementIterator::strengthOrder(int32_t order) const
@ -205,21 +208,6 @@ int32_t CollationElementIterator::strengthOrder(int32_t order) const
/* CollationElementIterator private constructors/destructors --------------- */
/*
This private method will never be called, but it makes the linker happy
CollationElementIterator::CollationElementIterator() : m_data_(0)
{
}
*/
CollationElementIterator::CollationElementIterator(
const RuleBasedCollator* order)
: isDataOwned_(TRUE)
{
UErrorCode status = U_ZERO_ERROR;
m_data_ = ucol_openElements(order->ucollator, NULL, 0, &status);
}
/**
* This is the "real" constructor for this class; it constructs an iterator
* over the source text using the specified collator

View File

@ -49,13 +49,6 @@ CollationKey::CollationKey()
{
}
// Adopt bytes allocated with malloc
CollationKey::CollationKey(int32_t count, uint8_t *values)
: fBogus(FALSE), fCount(count), fCapacity(count),
fHashCode(kInvalidHashCode), fBytes(values)
{
}
// Create a collation key from a bit array.
CollationKey::CollationKey(const uint8_t* newValues, int32_t count)
: fBogus(FALSE), fCount(count), fCapacity(count),
@ -72,11 +65,6 @@ CollationKey::CollationKey(const uint8_t* newValues, int32_t count)
uprv_memcpy(fBytes, newValues, fCount);
}
CollationKey::CollationKey(const UnicodeString& value)
{
copyUnicodeString(value);
}
CollationKey::CollationKey(const CollationKey& other)
: fBogus(FALSE), fCount(other.fCount), fCapacity(other.fCapacity),
fHashCode(other.fHashCode), fBytes(NULL)
@ -116,10 +104,11 @@ void CollationKey::adopt(uint8_t *values, int32_t count) {
fCapacity = count;
fHashCode = kInvalidHashCode;
}
// set the key to an empty state
CollationKey&
CollationKey::reset()
{
{
fCount = 0;
fBogus = FALSE;
fHashCode = kEmptyHashCode;
@ -173,7 +162,9 @@ CollationKey::operator=(const CollationKey& other)
}
else
{
reset();
fCount = 0;
fBogus = FALSE;
fHashCode = kEmptyHashCode;
}
}
@ -283,62 +274,6 @@ CollationKey::ensureCapacity(int32_t newSize)
return *this;
}
int32_t
CollationKey::storeUnicodeString(int32_t cursor, const UnicodeString &value)
{
UTextOffset input = 0;
int32_t charCount = value.length();
while (input < charCount)
{
cursor = storeBytes(cursor, value[input++]);
}
return storeBytes(cursor, 0);
}
CollationKey&
CollationKey::copyUnicodeString(const UnicodeString &value)
{
int32_t charCount = value.length();
// We allocate enough space for two null bytes at the end.
ensureCapacity((charCount * 2) + 2);
if (isBogus())
{
return *this;
}
storeUnicodeString(0, value);
return *this;
}
void
CollationKey::reverseBytes(UTextOffset from, UTextOffset to)
{
uint8_t *left = &fBytes[from];
uint8_t *right = &fBytes[to - 2];
while (left < right)
{
uint8_t swap[2];
swap[0] = right[0];
swap[1] = right[1];
right[0] = left[0];
right[1] = left[1];
left[0] = swap[0];
left[1] = swap[1];
left += 2;
right -= 2;
}
}
// Create a copy of the byte array.
uint8_t*
@ -359,33 +294,6 @@ CollationKey::toByteArray(int32_t& count) const
return result;
}
uint16_t*
CollationKey::copyValues(int32_t &size) const
{
uint16_t *result;
uint8_t *input = fBytes;
UTextOffset output = 0;
size = fCount / 2;
result = new uint16_t[size];
if (result == NULL)
{
size = 0;
}
else
{
while (output < size)
{
result[output] = (uint16_t)((input[0] << 8) | input[1]);
output += 1;
input += 2;
}
}
return result;
}
int32_t
CollationKey::hashCode() const
{

View File

@ -174,11 +174,6 @@ ucol_setText( UCollationElements *elems,
return;
}
/* gets the correct length of the null-terminated string */
if (textLength == -1) {
textLength = u_strlen(text);
}
if (elems->isWritable && elems->iteratordata_.string != NULL)
{
uprv_free(elems->iteratordata_.string);
@ -198,7 +193,20 @@ U_CAPI UTextOffset
ucol_getOffset(const UCollationElements *elems)
{
const collIterate *ci = &(elems->iteratordata_);
return ci->pos - ci->string;
// while processing characters in normalization buffer getOffset will
// return the next non-normalized character.
// should be inline with the old implementation since the old codes uses
// nextDecomp in normalizer which also decomposes the string till the
// first base character is found.
if (ci->flags & UCOL_ITER_INNORMBUF) {
if (ci->fcdPosition == NULL) {
return 0;
}
return ci->fcdPosition - ci->string;
}
else {
return ci->pos - ci->string;
}
}
U_CAPI void

View File

@ -27,22 +27,9 @@
#ifndef COLEITR_H
#define COLEITR_H
// #include "unicode/unistr.h"
#include "unicode/tblcoll.h"
#include "unicode/ucoleitr.h"
// #include "tables.h"
// #include "unicode/chariter.h"
// have to do this because the include path in the main project does not have
// tables.h.
// class VectorOfInt;
// class Normalizer;
// class VectorOfPToContractElement;
// class RuleBasedCollator;
// typedef void * UCollationElements;
// struct UCollationElements;
typedef struct UCollationElements UCollationElements;
/**
@ -294,41 +281,8 @@ protected:
private:
// friend class RuleBasedCollator;
// CollationElementIterator private data members ----------------------------
// static const int32_t UNMAPPEDCHARVALUE;
/*
Normalizer* text; // owning
VectorOfInt* bufferAlias; // not owned
*/
/**
* ownBuffer wants to be a subobject, not a pointer, but that means exposing
* the internal class VectorOfInt by #including the internal header
* "tables.h" -- not allowed! ownBuffer is a fixed-size 2-element vector that
* is used to handle Thai collation; bufferAlias points to ownBuffer in some
* situations. [j159 - aliu]
*/
// VectorOfInt* ownBuffer;
/**
* reorderBuffer is created on demand, so it doesn't want to be a subobject --
* pointer is fine. It is created and bufferAlias is set to it under certain
* conditions. Once created, it is reused for the life of this object. Because
* of the implementation of VectorOfInt, it grows monotonically. [j159 - aliu]
*/
/*
VectorOfInt* reorderBuffer;
int32_t expIndex;
UnicodeString key;
const RuleBasedCollator* orderAlias;
*/
/**
* Data wrapper for collation elements
*/
@ -338,50 +292,6 @@ private:
* Indicates if m_data_ belongs to this object.
*/
UBool isDataOwned_;
// CollationElementIterator private constructor/destructor ------------------
/**
* Default constructor.
*/
/* CollationElementIterator(); */
/**
* Constructor.
* @param order RuleBasedCollator object
*/
CollationElementIterator(const RuleBasedCollator* order);
// CollationElementIterator private methods ---------------------------------
/**
* Gets the ordering priority of the next contracting character in the string.
* @param ch the starting character of a contracting character token
* @param status the error code status.
* @return the next contracting character's ordering. Returns NULLORDER if the
* end of string is reached.
*/
// int32_t nextContractChar(UChar32 ch, UErrorCode& status);
/**
* Gets the ordering priority of the previous contracting character in the
* string.
* @param ch the starting character of a contracting character token
* @param status the error code status.
* @return the previous contracting character's ordering. Returns NULLORDER if
* the start of string is reached.
*/
// int32_t prevContractChar(UChar32 ch, UErrorCode& status);
// inline static UBool isThaiPreVowel(UChar32 ch);
// inline static UBool isThaiBaseConsonant(UChar32 ch);
/*
VectorOfInt* makeReorderedBuffer(UChar colFirst, int32_t lastValue,
VectorOfInt* lastExpansion, UBool forward,
UErrorCode& status);
*/
};
// CollationElementIterator inline method defination --------------------------
@ -428,25 +338,4 @@ inline UBool CollationElementIterator::isIgnorable(int32_t order)
return (primaryOrder(order) == RuleBasedCollator::PRIMIGNORABLE);
}
/**
* Determine if a character is a Thai vowel (which sorts after
* its base consonant).
*/
/*
inline UBool CollationElementIterator::isThaiPreVowel(UChar32 ch)
{
return ((uint32_t)ch - 0xe40) <= (0xe44 - 0xe40);
}
*/
/**
* Determine if a character is a Thai base consonant
*/
/*
inline UBool CollationElementIterator::isThaiBaseConsonant(UChar32 ch)
{
return ((uint32_t)ch - 0xe01) <= (0xe2e - 0xe01);
}
*/
#endif

View File

@ -207,25 +207,12 @@ private:
* @param size output parameter of the number of collation key values
* @return a pointer to an array of 16-bit collation key values.
*/
uint16_t* copyValues(int32_t &size) const;
void adopt(uint8_t *values, int32_t count);
/**
* The secret adopting constructor!
*/
CollationKey(int32_t count, uint8_t *values);
/*
* Creates a collation key with a string.
*/
CollationKey(const UnicodeString& value);
int32_t storeBytes(int32_t cursor, uint32_t byteValue);
int32_t storeUnicodeString(int32_t cursor, const UnicodeString &value);
void reverseBytes(int32_t from, int32_t to);
CollationKey& ensureCapacity(int32_t newSize);
CollationKey& copyUnicodeString(const UnicodeString &value);
CollationKey& setToBogus(void);
CollationKey& reset(void);
@ -259,14 +246,4 @@ CollationKey::getByteArray(int32_t &count) const
count = fCount;
return fBytes;
}
inline UTextOffset
CollationKey::storeBytes(UTextOffset cursor, uint32_t byteValue)
{
fBytes[cursor++] = (uint8_t) (byteValue >> 8);
fBytes[cursor++] = (uint8_t) byteValue;
return cursor;
}
#endif