本文整理汇总了C++中UVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ UVector::size方法的具体用法?C++ UVector::size怎么用?C++ UVector::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UVector
的用法示例。
在下文中一共展示了UVector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int32_t
TimeZoneGenericNameMatchInfo::size() const {
if (fMatches == NULL) {
return 0;
}
return fMatches->size();
}
示例2: updateVisibleIDs
void updateVisibleIDs(Hashtable& result, UErrorCode& status) const {
if (U_SUCCESS(_status)) {
for (int32_t i = 0; i < _ids.size(); ++i) {
result.put(*(UnicodeString*)_ids[i], (void*)this, status);
}
}
}
示例3: 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;
}
示例4: getUniquePatterns
void CompactData::getUniquePatterns(UVector &output, UErrorCode &status) const {
U_ASSERT(output.isEmpty());
// NOTE: In C++, this is done more manually with a UVector.
// In Java, we can take advantage of JDK HashSet.
for (auto pattern : patterns) {
if (pattern == nullptr || pattern == USE_FALLBACK) {
continue;
}
// Insert pattern into the UVector if the UVector does not already contain the pattern.
// Search the UVector from the end since identical patterns are likely to be adjacent.
for (int32_t i = output.size() - 1; i >= 0; i--) {
if (u_strcmp(pattern, static_cast<const UChar *>(output[i])) == 0) {
goto continue_outer;
}
}
// The string was not found; add it to the UVector.
// ANDY: This requires a const_cast. Why?
output.addElement(const_cast<UChar *>(pattern), status);
continue_outer:
continue;
}
}
示例5: sortedAdd
//-----------------------------------------------------------------------------
//
// sortedAdd Add a value to a vector of sorted values (ints).
// Do not replicate entries; if the value is already there, do not
// add a second one.
// Lazily create the vector if it does not already exist.
//
//-----------------------------------------------------------------------------
void RBBITableBuilder::sortedAdd(UVector ** vector, int32_t val)
{
int32_t i;
if (*vector == NULL)
{
*vector = new UVector(*fStatus);
}
if (*vector == NULL || U_FAILURE(*fStatus))
{
return;
}
UVector * vec = *vector;
int32_t vSize = vec->size();
for (i = 0; i < vSize; i++)
{
int32_t valAtI = vec->elementAti(i);
if (valAtI == val)
{
// The value is already in the vector. Don't add it again.
return;
}
if (valAtI > val)
{
break;
}
}
vec->insertElementAt(val, i, *fStatus);
}
示例6: 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;
}
示例7: containsNone
UBool UVector::containsNone(const UVector& other) const {
for (int32_t i=0; i<other.size(); ++i) {
if (indexOf(other.elements[i]) >= 0) {
return FALSE;
}
}
return TRUE;
}
示例8: countAvailableVariants
int32_t TransliteratorRegistry::countAvailableVariants(const UnicodeString& source,
const UnicodeString& target) const {
Hashtable *targets = (Hashtable*) specDAG.get(source);
if (targets == 0) {
return 0;
}
UVector *variants = (UVector*) targets->get(target);
// variants may be 0 if the source/target are invalid
return (variants == 0) ? 0 : variants->size();
}
示例9: removeAll
UBool UVector::removeAll(const UVector& other) {
UBool changed = FALSE;
for (int32_t i=0; i<other.size(); ++i) {
int32_t j = indexOf(other.elements[i]);
if (j >= 0) {
removeElementAt(j);
changed = TRUE;
}
}
return changed;
}
示例10: while
uint32_t UXML2Document::getElement(UVector<UString>& velement, const char* tag, uint32_t tag_len)
{
U_TRACE(0, "UXML2Document::getElement(%p,%.*S,%u)", &velement, tag_len, tag, tag_len)
U_INTERNAL_ASSERT_POINTER(tag)
UString element;
uint32_t n = velement.size(), pos = 0;
while (true)
{
pos = getElement(element, pos, tag, tag_len);
if (pos == U_NOT_FOUND) break;
velement.push(element);
}
uint32_t result = velement.size() - n;
U_RETURN(result);
}
示例11: 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();
}
示例12: 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);
}
}
}
示例13: 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);
}
}
}
示例14: printRuleStatusTable
void RBBITableBuilder::printRuleStatusTable() {
int32_t thisRecord = 0;
int32_t nextRecord = 0;
int i;
UVector *tbl = fRB->fRuleStatusVals;
RBBIDebugPrintf("index | tags \n");
RBBIDebugPrintf("-------------------\n");
while (nextRecord < tbl->size()) {
thisRecord = nextRecord;
nextRecord = thisRecord + tbl->elementAti(thisRecord) + 1;
RBBIDebugPrintf("%4d ", thisRecord);
for (i=thisRecord+1; i<nextRecord; i++) {
RBBIDebugPrintf(" %5d", tbl->elementAti(i));
}
RBBIDebugPrintf("\n");
}
RBBIDebugPrintf("\n\n");
}
示例15: removeSTV
/**
* Remove a source-target/variant from the specDAG.
*/
void TransliteratorRegistry::removeSTV(const UnicodeString& source,
const UnicodeString& target,
const UnicodeString& variant) {
// assert(source.length() > 0);
// assert(target.length() > 0);
// UErrorCode status = U_ZERO_ERROR;
Hashtable *targets = (Hashtable*) specDAG.get(source);
if (targets == 0) {
return; // should never happen for valid s-t/v
}
UVector *variants = (UVector*) targets->get(target);
if (variants == 0) {
return; // should never happen for valid s-t/v
}
variants->removeElement((void*) &variant);
if (variants->size() == 0) {
targets->remove(target); // should delete variants
if (targets->count() == 0) {
specDAG.remove(source); // should delete targets
}
}
}