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


C++ IntervalTree::findOverlapping方法代码示例

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


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

示例1: fillChunks

// find all matching chunks in tree and fill them
static void fillChunks(const char *source, const IntervalTree<ElemChunk> &tree, dav_off_t offset, dav_size_t size) {
    std::vector<Interval<ElemChunk> > matches;
    tree.findOverlapping(offset, offset+size-1, matches);

    for(std::vector<Interval<ElemChunk> >::iterator it = matches.begin(); it != matches.end(); it++) {
        copyBytes(source, offset, size, it->value);
    }

    if(matches.size() == 0) {
        DAVIX_SLOG(DAVIX_LOG_DEBUG, DAVIX_LOG_CHAIN, "WARNING: Received byte-range from server does not match any in the interval tree");
    }
}
开发者ID:cern-it-sdc-id,项目名称:davix,代码行数:13,代码来源:httpiovec.cpp

示例2: algorithm2

void algorithm2(vector<Square> & squares){
	
	priority_queue<Event, vector<Event>, CompareEvent> events; 
	//vector<SQINTERVAL> intervals; // vector containg all vertical intervals and their rectangles
	IntervalTree<Square, float> activeTree; // tree containing the vertical intervals
	vector<SQINTERVAL> results; // contains the intersecting vertical intervals and their rectangles

	ofstream output;
	output.open("uitvoerrechthoeken.txt");

	// start timer
	auto start = std::chrono::steady_clock::now();
	
	for (int i = 0; i < squares.size(); i++){
		Event e1 = Event(true, squares[i], squares[i].getLB().getX());
		Event e2 = Event(false, squares[i], squares[i].getRA().getX());
		events.push( e1 ); //left side event of rectangle
		events.push( e2 ); //right side event of rectangle
	}
	
	while (!events.empty()) {
		Event current = events.top();
		if (current.isLeftEdge()){
			
			if (activeTree.getIntervals().size() > 0){
				
				activeTree.findOverlapping(current.getSquare().getLB().getY(), current.getSquare().getRA().getY(), results);
				vector<Coordinate> pos;
				for (int i = 0; i < results.size(); i++){
					
					results[i].value.getIntersection(current.getSquare(), pos);
					for (int w = 0; w < pos.size(); w++){
						output << pos[w].getX() << " " << pos[w].getY() << "\n";
					}
					
					pos.clear();
				}
			}
			activeTree.addInterval(SQINTERVAL(current.getSquare().getInterval()));
      activeTree.sort();
			results.clear();
		}
		else {

      for (vector<SQINTERVAL>::iterator i = activeTree.getIntervals().begin(); i != activeTree.getIntervals().end(); ++i){
				if (current.getSquare().getId() == i->value.getId()){
          activeTree.getIntervals().erase(i);
          break;
				}
			}
			results.clear();
		}
		events.pop();
	}

	// stop timer
	auto end = std::chrono::steady_clock::now();
	auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
	output << elapsed.count() << "\n"; 
	output.close();
	cout << "Ready. \n";
	cout << elapsed.count();
}
开发者ID:yvanvds,项目名称:tmi,代码行数:63,代码来源:Algorithm.cpp


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