multindex comparison on two int keys

I have a boost multiindex container which has an object which is contains this struct, with a composite key on both _start and _end.

1
2
3
4
5
6
struct ObjUtil
{
    Obj*    _obj;
    int     _start;
    int     _end;
};


Can I search this for all objects where X2 >= _start
and _end >= X1. Obviously specifying X1 and X2


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
struct ObjectUtil
{
    Object*    _obj;
    int             _start;
    int             _end;

    ObjectUtil(Object*    obj_,
                    int             start_,
                    int             end_ )
    {
        this->_obj      = obj_;
        this->_start            = start_;
        this->_end              = end_;
    }
};

namespace obj_tags
{
struct tag_obj{};
struct tag_start{};
struct tag_end{};
struct tag_both_index{};
}

using sort_objects = boost::multi_index_container<
      ObjectUtil,
      boost::multi_index::indexed_by<
        boost::multi_index::ordered_unique<
            boost::multi_index::tag<obj_tags::tag_obj>,
            boost::multi_index::member<ObjectUtil, Object*, &ObjectUtil::_obj>,
            std::less<Object*>
        >,
        boost::multi_index::ordered_non_unique<
            boost::multi_index::tag<obj_tags::tag_start>,
            boost::multi_index::member<ObjectUtil, int, &ObjectUtil::_start>,
            std::less<int>
        >,
        boost::multi_index::ordered_non_unique<
            boost::multi_index::tag<obj_tags::tag_end>,
            boost::multi_index::member<ObjectUtil, int, &ObjectUtil ::_end>,
            std::less<int>
        >,
        boost::multi_index::ordered_non_unique<
            boost::multi_index::tag<obj_tags::tag_both_index>,
            boost::multi_index::composite_key<ObjectUtil,
                boost::multi_index::member<ObjectUtil, int, &ObjectUtil::_start>,
                boost::multi_index::member<ObjectUtil, int, &ObjectUtil::_end>
            >
        >
      >
    >;


Last edited on
looking it seems like <boost/icl/interval_map.hpp> might be what i need,
Topic archived. No new replies allowed.