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


C++ ListType::erase方法代码示例

本文整理汇总了C++中ListType::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ ListType::erase方法的具体用法?C++ ListType::erase怎么用?C++ ListType::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListType的用法示例。


在下文中一共展示了ListType::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: removeEdge

bool DirectedGraph::removeEdge(int fromNodeId, int toNodeId) {
	ListType::iterator neighborToRemove;
	ListType* fromNeighbors = inNeighborsTable[toNodeId];
	
	neighborToRemove = std::lower_bound(fromNeighbors->begin(), fromNeighbors->end(), fromNodeId);
	if (neighborToRemove != fromNeighbors->end() && (*neighborToRemove == fromNodeId))
		fromNeighbors->erase(neighborToRemove);
	else
		return false;
	
	ListType* toNeighbors = outNeighborsTable[fromNodeId];
	neighborToRemove = std::lower_bound(toNeighbors->begin(), toNeighbors->end(), toNodeId);
	assert(*neighborToRemove == toNodeId);
	toNeighbors->erase(neighborToRemove);
	edgeCount--;
	return true;
}
开发者ID:supergao222,项目名称:compression,代码行数:17,代码来源:DirectedGraph.cpp

示例2: addToList

	void addToList(const typename ListType::value_type &data, ListType &list) const {
		if (length()<=0) {
			// Ensure that no dummy data will get added. Shouldn't get here.
			return;
		}
		if (startbyte()==0 && goesToEndOfFile()) {
			// favor a single chunk covering the whole file.
			list.clear();
			list.insert(list.end(), data);
			return;
		}

		typename ListType::iterator endIter=list.end(), iter=list.begin();
		Range::base_type startdata = startbyte();
		Range::base_type maxend = startdata;
		bool includeseof = false;
		while (iter != endIter) {
			// maxend is not relevant for ranges strictly above us.
			if ((*iter).startbyte() > startdata) {
				break;
			}
			if ((*iter).endbyte() > maxend) {
				maxend = (*iter).endbyte();
			}
			if ((*iter).goesToEndOfFile()) {
				includeseof = true;
			}
			// we do not want to allow for more than one
			// range starting at the same start byte--
			// If this is the case, one is guaranteed to overlap.
			if ((*iter).startbyte() >= startdata) {
				break;
			}
			++iter;
		}
		if (includeseof || (maxend > endbyte() && !goesToEndOfFile())) {
			return; // already included by another range.
		}
		iter = list.insert(iter, data);
		++iter;
		while (iter != endIter) {
			typename ListType::iterator nextIter = iter;
			++nextIter;

			if (goesToEndOfFile() ||
					(!(*iter).goesToEndOfFile() && (*iter).endbyte() <= endbyte())) {
				list.erase(iter);
			}

			iter = nextIter;
		}
	}
开发者ID:ericruth,项目名称:sirikata,代码行数:52,代码来源:Range.hpp


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