本文整理汇总了C++中UVector::removeAllElements方法的典型用法代码示例。如果您正苦于以下问题:C++ UVector::removeAllElements方法的具体用法?C++ UVector::removeAllElements怎么用?C++ UVector::removeAllElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UVector
的用法示例。
在下文中一共展示了UVector::removeAllElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: instantiateList
/**
* Convert the elements of the 'list' vector, which are SingleID
* objects, into actual Transliterator objects. In the course of
* this, some (or all) entries may be removed. If all entries
* are removed, the NULL transliterator will be added.
*
* Delete entries with empty basicIDs; these are generated by
* elements like "(A)" in the forward direction, or "A()" in
* the reverse. THIS MAY RESULT IN AN EMPTY VECTOR. Convert
* SingleID entries to actual transliterators.
*
* @param list vector of SingleID objects. On exit, vector
* of one or more Transliterators.
* @return new value of insertIndex. The index will shift if
* there are empty items, like "(Lower)", with indices less than
* insertIndex.
*/
void TransliteratorIDParser::instantiateList(UVector & list,
UErrorCode & ec)
{
UVector tlist(ec);
if (U_FAILURE(ec))
{
goto RETURN;
}
tlist.setDeleter(_deleteTransliteratorTrIDPars);
Transliterator * t;
int32_t i;
for (i = 0; i <= list.size(); ++i) // [sic]: i<=list.size()
{
// We run the loop too long by one, so we can
// do an insert after the last element
if (i == list.size())
{
break;
}
SingleID * single = (SingleID *) list.elementAt(i);
if (single->basicID.length() != 0)
{
t = single->createInstance();
if (t == NULL)
{
ec = U_INVALID_ID;
goto RETURN;
}
tlist.addElement(t, ec);
if (U_FAILURE(ec))
{
delete t;
goto RETURN;
}
}
}
// An empty list is equivalent to a NULL transliterator.
if (tlist.size() == 0)
{
t = createBasicInstance(ANY_NULL, NULL);
if (t == NULL)
{
// Should never happen
ec = U_INTERNAL_TRANSLITERATOR_ERROR;
}
tlist.addElement(t, ec);
if (U_FAILURE(ec))
{
delete t;
}
}
RETURN:
UObjectDeleter * save = list.setDeleter(_deleteSingleID);
list.removeAllElements();
if (U_SUCCESS(ec))
{
list.setDeleter(_deleteTransliteratorTrIDPars);
while (tlist.size() > 0)
{
t = (Transliterator *) tlist.orphanElementAt(0);
list.addElement(t, ec);
if (U_FAILURE(ec))
{
delete t;
list.removeAllElements();
break;
}
}
}
list.setDeleter(save);
}
示例2: parseCompoundID
U_CDECL_END
/**
* Parse a compound ID, consisting of an optional forward global
* filter, a separator, one or more single IDs delimited by
* separators, an an optional reverse global filter. The
* separator is a semicolon. The global filters are UnicodeSet
* patterns. The reverse global filter must be enclosed in
* parentheses.
* @param id the pattern the parse
* @param dir the direction.
* @param canonID OUTPUT parameter that receives the canonical ID,
* consisting of canonical IDs for all elements, as returned by
* parseSingleID(), separated by semicolons. Previous contents
* are discarded.
* @param list OUTPUT parameter that receives a list of SingleID
* objects representing the parsed IDs. Previous contents are
* discarded.
* @param globalFilter OUTPUT parameter that receives a pointer to
* a newly created global filter for this ID in this direction, or
* NULL if there is none.
* @return TRUE if the parse succeeds, that is, if the entire
* id is consumed without syntax error.
*/
UBool TransliteratorIDParser::parseCompoundID(const UnicodeString & id, int32_t dir,
UnicodeString & canonID,
UVector & list,
UnicodeSet *& globalFilter)
{
UErrorCode ec = U_ZERO_ERROR;
int32_t i;
int32_t pos = 0;
int32_t withParens = 1;
list.removeAllElements();
UnicodeSet * filter;
globalFilter = NULL;
canonID.truncate(0);
// Parse leading global filter, if any
withParens = 0; // parens disallowed
filter = parseGlobalFilter(id, pos, dir, withParens, &canonID);
if (filter != NULL)
{
if (!ICU_Utility::parseChar(id, pos, ID_DELIM))
{
// Not a global filter; backup and resume
canonID.truncate(0);
pos = 0;
}
if (dir == FORWARD)
{
globalFilter = filter;
}
else
{
delete filter;
}
filter = NULL;
}
UBool sawDelimiter = TRUE;
for (;;)
{
SingleID * single = parseSingleID(id, pos, dir, ec);
if (single == NULL)
{
break;
}
if (dir == FORWARD)
{
list.addElement(single, ec);
}
else
{
list.insertElementAt(single, 0, ec);
}
if (U_FAILURE(ec))
{
goto FAIL;
}
if (!ICU_Utility::parseChar(id, pos, ID_DELIM))
{
sawDelimiter = FALSE;
break;
}
}
if (list.size() == 0)
{
goto FAIL;
}
// Construct canonical ID
for (i = 0; i < list.size(); ++i)
{
SingleID * single = (SingleID *) list.elementAt(i);
canonID.append(single->canonID);
if (i != (list.size() - 1))
{
canonID.append(ID_DELIM);
//.........这里部分代码省略.........