本文整理汇总了C++中UVector类的典型用法代码示例。如果您正苦于以下问题:C++ UVector类的具体用法?C++ UVector怎么用?C++ UVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UVector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: valueDeleter
void
CharacterNode::addValue(void *value, UObjectDeleter *valueDeleter, UErrorCode &status) {
if (U_FAILURE(status)) {
if (valueDeleter) {
valueDeleter(value);
}
return;
}
if (fValues == NULL) {
fValues = value;
} else {
// At least one value already.
if (!fHasValuesVector) {
// There is only one value so far, and not in a vector yet.
// Create a vector and add the old value.
UVector *values = new UVector(valueDeleter, NULL, DEFAULT_CHARACTERNODE_CAPACITY, status);
if (U_FAILURE(status)) {
if (valueDeleter) {
valueDeleter(value);
}
return;
}
values->addElement(fValues, status);
fValues = values;
fHasValuesVector = TRUE;
}
// Add the new value.
((UVector *)fValues)->addElement(value, status);
}
}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:30,代码来源:tznames_impl.cpp
示例2: 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;
}
开发者ID:0omega,项目名称:platform_external_icu4c,代码行数:29,代码来源:rbtz.cpp
示例3: UVector
UVector *AlphabeticIndex::firstStringsInScript(UErrorCode &status) {
if (U_FAILURE(status)) {
return NULL;
}
UVector *dest = new UVector(status);
if (dest == NULL) {
if (U_SUCCESS(status)) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return NULL;
}
dest->setDeleter(uprv_deleteUObject);
const UChar *src = HACK_FIRST_CHARS_IN_SCRIPTS;
const UChar *limit = src + sizeof(HACK_FIRST_CHARS_IN_SCRIPTS) / sizeof(HACK_FIRST_CHARS_IN_SCRIPTS[0]);
do {
if (U_FAILURE(status)) {
return dest;
}
UnicodeString *str = new UnicodeString(src, -1);
if (str == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
dest->addElement(str, status);
src += str->length() + 1;
}
} while (src < limit);
dest->sortWithUComparator(sortCollateComparator, collator_, status);
return dest;
}
开发者ID:0omega,项目名称:platform_external_icu4c,代码行数:29,代码来源:alphaindex.cpp
示例4: 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;
}
开发者ID:Andproject,项目名称:platform_external_icu4c,代码行数:31,代码来源:zonemeta.cpp
示例5: umtx_initOnce
/**
* Returns an enumeration over the IDs of all the regions that are children of this region anywhere in the region
* hierarchy and match the given type. This API may return an empty enumeration if this region doesn't have any
* sub-regions that match the given type. For example, calling this method with region "150" (Europe) and type
* "URGN_TERRITORY" returns a set containing all the territories in Europe ( "FR" (France) - "IT" (Italy) - "DE" (Germany) etc. )
*/
StringEnumeration*
Region::getContainedRegions( URegionType type, UErrorCode &status ) const {
umtx_initOnce(gRegionDataInitOnce, &loadRegionData, status); // returns immediately if U_FAILURE(status)
if (U_FAILURE(status)) {
return NULL;
}
UVector *result = new UVector(NULL, uhash_compareChars, status);
StringEnumeration *cr = getContainedRegions(status);
for ( int32_t i = 0 ; i < cr->count(status) ; i++ ) {
const char *id = cr->next(NULL,status);
const Region *r = Region::getInstance(id,status);
if ( r->getType() == type ) {
result->addElement((void *)&r->idStr,status);
} else {
StringEnumeration *children = r->getContainedRegions(type, status);
for ( int32_t j = 0 ; j < children->count(status) ; j++ ) {
const char *id2 = children->next(NULL,status);
const Region *r2 = Region::getInstance(id2,status);
result->addElement((void *)&r2->idStr,status);
}
delete children;
}
}
delete cr;
StringEnumeration* resultEnumeration = new RegionNameEnumeration(result,status);
delete result;
return resultEnumeration;
}
开发者ID:Cyril2004,项目名称:proto-quic,代码行数:37,代码来源:region.cpp
示例6: 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);
}
开发者ID:Botyto,项目名称:Core,代码行数:37,代码来源:rbbitblb.cpp
示例7: U_ASSERT
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;
}
}
开发者ID:winlibs,项目名称:icu4c,代码行数:25,代码来源:number_compact.cpp
示例8: MetaZoneIDsEnumeration
StringEnumeration*
TimeZoneNamesImpl::getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const {
if (U_FAILURE(status)) {
return NULL;
}
const UVector* mappings = ZoneMeta::getMetazoneMappings(tzID);
if (mappings == NULL) {
return new MetaZoneIDsEnumeration();
}
MetaZoneIDsEnumeration *senum = NULL;
UVector* mzIDs = new UVector(NULL, uhash_compareUChars, status);
if (mzIDs == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
}
if (U_SUCCESS(status)) {
U_ASSERT(mzIDs != NULL);
for (int32_t i = 0; U_SUCCESS(status) && i < mappings->size(); i++) {
OlsonToMetaMappingEntry *map = (OlsonToMetaMappingEntry *)mappings->elementAt(i);
const UChar *mzID = map->mzid;
if (!mzIDs->contains((void *)mzID)) {
mzIDs->addElement((void *)mzID, status);
}
}
if (U_SUCCESS(status)) {
senum = new MetaZoneIDsEnumeration(mzIDs);
} else {
delete mzIDs;
}
}
return senum;
}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:33,代码来源:tznames_impl.cpp
示例9: UVector
UVector *AlphabeticIndex::firstStringsInScript(UErrorCode &status) {
if (U_FAILURE(status)) {
return NULL;
}
UVector *dest = new UVector(status);
if (dest == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
dest->setDeleter(uprv_deleteUObject);
const UChar *src = HACK_FIRST_CHARS_IN_SCRIPTS;
const UChar *limit = src + LENGTHOF(HACK_FIRST_CHARS_IN_SCRIPTS);
do {
if (U_FAILURE(status)) {
return dest;
}
UnicodeString *str = new UnicodeString(src, -1);
if (str == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
return dest;
}
dest->addElement(str, status);
src += str->length() + 1;
} while (src < limit);
return dest;
}
开发者ID:Congle,项目名称:platform_external_icu4c,代码行数:26,代码来源:alphaindex.cpp
示例10: 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();
}
开发者ID:GuillaumeSmaha,项目名称:stringi,代码行数:10,代码来源:transreg.cpp
示例11: U_ASSERT
//-----------------------------------------------------------------------------
//
// 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);
}
}
}
开发者ID:Botyto,项目名称:Core,代码行数:60,代码来源:rbbitblb.cpp
示例12: 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();
}
开发者ID:andrewleech,项目名称:firebird,代码行数:63,代码来源:cpdtrans.cpp
示例13: appendUnicodeSetToUVector
static void appendUnicodeSetToUVector(UVector &dest, const UnicodeSet &source, UErrorCode &status) {
UnicodeSetIterator setIter(source);
while (setIter.next()) {
const UnicodeString &str = setIter.getString();
dest.addElement(str.clone(), status);
}
}
开发者ID:0omega,项目名称:platform_external_icu4c,代码行数:7,代码来源:alphaindex.cpp
示例14: buildFilenameListFrom
static void buildFilenameListFrom(UVector<UString>& vec, const UString& arg)
{
U_TRACE(5, "Application::buildFilenameListFrom(%p,%.*S)", &vec, U_STRING_TO_TRACE(arg))
uint32_t pos;
UTokenizer t(arg);
UString dir, filename, filter;
while (t.next(filename, ','))
{
if (filename.find_first_of("?*", 0, 2) == U_NOT_FOUND) vec.push(filename);
else
{
pos = filename.find_last_of('/');
U_INTERNAL_DUMP("pos = %u", pos)
if (pos == U_NOT_FOUND)
{
UDirWalk dirwalk(0, U_STRING_TO_PARAM(filename));
(void) dirwalk.walk(vec);
}
else
{
dir = filename.substr(0U, pos);
filter = filename.substr(pos + 1);
UDirWalk dirwalk(dir, U_STRING_TO_PARAM(filter));
(void) dirwalk.walk(vec);
}
}
}
}
开发者ID:fast01,项目名称:ULib,代码行数:35,代码来源:update.cpp
示例15: 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;
}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:8,代码来源:uvector.cpp
示例16: 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);
}
}
}
开发者ID:Botyto,项目名称:Core,代码行数:49,代码来源:rbbitblb.cpp
示例17: Hashtable
/**
* Register a source-target/variant in the specDAG. Variant may be
* empty, but source and target must not be. If variant is empty then
* the special variant NO_VARIANT is stored in slot zero of the
* UVector of variants.
*/
void TransliteratorRegistry::registerSTV(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) {
targets = new Hashtable(TRUE, status);
if (U_FAILURE(status) || targets == 0) {
return;
}
targets->setValueDeleter(uprv_deleteUObject);
specDAG.put(source, targets, status);
}
UVector *variants = (UVector*) targets->get(target);
if (variants == 0) {
variants = new UVector(uprv_deleteUObject,
uhash_compareCaselessUnicodeString, status);
if (variants == 0) {
return;
}
targets->put(target, variants, status);
}
// assert(NO_VARIANT == "");
// We add the variant string. If it is the special "no variant"
// string, that is, the empty string, we add it at position zero.
if (!variants->contains((void*) &variant)) {
UnicodeString *tempus; // Used for null pointer check.
if (variant.length() > 0) {
tempus = new UnicodeString(variant);
if (tempus != NULL) {
variants->addElement(tempus, status);
}
} else {
tempus = new UnicodeString(); // = NO_VARIANT
if (tempus != NULL) {
variants->insertElementAt(tempus, 0, status);
}
}
}
}
开发者ID:GuillaumeSmaha,项目名称:stringi,代码行数:48,代码来源:transreg.cpp
示例18: 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");
}
开发者ID:mason105,项目名称:red5cpp,代码行数:20,代码来源:rbbitblb.cpp
示例19: retainAll
UBool UVector::retainAll(const UVector& other) {
UBool changed = FALSE;
for (int32_t j=size()-1; j>=0; --j) {
int32_t i = other.indexOf(elements[j]);
if (i < 0) {
removeElementAt(j);
changed = TRUE;
}
}
return changed;
}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:11,代码来源:uvector.cpp
示例20: 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;
}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:11,代码来源:uvector.cpp
注:本文中的UVector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论