本文整理汇总了C++中UVector::orphanElementAt方法的典型用法代码示例。如果您正苦于以下问题:C++ UVector::orphanElementAt方法的具体用法?C++ UVector::orphanElementAt怎么用?C++ UVector::orphanElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UVector
的用法示例。
在下文中一共展示了UVector::orphanElementAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UVector
UVector*
RuleBasedTimeZone::copyRules(UVector* source) {
if (source == NULL) {
return NULL;
}
UErrorCode ec = U_ZERO_ERROR;
int32_t size = source->size();
UVector *rules = new UVector(size, ec);
if (U_FAILURE(ec)) {
return NULL;
}
int32_t i;
for (i = 0; i < size; i++) {
rules->addElement(((TimeZoneRule*)source->elementAt(i))->clone(), ec);
if (U_FAILURE(ec)) {
break;
}
}
if (U_FAILURE(ec)) {
// In case of error, clean up
for (i = 0; i < rules->size(); i++) {
TimeZoneRule *rule = (TimeZoneRule*)rules->orphanElementAt(i);
delete rule;
}
delete rules;
return NULL;
}
return rules;
}
示例2: countTransitionRules
//.........这里部分代码省略.........
if (newTimes == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
goto error;
}
for (int32_t newidx = 0; newidx < asize; newidx++) {
tar->getStartTimeAt(idx + newidx, newTimes[newidx]);
if (U_FAILURE(status)) {
uprv_free(newTimes);
newTimes = NULL;
goto error;
}
}
tar->getName(name);
TimeArrayTimeZoneRule *newTar = new TimeArrayTimeZoneRule(name,
tar->getRawOffset(), tar->getDSTSavings(), newTimes, asize, timeType);
uprv_free(newTimes);
filteredRules->addElement(newTar, status);
if (U_FAILURE(status)) {
goto error;
}
}
}
}
} else if ((ar = dynamic_cast<const AnnualTimeZoneRule *>(toRule)) != NULL) {
ar->getFirstStart(tzt.getFrom()->getRawOffset(), tzt.getFrom()->getDSTSavings(), firstStart);
if (firstStart == tzt.getTime()) {
// Just add the rule as is
filteredRules->addElement(ar->clone(), status);
if (U_FAILURE(status)) {
goto error;
}
} else {
// Calculate the transition year
int32_t year, month, dom, dow, doy, mid;
Grego::timeToFields(tzt.getTime(), year, month, dom, dow, doy, mid);
// Re-create the rule
ar->getName(name);
AnnualTimeZoneRule *newAr = new AnnualTimeZoneRule(name, ar->getRawOffset(), ar->getDSTSavings(),
*(ar->getRule()), year, ar->getEndYear());
filteredRules->addElement(newAr, status);
if (U_FAILURE(status)) {
goto error;
}
}
// check if this is a final rule
if (ar->getEndYear() == AnnualTimeZoneRule::MAX_YEAR) {
// After bot final standard and dst rules are processed,
// exit this while loop.
if (ar->getDSTSavings() == 0) {
bFinalStd = TRUE;
} else {
bFinalDst = TRUE;
}
}
}
done[i] = TRUE;
}
// Set the results
if (orgRules != NULL) {
while (!orgRules->isEmpty()) {
r = (TimeZoneRule*)orgRules->orphanElementAt(0);
delete r;
}
delete orgRules;
}
if (done != NULL) {
uprv_free(done);
}
initial = res_initial;
transitionRules = filteredRules;
return;
error:
if (orgtrs != NULL) {
uprv_free(orgtrs);
}
if (orgRules != NULL) {
while (!orgRules->isEmpty()) {
r = (TimeZoneRule*)orgRules->orphanElementAt(0);
delete r;
}
delete orgRules;
}
if (done != NULL) {
if (filteredRules != NULL) {
while (!filteredRules->isEmpty()) {
r = (TimeZoneRule*)filteredRules->orphanElementAt(0);
delete r;
}
delete filteredRules;
}
delete res_initial;
uprv_free(done);
}
initial = NULL;
transitionRules = NULL;
}