Example #1
0
SegmentStorage::iterator SegmentStorage::includes(const Segment& s) const {
    iterator result(end);
    if (s.first() != s.second()) {
        auto set_it = storage_.find(s.angle());
        if (set_it != storage_.end()) {
            auto it = set_it->second.lower_bound(s);
            for (; it != set_it->second.end(); ++it) {
                if (it->includes(s)) {
                    result = it;
                    break;
                }
            }
        }
    } else { // If segment is degenerate we need to iterate all structure in any way
        for (auto const& set : storage_) {
            auto it = std::find_if(set.second.begin(), set.second.end(), [&s] (const Segment& segment) {
                return segment.includes(s.first());
            });
            if (it != set.second.end()) {
                result = it;
                break;
            }
        }
    }
    return result;
}
Example #2
0
bool SegmentStorage::erase(const Segment& s) {
    bool result = false;
    auto it = storage_.find(s.angle());
    if (it != storage_.end()) {
        result = (0 != it->second.erase(s));
    }
    return result;
}
Example #3
0
SegmentStorage::iterator SegmentStorage::find(const Segment& s) const {
    iterator result(end);
    auto set_it = storage_.find(s.angle());
    if (set_it != storage_.end()) {
        auto it = set_it->second.find(s);
        if (it != set_it->second.end()) {
            result = it;
        }
    }
    return result;
}
Example #4
0
bool SegmentStorage::insert(const Segment& s) {
    segment_set& set = storage_[s.angle()];
    auto pit = set.insert(s);
    return pit.second;
}