IvanPinezhaninov/IntervalTree

Doesn't work with const ValueType

Hideman85 opened this issue · 1 comments

    // Create an interval tree
    // Intervals::IntervalTree<int, int> intervalTree; // Work fine
    Intervals::IntervalTree<int, const int> intervalTree; /* Doesn't work
    error: use of deleted function ‘Intervals::Interval<int, const int>& Intervals::Interval<int, const int>::operator=(Intervals::Interval<int, const int>&&)’
           *__position = std::forward<_Arg>(__arg);

    error: use of deleted function ‘Intervals::Interval<int, const int>& Intervals::Interval<int, const int>::operator=(Intervals::Interval<int, const int>&&)’
          *--__result = std::move(*--__last);
    */

    // Insert intervals to the tree
    intervalTree.insert({ 20, 30, 1 });
    intervalTree.insert({ 40, 60, 2 });
    intervalTree.insert({ 70, 90, 3 });
    intervalTree.insert({ 60, 70, 4 });
    intervalTree.insert({ 40, 90, 5 });
    intervalTree.insert({ 80, 90, 6 });

    // Find intervals
    auto overlappingIntervals = intervalTree.findOverlappingIntervals({ 50, 80 });
    auto innerIntervals = intervalTree.findInnerIntervals({ 50, 80 });
    auto outerIntervals = intervalTree.findOuterIntervals({ 50, 80 });
    auto intervalsContainPoint = intervalTree.findIntervalsContainPoint(50);

    // Print all intervals
    std::cout << "All intervals:" << std::endl;
    for (auto interval : intervalTree.intervals()) {
        std::cout << interval << std::endl;
    }
    std::cout << std::endl;

    // Print overlapping intervals
    std::cout << "Overlapping intervals:" << std::endl;
    for (auto interval : overlappingIntervals) {
        std::cout << interval << std::endl;
    }
    std::cout << std::endl;

    // Print inner intervals
    std::cout << "Inner intervals:" << std::endl;
    for (auto interval : innerIntervals) {
        std::cout << interval << std::endl;
    }
    std::cout << std::endl;

    // Print outer intervals
    std::cout << "Outer intervals:" << std::endl;
    for (auto interval : outerIntervals) {
        std::cout << interval << std::endl;
    }
    std::cout << std::endl;

    // Print intervals contain the point
    std::cout << "Intervals contain the point:" << std::endl;
    for (auto interval : intervalsContainPoint) {
        std::cout << interval << std::endl;
    }

Yes this is a bug. Thank you! Please give me a couple of days for fixing it. The solution is trivial and won't take to long.