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


C++ Samples::clear方法代码示例

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


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

示例1: clear

	void clear() {
		SamplesIterator i, end = samples.end();
		for (i = samples.begin(); i != end; ++i) {
			// delete object pointed to by Sample* pointer
			delete (*i);
		}
		samples.clear();
		byNames.clear();
		marker::manager.unref(markers);
	}
开发者ID:djhshih,项目名称:genomic,代码行数:10,代码来源:RawSampleSet.hpp

示例2: filter

	void filter(const marker::Set& refMarkers) {
		if (markers == NULL) {
			throw invalid_argument("Markers in sample set are missing.");
		}
		
		// flag markers for removal
		markers->filter(refMarkers);
		
		if (samples.size() > 0) {
		
			// Create copy of samples with only unflagged markers
			
			// Shallow copy current samples (copy pointers)
			Samples oldSamples = samples;
			
			// clear current data
			samples.clear();
			byNames.clear();
			
			// pre-allocate space
			samples.resize(oldSamples.size());
			for (size_t sampleIndex = 0; sampleIndex < oldSamples.size(); ++sampleIndex) {
				// iterate through chromosomes
				for (size_t chromIndex = 0; chromIndex < oldSamples[0]->size(); ++chromIndex) {
					// resize chromosome to be as big as chromosome from old sample
					samples[sampleIndex]->resizeChromosome(chromIndex, (*oldSamples[sampleIndex])[chromIndex].size());
				}
			}
			
			// copy data from unflagged markers
			const size_t chromEnd = markers->size();
			vector<size_t> validMarkersCounts(chromEnd);
			for (size_t chromIndex = 0; chromIndex < chromEnd; ++chromIndex) {
				const size_t numMarkers = (*markers)[chromIndex].size();
				validMarkersCounts[chromIndex] = 0;
				for (size_t markerIndex = 0; markerIndex < numMarkers; ++markerIndex) {
					// only copy unflagged markers
					if (!(*markers)[chromIndex][markerIndex]->flag) {
						// copy marker values from oldSamples
						const size_t numSamples = oldSamples.size();
						for (size_t sampleIndex = 0; sampleIndex < numSamples; ++sampleIndex) {
							(*samples[sampleIndex])[chromIndex][validMarkersCounts[chromIndex]] = (*oldSamples[sampleIndex])[chromIndex][markerIndex];
						}
						++validMarkersCounts[chromIndex];
					}
				}
			}
			
			// shrink new sample chromosomes to match new size
			SamplesIterator it, end = samples.end();
			for (it = samples.begin(); it != end; ++it) {
				for (size_t chromIndex = 0; chromIndex < chromEnd; ++chromIndex) {
					(**it).resizeChromosome(chromIndex, validMarkersCounts[chromIndex]);
				}
			}
			
			// clear old samples
			end = oldSamples.end();
			for (it = oldSamples.begin(); it != end; ++it) {
				delete (*it);
			}
			
		}
		
		// remove flagged markers
		markers->clean();
		
	}
开发者ID:djhshih,项目名称:genomic,代码行数:68,代码来源:RawSampleSet.hpp


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