本文整理汇总了C++中UnicodeSet::ensureCapacity方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeSet::ensureCapacity方法的具体用法?C++ UnicodeSet::ensureCapacity怎么用?C++ UnicodeSet::ensureCapacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeSet
的用法示例。
在下文中一共展示了UnicodeSet::ensureCapacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getInclusions
U_CDECL_END
U_NAMESPACE_BEGIN
/*
Reduce excessive reallocation, and make it easier to detect initialization
problems.
Usually you don't see smaller sets than this for Unicode 5.0.
*/
#define DEFAULT_INCLUSION_CAPACITY 3072
const UnicodeSet* UnicodeSet::getInclusions(int32_t src, UErrorCode &status) {
UBool needInit;
UMTX_CHECK(NULL, (INCLUSIONS[src] == NULL), needInit);
if (needInit) {
UnicodeSet* incl = new UnicodeSet();
USetAdder sa = {
(USet *)incl,
_set_add,
_set_addRange,
_set_addString,
NULL, // don't need remove()
NULL // don't need removeRange()
};
incl->ensureCapacity(DEFAULT_INCLUSION_CAPACITY, status);
if (incl != NULL) {
switch(src) {
case UPROPS_SRC_CHAR:
uchar_addPropertyStarts(&sa, &status);
break;
case UPROPS_SRC_PROPSVEC:
upropsvec_addPropertyStarts(&sa, &status);
break;
case UPROPS_SRC_CHAR_AND_PROPSVEC:
uchar_addPropertyStarts(&sa, &status);
upropsvec_addPropertyStarts(&sa, &status);
break;
case UPROPS_SRC_HST:
uhst_addPropertyStarts(&sa, &status);
break;
#if !UCONFIG_NO_NORMALIZATION
case UPROPS_SRC_NORM:
unorm_addPropertyStarts(&sa, &status);
break;
#endif
case UPROPS_SRC_CASE:
ucase_addPropertyStarts(ucase_getSingleton(&status), &sa, &status);
break;
case UPROPS_SRC_BIDI:
ubidi_addPropertyStarts(ubidi_getSingleton(&status), &sa, &status);
break;
default:
status = U_INTERNAL_PROGRAM_ERROR;
break;
}
if (U_SUCCESS(status)) {
// Compact for caching
incl->compact();
umtx_lock(NULL);
if (INCLUSIONS[src] == NULL) {
INCLUSIONS[src] = incl;
incl = NULL;
ucln_common_registerCleanup(UCLN_COMMON_USET, uset_cleanup);
}
umtx_unlock(NULL);
}
delete incl;
} else {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
return INCLUSIONS[src];
}
示例2: getInclusions
U_CDECL_END
U_NAMESPACE_BEGIN
#define DEFAULT_INCLUSION_CAPACITY 3072
const UnicodeSet* UnicodeSet::getInclusions(int32_t src, UErrorCode &status) {
UBool needInit;
UMTX_CHECK(NULL, (INCLUSIONS[src] == NULL), needInit);
if (needInit) {
UnicodeSet* incl = new UnicodeSet();
USetAdder sa = {
(USet *)incl,
_set_add,
_set_addRange,
_set_addString,
NULL, // don't need remove()
NULL // don't need removeRange()
};
incl->ensureCapacity(DEFAULT_INCLUSION_CAPACITY, status);
if (incl != NULL) {
switch(src) {
case UPROPS_SRC_CHAR:
uchar_addPropertyStarts(&sa, &status);
break;
case UPROPS_SRC_PROPSVEC:
upropsvec_addPropertyStarts(&sa, &status);
break;
case UPROPS_SRC_CHAR_AND_PROPSVEC:
uchar_addPropertyStarts(&sa, &status);
upropsvec_addPropertyStarts(&sa, &status);
break;
#if !UCONFIG_NO_NORMALIZATION
case UPROPS_SRC_NORM:
unorm_addPropertyStarts(&sa, &status);
break;
case UPROPS_SRC_CASE_AND_NORM:
ucase_addPropertyStarts(ucase_getSingleton(&status), &sa, &status);
unorm_addPropertyStarts(&sa, &status);
break;
case UPROPS_SRC_NFC: {
const Normalizer2Impl *impl=Normalizer2Factory::getNFCImpl(status);
if(U_SUCCESS(status)) {
impl->addPropertyStarts(&sa, status);
}
break;
}
case UPROPS_SRC_NFKC: {
const Normalizer2Impl *impl=Normalizer2Factory::getNFKCImpl(status);
if(U_SUCCESS(status)) {
impl->addPropertyStarts(&sa, status);
}
break;
}
case UPROPS_SRC_NFKC_CF: {
const Normalizer2Impl *impl=Normalizer2Factory::getNFKC_CFImpl(status);
if(U_SUCCESS(status)) {
impl->addPropertyStarts(&sa, status);
}
break;
}
#endif
case UPROPS_SRC_CASE:
ucase_addPropertyStarts(ucase_getSingleton(&status), &sa, &status);
break;
case UPROPS_SRC_BIDI:
ubidi_addPropertyStarts(ubidi_getSingleton(&status), &sa, &status);
break;
default:
status = U_INTERNAL_PROGRAM_ERROR;
break;
}
if (U_SUCCESS(status)) {
// Compact for caching
incl->compact();
umtx_lock(NULL);
if (INCLUSIONS[src] == NULL) {
INCLUSIONS[src] = incl;
incl = NULL;
ucln_common_registerCleanup(UCLN_COMMON_USET, uset_cleanup);
}
umtx_unlock(NULL);
}
delete incl;
} else {
status = U_MEMORY_ALLOCATION_ERROR;
}
}
return INCLUSIONS[src];
}