Beispiel #1
0
static void makeWeightedOne(float wA,
							std::vector<VisibilityVector::node_benefits_pair_t>::const_iterator & a,
							std::vector<VisibilityVector::node_benefits_pair_t>::const_iterator & aEnd,
							container_t & result) {
	// Add the elements of the single map.
	while(a != aEnd) {
		const VisibilityVector::benefits_t weightedBenefits = (wA * a->second);
		if(weightedBenefits > 0) {
			result.emplace_back(a->first, weightedBenefits);
		}
		++a;
	}
}
Beispiel #2
0
static void makeWeightedTwo(float wA,
							std::vector<VisibilityVector::node_benefits_pair_t>::const_iterator & a,
							std::vector<VisibilityVector::node_benefits_pair_t>::const_iterator & aEnd,
							float wB,
							std::vector<VisibilityVector::node_benefits_pair_t>::const_iterator & b,
							std::vector<VisibilityVector::node_benefits_pair_t>::const_iterator & bEnd,
							container_t & result) {
	// Compare elements of the two maps.
	while(a != aEnd && b != bEnd) {
		if(a->first < b->first) {           // Object is only in map of vvA.
			const VisibilityVector::benefits_t weightedBenefits = (wA * a->second);
			if(weightedBenefits > 0) {
				result.emplace_back(a->first, weightedBenefits);
			}
			++a;
		} else if(b->first < a->first) {    // Object is only in map of vvB.
			const VisibilityVector::benefits_t weightedBenefits = (wB * b->second);
			if(weightedBenefits > 0) {
				result.emplace_back(b->first, weightedBenefits);
			}
			++b;
		} else {                            // Object is in both maps.
			const VisibilityVector::benefits_t weightedBenefits = (wA * a->second + wB * b->second);
			if(weightedBenefits > 0) {
				result.emplace_back(a->first, weightedBenefits);
			}
			++a;
			++b;
		}
	}
	if(a == aEnd) {
		makeWeightedOne(wB, b, bEnd, result);
	} else {
		makeWeightedOne(wA, a, aEnd, result);
	}
}