本文整理汇总了C++中DynamicArray::removeAt方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::removeAt方法的具体用法?C++ DynamicArray::removeAt怎么用?C++ DynamicArray::removeAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicArray
的用法示例。
在下文中一共展示了DynamicArray::removeAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST( DynamicArray, removeAt ){
DynamicArray<string> arrayRemoveAt = testArrayOne;
for( size_t i = 0; i < testArrayOne.getLength() - 1; ++i ){
EXPECT_EQ( arrayRemoveAt.removeAt(1), testArrayOne[i + 1] );
}
EXPECT_EQ( 1, arrayRemoveAt.getLength() );
}
示例2: orderedRemove
void DLL_EXPORT orderedRemove(DynamicArray<T, chrunkSize> &list, T &item, signed char (*comp)(T &item1, T &item2) = 0){
if(!comp)
comp = defaultComparer<T>;
int itemIndex = orderedIndexOf(list, item, comp);
if(itemIndex == -1){
return;
}
list.removeAt(itemIndex);
}
示例3: select
void _FSSEnvironment::select(const Selector& atomSelector,
DynamicArray<Operation*>& resultList) {
// Find the criterion with the lowest number of matching operations.
// Exclude the terminator symbol from the selector while searching.
SelectorCriterion* startingCriterion = NULL;
int criteriaCount = atomSelector.getCriteria().length - 1;
for (int i = 0; i < criteriaCount; i++) {
SelectorCriterion& criterion = atomSelector.getCriteria()[i];
if (criterion.getType() == SelectorCriteriaType::SCT_OPERATION) {
startingCriterion = &criterion;
break;
} else if (criterion.getType() == SelectorCriteriaType::SCT_CLASS) {
if (startingCriterion == NULL || startingCriterion->getType() ==
SelectorCriteriaType::SCT_CLASS)
{
if (startingCriterion == NULL ||
criterion.getClass()->getMembers().length <
startingCriterion->getClass()->getMembers().length) {
startingCriterion = &criterion;
}
} else {
throw AssertionFailureException("Comparing against non-class"\
"criterion", __FILE__, __LINE__);
}
} else {
throw AssertionFailureException("Invalid criterion type.",
__FILE__, __LINE__);
}
}
// Add all operations from the starting criterion to the results list
if (startingCriterion->getType() == SCT_OPERATION) {
resultList.append(startingCriterion->getOperation());
} else if (startingCriterion->getType() == SCT_CLASS) {
int memberCount = startingCriterion->getClass()->getMembers().length;
for (int i = 0; i < memberCount; i++) {
resultList.append(startingCriterion->getClass()->getMembers()[i]);
}
}
// Remove stuff that doesn't match.
for (int i = 0; i < criteriaCount; i++) {
SelectorCriterion& criterion = atomSelector.getCriteria()[i];
if (&criterion == startingCriterion) {
continue;
}
int memberCount = resultList.getSize();
for (int j = 0; j < memberCount; j++) {
bool cull = false;
if (criterion.getType() == SCT_OPERATION) {
cull = resultList[i] != criterion.getOperation();
} else if (criterion.getType() == SCT_CLASS) {
cull = !resultList[i]->hasClass(*criterion.getClass());
} else {
throw AssertionFailureException("Invalid criterion type.",
__FILE__, __LINE__);
}
if (cull) {
resultList.removeAt(j);
memberCount--;
j--;
}
}
}
}