当前位置: 首页>>代码示例>>C++>>正文


C++ DynamicArray::removeAt方法代码示例

本文整理汇总了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() );
}
开发者ID:curtisai,项目名称:CS585MKII,代码行数:7,代码来源:test_dynamic_array.cpp

示例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);
}
开发者ID:enjoythelive1,项目名称:memory-manage,代码行数:12,代码来源:DynamicArray.cpp

示例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--;
			}

		}
	}
}
开发者ID:andrewoftoronto,项目名称:FreeDynamics,代码行数:71,代码来源:impl_FSS.cpp


注:本文中的DynamicArray::removeAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。