本文整理汇总了C++中UVector::elementAt方法的典型用法代码示例。如果您正苦于以下问题:C++ UVector::elementAt方法的具体用法?C++ UVector::elementAt怎么用?C++ UVector::elementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UVector
的用法示例。
在下文中一共展示了UVector::elementAt方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeMetaToOlson
UnicodeString& U_EXPORT2
ZoneMeta::getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString ®ion, UnicodeString &result) {
initializeMetaToOlson();
UBool isSet = FALSE;
if (gMetaToOlson != NULL) {
UErrorCode status = U_ZERO_ERROR;
UChar mzidUChars[ZID_KEY_MAX];
mzid.extract(mzidUChars, ZID_KEY_MAX, status);
if (U_SUCCESS(status) && status!=U_STRING_NOT_TERMINATED_WARNING) {
UVector *mappings = (UVector*)uhash_get(gMetaToOlson, mzidUChars);
if (mappings != NULL) {
// Find a preferred time zone for the given region.
for (int32_t i = 0; i < mappings->size(); i++) {
MetaToOlsonMappingEntry *olsonmap = (MetaToOlsonMappingEntry*)mappings->elementAt(i);
if (region.compare(olsonmap->territory, -1) == 0) {
result.setTo(olsonmap->id);
isSet = TRUE;
break;
} else if (u_strcmp(olsonmap->territory, gWorld) == 0) {
result.setTo(olsonmap->id);
isSet = TRUE;
}
}
}
}
}
if (!isSet) {
result.remove();
}
return result;
}
示例2:
int32_t
TimeZoneGenericNameMatchInfo::getMatchLength(int32_t index) const {
ZMatchInfo *minfo = (ZMatchInfo *)fMatches->elementAt(index);
if (minfo != NULL) {
return minfo->matchLength;
}
return -1;
}
示例3:
const UnicodeString*
MetaZoneIDsEnumeration::snext(UErrorCode& status) {
if (U_SUCCESS(status) && fMetaZoneIDs != NULL && fPos < fLen) {
unistr.setTo((const UChar*)fMetaZoneIDs->elementAt(fPos++), -1);
return &unistr;
}
return NULL;
}
示例4: init
/**
* Finish constructing a transliterator: only to be called by
* constructors. Before calling init(), set trans and filter to NULL.
* @param list a vector of transliterator objects to be adopted. It
* should NOT be empty. The list should be in declared order. That
* is, it should be in the FORWARD order; if direction is REVERSE then
* the list order will be reversed.
* @param direction either FORWARD or REVERSE
* @param fixReverseID if TRUE, then reconstruct the ID of reverse
* entries by calling getID() of component entries. Some constructors
* do not require this because they apply a facade ID anyway.
* @param status the error code indicating success or failure
*/
void CompoundTransliterator::init(UVector& list,
UTransDirection direction,
UBool fixReverseID,
UErrorCode& status) {
// assert(trans == 0);
// Allocate array
if (U_SUCCESS(status)) {
count = list.size();
trans = (Transliterator **)uprv_malloc(count * sizeof(Transliterator *));
/* test for NULL */
if (trans == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
}
if (U_FAILURE(status) || trans == 0) {
// assert(trans == 0);
return;
}
// Move the transliterators from the vector into an array.
// Reverse the order if necessary.
int32_t i;
for (i=0; i<count; ++i) {
int32_t j = (direction == UTRANS_FORWARD) ? i : count - 1 - i;
trans[i] = (Transliterator*) list.elementAt(j);
}
// Fix compoundRBTIndex for REVERSE transliterators
if (compoundRBTIndex >= 0 && direction == UTRANS_REVERSE) {
compoundRBTIndex = count - 1 - compoundRBTIndex;
}
// If the direction is UTRANS_REVERSE then we may need to fix the
// ID.
if (direction == UTRANS_REVERSE && fixReverseID) {
UnicodeString newID;
for (i=0; i<count; ++i) {
if (i > 0) {
newID.append(ID_DELIM);
}
newID.append(trans[i]->getID());
}
setID(newID);
}
computeMaximumContextLength();
}
示例5: bofFixup
//-----------------------------------------------------------------------------
//
// bofFixup. Fixup for state tables that include {bof} beginning of input testing.
// Do an swizzle similar to chaining, modifying the followPos set of
// the bofNode to include the followPos nodes from other {bot} nodes
// scattered through the tree.
//
// This function has much in common with calcChainedFollowPos().
//
//-----------------------------------------------------------------------------
void RBBITableBuilder::bofFixup()
{
if (U_FAILURE(*fStatus))
{
return;
}
// The parse tree looks like this ...
// fTree root ---> <cat>
// / \ .
// <cat> <#end node>
// / \ .
// <bofNode> rest
// of tree
//
// We will be adding things to the followPos set of the <bofNode>
//
RBBINode * bofNode = fTree->fLeftChild->fLeftChild;
U_ASSERT(bofNode->fType == RBBINode::leafChar);
U_ASSERT(bofNode->fVal == 2);
// Get all nodes that can be the start a match of the user-written rules
// (excluding the fake bofNode)
// We want the nodes that can start a match in the
// part labeled "rest of tree"
//
UVector * matchStartNodes = fTree->fLeftChild->fRightChild->fFirstPosSet;
RBBINode * startNode;
int startNodeIx;
for (startNodeIx = 0; startNodeIx < matchStartNodes->size(); startNodeIx++)
{
startNode = (RBBINode *)matchStartNodes->elementAt(startNodeIx);
if (startNode->fType != RBBINode::leafChar)
{
continue;
}
if (startNode->fVal == bofNode->fVal)
{
// We found a leaf node corresponding to a {bof} that was
// explicitly written into a rule.
// Add everything from the followPos set of this node to the
// followPos set of the fake bofNode at the start of the tree.
//
setAdd(bofNode->fFollowPos, startNode->fFollowPos);
}
}
}
示例6: calcFollowPos
//-----------------------------------------------------------------------------
//
// calcFollowPos. Impossible to explain succinctly. See Aho, section 3.9
//
//-----------------------------------------------------------------------------
void RBBITableBuilder::calcFollowPos(RBBINode * n)
{
if (n == NULL ||
n->fType == RBBINode::leafChar ||
n->fType == RBBINode::endMark)
{
return;
}
calcFollowPos(n->fLeftChild);
calcFollowPos(n->fRightChild);
// Aho rule #1
if (n->fType == RBBINode::opCat)
{
RBBINode * i; // is 'i' in Aho's description
uint32_t ix;
UVector * LastPosOfLeftChild = n->fLeftChild->fLastPosSet;
for (ix = 0; ix < (uint32_t)LastPosOfLeftChild->size(); ix++)
{
i = (RBBINode *)LastPosOfLeftChild->elementAt(ix);
setAdd(i->fFollowPos, n->fRightChild->fFirstPosSet);
}
}
// Aho rule #2
if (n->fType == RBBINode::opStar ||
n->fType == RBBINode::opPlus)
{
RBBINode * i; // again, n and i are the names from Aho's description.
uint32_t ix;
for (ix = 0; ix < (uint32_t)n->fLastPosSet->size(); ix++)
{
i = (RBBINode *)n->fLastPosSet->elementAt(ix);
setAdd(i->fFollowPos, n->fFirstPosSet);
}
}
}
示例7:
UnicodeString& TransliteratorRegistry::getAvailableVariant(int32_t index,
const UnicodeString& source,
const UnicodeString& target,
UnicodeString& result) const {
Hashtable *targets = (Hashtable*) specDAG.get(source);
if (targets == 0) {
result.truncate(0); // invalid source
return result;
}
UVector *variants = (UVector*) targets->get(target);
if (variants == 0) {
result.truncate(0); // invalid target
return result;
}
UnicodeString *v = (UnicodeString*) variants->elementAt(index);
if (v == 0) {
result.truncate(0); // invalid index
} else {
result = *v;
}
return result;
}
示例8: calcChainedFollowPos
//-----------------------------------------------------------------------------
//
// calcChainedFollowPos. Modify the previously calculated followPos sets
// to implement rule chaining. NOT described by Aho
//
//-----------------------------------------------------------------------------
void RBBITableBuilder::calcChainedFollowPos(RBBINode *tree) {
UVector endMarkerNodes(*fStatus);
UVector leafNodes(*fStatus);
int32_t i;
if (U_FAILURE(*fStatus)) {
return;
}
// get a list of all endmarker nodes.
tree->findNodes(&endMarkerNodes, RBBINode::endMark, *fStatus);
// get a list all leaf nodes
tree->findNodes(&leafNodes, RBBINode::leafChar, *fStatus);
if (U_FAILURE(*fStatus)) {
return;
}
// Get all nodes that can be the start a match, which is FirstPosition()
// of the portion of the tree corresponding to user-written rules.
// See the tree description in bofFixup().
RBBINode *userRuleRoot = tree;
if (fRB->fSetBuilder->sawBOF()) {
userRuleRoot = tree->fLeftChild->fRightChild;
}
U_ASSERT(userRuleRoot != NULL);
UVector *matchStartNodes = userRuleRoot->fFirstPosSet;
// Iteratate over all leaf nodes,
//
int32_t endNodeIx;
int32_t startNodeIx;
for (endNodeIx=0; endNodeIx<leafNodes.size(); endNodeIx++) {
RBBINode *tNode = (RBBINode *)leafNodes.elementAt(endNodeIx);
RBBINode *endNode = NULL;
// Identify leaf nodes that correspond to overall rule match positions.
// These include an endMarkerNode in their followPos sets.
for (i=0; i<endMarkerNodes.size(); i++) {
if (tNode->fFollowPos->contains(endMarkerNodes.elementAt(i))) {
endNode = tNode;
break;
}
}
if (endNode == NULL) {
// node wasn't an end node. Try again with the next.
continue;
}
// We've got a node that can end a match.
// Line Break Specific hack: If this node's val correspond to the $CM char class,
// don't chain from it.
// TODO: Add rule syntax for this behavior, get specifics out of here and
// into the rule file.
if (fRB->fLBCMNoChain) {
UChar32 c = this->fRB->fSetBuilder->getFirstChar(endNode->fVal);
if (c != -1) {
// c == -1 occurs with sets containing only the {eof} marker string.
ULineBreak cLBProp = (ULineBreak)u_getIntPropertyValue(c, UCHAR_LINE_BREAK);
if (cLBProp == U_LB_COMBINING_MARK) {
continue;
}
}
}
// Now iterate over the nodes that can start a match, looking for ones
// with the same char class as our ending node.
RBBINode *startNode;
for (startNodeIx = 0; startNodeIx<matchStartNodes->size(); startNodeIx++) {
startNode = (RBBINode *)matchStartNodes->elementAt(startNodeIx);
if (startNode->fType != RBBINode::leafChar) {
continue;
}
if (endNode->fVal == startNode->fVal) {
// The end val (character class) of one possible match is the
// same as the start of another.
// Add all nodes from the followPos of the start node to the
// followPos set of the end node, which will have the effect of
// letting matches transition from a match state at endNode
// to the second char of a match starting with startNode.
setAdd(endNode->fFollowPos, startNode->fFollowPos);
}
}
}
}
示例9: 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);
}
示例10: 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);
//.........这里部分代码省略.........
示例11: countTransitionRules
void
BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial,
UVector*& transitionRules, UErrorCode& status) /*const*/ {
if (U_FAILURE(status)) {
return;
}
const InitialTimeZoneRule *orgini;
const TimeZoneRule **orgtrs = NULL;
TimeZoneTransition tzt;
UBool avail;
UVector *orgRules = NULL;
int32_t ruleCount;
TimeZoneRule *r = NULL;
UBool *done = NULL;
InitialTimeZoneRule *res_initial = NULL;
UVector *filteredRules = NULL;
UnicodeString name;
int32_t i;
UDate time, t;
UDate *newTimes = NULL;
UDate firstStart;
UBool bFinalStd = FALSE, bFinalDst = FALSE;
// Original transition rules
ruleCount = countTransitionRules(status);
if (U_FAILURE(status)) {
return;
}
orgRules = new UVector(ruleCount, status);
if (U_FAILURE(status)) {
return;
}
orgtrs = (const TimeZoneRule**)uprv_malloc(sizeof(TimeZoneRule*)*ruleCount);
if (orgtrs == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
goto error;
}
getTimeZoneRules(orgini, orgtrs, ruleCount, status);
if (U_FAILURE(status)) {
goto error;
}
for (i = 0; i < ruleCount; i++) {
orgRules->addElement(orgtrs[i]->clone(), status);
if (U_FAILURE(status)) {
goto error;
}
}
uprv_free(orgtrs);
orgtrs = NULL;
avail = getPreviousTransition(start, TRUE, tzt);
if (!avail) {
// No need to filter out rules only applicable to time before the start
initial = orgini->clone();
transitionRules = orgRules;
return;
}
done = (UBool*)uprv_malloc(sizeof(UBool)*ruleCount);
if (done == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
goto error;
}
filteredRules = new UVector(status);
if (U_FAILURE(status)) {
goto error;
}
// Create initial rule
tzt.getTo()->getName(name);
res_initial = new InitialTimeZoneRule(name, tzt.getTo()->getRawOffset(),
tzt.getTo()->getDSTSavings());
// Mark rules which does not need to be processed
for (i = 0; i < ruleCount; i++) {
r = (TimeZoneRule*)orgRules->elementAt(i);
avail = r->getNextStart(start, res_initial->getRawOffset(), res_initial->getDSTSavings(), FALSE, time);
done[i] = !avail;
}
time = start;
while (!bFinalStd || !bFinalDst) {
avail = getNextTransition(time, FALSE, tzt);
if (!avail) {
break;
}
UDate updatedTime = tzt.getTime();
if (updatedTime == time) {
// Can get here if rules for start & end of daylight time have exactly
// the same time.
// TODO: fix getNextTransition() to prevent it?
status = U_INVALID_STATE_ERROR;
goto error;
}
time = updatedTime;
const TimeZoneRule *toRule = tzt.getTo();
for (i = 0; i < ruleCount; i++) {
r = (TimeZoneRule*)orgRules->elementAt(i);
//.........这里部分代码省略.........
示例12: buildWSConfusableData
//.........这里部分代码省略.........
extractGroup(parseRegexp, 4, srcScriptName, sizeof(srcScriptName), status);
extractGroup(parseRegexp, 5, targScriptName, sizeof(targScriptName), status);
UScriptCode srcScript =
static_cast<UScriptCode>(u_getPropertyValueEnum(UCHAR_SCRIPT, srcScriptName));
UScriptCode targScript =
static_cast<UScriptCode>(u_getPropertyValueEnum(UCHAR_SCRIPT, targScriptName));
if (U_FAILURE(status)) {
goto cleanup;
}
if (srcScript == USCRIPT_INVALID_CODE || targScript == USCRIPT_INVALID_CODE) {
status = U_INVALID_FORMAT_ERROR;
goto cleanup;
}
// select the table - (A) any case or (L) lower case only
UTrie2 *table = anyCaseTrie;
if (uregex_start(parseRegexp, 7, &status) >= 0) {
table = lowerCaseTrie;
}
// Build the set of scripts containing confusable characters for
// the code point(s) specified in this input line.
// Sanity check that the script of the source code point is the same
// as the source script indicated in the input file. Failure of this check is
// an error in the input file.
// Include the source script in the set (needed for Mixed Script Confusable detection).
//
UChar32 cp;
for (cp=startCodePoint; cp<=endCodePoint; cp++) {
int32_t setIndex = utrie2_get32(table, cp);
BuilderScriptSet *bsset = NULL;
if (setIndex > 0) {
U_ASSERT(setIndex < scriptSets->size());
bsset = static_cast<BuilderScriptSet *>(scriptSets->elementAt(setIndex));
} else {
bsset = new BuilderScriptSet();
if (bsset == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
goto cleanup;
}
bsset->codePoint = cp;
bsset->trie = table;
bsset->sset = new ScriptSet();
setIndex = scriptSets->size();
bsset->index = setIndex;
bsset->rindex = 0;
if (bsset->sset == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
goto cleanup;
}
scriptSets->addElement(bsset, status);
utrie2_set32(table, cp, setIndex, &status);
}
bsset->sset->Union(targScript);
bsset->sset->Union(srcScript);
if (U_FAILURE(status)) {
goto cleanup;
}
UScriptCode cpScript = uscript_getScript(cp, &status);
if (cpScript != srcScript) {
status = U_INVALID_FORMAT_ERROR;
goto cleanup;
}
}
}