diff --git a/icu4c/source/common/uvector.cpp b/icu4c/source/common/uvector.cpp index 41322ba7ff..a93855d440 100644 --- a/icu4c/source/common/uvector.cpp +++ b/icu4c/source/common/uvector.cpp @@ -13,23 +13,45 @@ U_NAMESPACE_BEGIN -UVector::UVector(UErrorCode &status, int32_t initialCapacity) : +#define DEFUALT_CAPACITY 8 + +UVector::UVector(UErrorCode &status) : count(0), capacity(0), elements(0), deleter(0), - comparer(0) { + comparer(0) +{ + _init(DEFUALT_CAPACITY, status); +} +UVector::UVector(int32_t initialCapacity, UErrorCode &status) : + count(0), + capacity(0), + elements(0), + deleter(0), + comparer(0) +{ _init(initialCapacity, status); } -UVector::UVector(UObjectDeleter d, UKeyComparator c, UErrorCode &status, int32_t initialCapacity) : +UVector::UVector(UObjectDeleter d, UKeyComparator c, UErrorCode &status) : count(0), capacity(0), elements(0), deleter(d), - comparer(c) { - + comparer(c) +{ + _init(DEFUALT_CAPACITY, status); +} + +UVector::UVector(UObjectDeleter d, UKeyComparator c, int32_t initialCapacity, UErrorCode &status) : + count(0), + capacity(0), + elements(0), + deleter(d), + comparer(c) +{ _init(initialCapacity, status); } @@ -237,12 +259,24 @@ void* UVector::orphanElementAt(int32_t index) { return e; } -UStack::UStack(UErrorCode &status, int32_t initialCapacity) : - UVector(status, initialCapacity) { +UStack::UStack(UErrorCode &status) : + UVector(status) +{ } -UStack::UStack(UObjectDeleter d, UKeyComparator c, UErrorCode &status, int32_t initialCapacity) : - UVector(d, c, status, initialCapacity) { +UStack::UStack(int32_t initialCapacity, UErrorCode &status) : + UVector(initialCapacity, status) +{ +} + +UStack::UStack(UObjectDeleter d, UKeyComparator c, UErrorCode &status) : + UVector(d, c, status) +{ +} + +UStack::UStack(UObjectDeleter d, UKeyComparator c, int32_t initialCapacity, UErrorCode &status) : + UVector(d, c, initialCapacity, status) +{ } void* UStack::pop(void) { diff --git a/icu4c/source/common/uvector.h b/icu4c/source/common/uvector.h index 4c75a2ef3a..fd769d458b 100644 --- a/icu4c/source/common/uvector.h +++ b/icu4c/source/common/uvector.h @@ -87,10 +87,13 @@ private: UKeyComparator comparer; public: - UVector(UErrorCode &status, int32_t initialCapacity = 8); + UVector(UErrorCode &status); - UVector(UObjectDeleter d, UKeyComparator c, UErrorCode &status, int32_t initialCapacity = 8); + UVector(int32_t initialCapacity, UErrorCode &status); + UVector(UObjectDeleter d, UKeyComparator c, UErrorCode &status); + + UVector(UObjectDeleter d, UKeyComparator c, int32_t initialCapacity, UErrorCode &status); ~UVector(); //------------------------------------------------------------ @@ -194,9 +197,13 @@ private: */ class U_COMMON_API UStack : public UVector { public: - UStack(UErrorCode &status, int32_t initialCapacity = 8); + UStack(UErrorCode &status); - UStack(UObjectDeleter d, UKeyComparator c, UErrorCode &status, int32_t initialCapacity = 8); + UStack(int32_t initialCapacity, UErrorCode &status); + + UStack(UObjectDeleter d, UKeyComparator c, UErrorCode &status); + + UStack(UObjectDeleter d, UKeyComparator c, int32_t initialCapacity, UErrorCode &status); // It's okay not to have a virtual destructor (in UVector) // because UStack has no special cleanup to do. diff --git a/icu4c/source/i18n/rbt_set.cpp b/icu4c/source/i18n/rbt_set.cpp index 092789cf78..fb125e9bd7 100644 --- a/icu4c/source/i18n/rbt_set.cpp +++ b/icu4c/source/i18n/rbt_set.cpp @@ -293,7 +293,7 @@ void TransliterationRuleSet::freeze(UParseError& parseError,UErrorCode& status) int32_t n = ruleVector->size(); int32_t j; int16_t x; - UVector v(status, 2*n); // heuristic; adjust as needed + UVector v(2*n, status); // heuristic; adjust as needed if (U_FAILURE(status)) { return;