| Home | Libraries | People | FAQ | More

#### boost::geometry::index::rtree

The R-tree spatial index.

###### Description

This is self-balancing spatial index capable to store various types of Values and balancing algorithms.

###### Parameters

The user must pass a type defining the Parameters which will be used in rtree creation process. This type is used e.g. to specify balancing algorithm with specific parameters like min and max number of elements in node.

Predefined algorithms with compile-time parameters are:

- `boost::geometry::index::linear`,
- `boost::geometry::index::quadratic`,
- `boost::geometry::index::rstar`.

Predefined algorithms with run-time parameters are:

- `boost::geometry::index::dynamic_linear`,
- `boost::geometry::index::dynamic_quadratic`,
- `boost::geometry::index::dynamic_rstar`.

###### IndexableGetter

The object of IndexableGetter type translates from Value to Indexable each time r-tree requires it. This means that this operation is done for each Value access. Therefore the IndexableGetter should return the Indexable by a reference type. The Indexable should not be calculated since it could harm the performance. The default IndexableGetter can translate all types adapted to Point, Box or Segment concepts (called Indexables). Furthermore, it can handle ``std::pair<Indexable, T>``, ``std::tuple<Indexable, ...>`` and ``boost::tuple<Indexable, ...>``. For example, for Value of type ``std::pair<Box, int>``, the default IndexableGetter translates from ``std::pair<Box, int> const&`` to ``Box const&``.

###### EqualTo

The object of EqualTo type compares Values and returns ``true`` if they are equal. It's similar to ``std::equal_to<>``. The default EqualTo returns the result of ``boost::geometry::equals()`` for types adapted to some Geometry concept defined in Boost.Geometry and the result of ``operator==`` for other types. Components of Pairs and Tuples are compared left-to-right.

###### Header

`#include <boost/geometry/index/rtree.hpp>`

###### Synopsis

    template<typename Value,
             typename Parameters,
             typename IndexableGetter = index::indexable<Value>,
             typename EqualTo = index::equal_to<Value>,
             typename Allocator = boost::container::new_allocator<Value>>
    class rtree
    {
      // ...
    };

###### Template parameter(s)

Parameter | Description
--- | ---
`Value` | The type of objects stored in the container.
`Parameters` | Compile-time parameters.
`IndexableGetter` | The function object extracting Indexable from Value.
`EqualTo` | The function object comparing objects of type Value.
`Allocator` | The allocator used to allocate/deallocate memory, construct/destroy nodes and Values.

###### Typedef(s)

Type | Description
--- | ---
`value_type` | The type of Value stored in the container.
`parameters_type` | R-tree parameters type.
`indexable_getter` | The function object extracting Indexable from Value.
`value_equal` | The function object comparing objects of type Value.
`allocator_type` | The type of allocator used by the container.
`indexable_type` | The Indexable type to which Value is translated.
`bounds_type` | The Box type used by the R-tree.
`reference` | Type of reference to Value.
`const_reference` | Type of reference to const Value.
`pointer` | Type of pointer to Value.
`const_pointer` | Type of pointer to const Value.
`difference_type` | Type of difference type.
`size_type` | Unsigned integral type used by the container.
`const_iterator` | Type of const iterator, category ForwardIterator.
`const_query_iterator` | Type of const query iterator, category ForwardIterator.

###### Constructor(s) and destructor

Function | Description
--- | ---
`rtree()` | The constructor.
`rtree(parameters_type const &, indexable_getter const &, value_equal const &, allocator_type const &)` | The constructor.
`rtree(Iterator, Iterator)` | The constructor.
`rtree(Range const &)` | The constructor.
`rtree(Iterator, Iterator, parameters_type const &, indexable_getter const &, value_equal const &, allocator_type const &, PackAlloc const &)` | The constructor.
`rtree(Range const &, parameters_type const &, indexable_getter const &, value_equal const &, allocator_type const &, PackAlloc const &)` | The constructor.
`rtree(Iterator, Iterator, allocator_type const &)` | The constructor.
`rtree(Range const &, allocator_type const &)` | The constructor.
`rtree(Iterator, Iterator, allocator_type const &, PackAlloc const &)` | The constructor.
`rtree(Range const &, allocator_type const &, PackAlloc const &)` | The constructor.
`~rtree()` | The destructor.
`rtree(rtree const &)` | The copy constructor.
`rtree(rtree const &, allocator_type const &)` | The copy constructor.
`rtree(rtree &&)` | The moving constructor.
`rtree(rtree &&, allocator_type const &)` | The moving constructor.

###### Member(s)

Modifier | Function | Description
--- | --- | ---
| `operator=(rtree const &)` | The assignment operator.
| `operator=(rtree &&)` | The moving assignment.
| `swap(rtree &)` | Swaps contents of two rtrees.
| `insert(value_type const &)` | Insert a value to the index.
| `insert(Iterator, Iterator)` | Insert a range of values to the index.
| `insert(ConvertibleOrRange const &)` | Insert a value created using convertible object or a range of values to the index.
| `remove(value_type const &)` | Remove a value from the container.
| `remove(Iterator, Iterator)` | Remove a range of values from the container.
| `remove(ConvertibleOrRange const &)` | Remove value corresponding to an object convertible to it or a range of values from the container.
`const` | `query(Predicates const &, OutIter)` | Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box.
`const` | `qbegin(Predicates const &)` | Returns a query iterator pointing at the begin of the query range.
`const` | `qend()` | Returns a query iterator pointing at the end of the query range.
`const` | `begin()` | Returns the iterator pointing at the begin of the rtree values range.
`const` | `end()` | Returns the iterator pointing at the end of the rtree values range.
`const` | `size()` | Returns the number of stored values.
`const` | `empty()` | Query if the container is empty.
| `clear()` | Removes all values stored in the container.
`const` | `bounds()` | Returns the box able to contain all values stored in the container.
`const` | `count(ValueOrIndexable const &)` | Count Values or Indexables stored in the container.
`const` | `parameters()` | Returns parameters.
`const` | `indexable_get()` | Returns function retrieving Indexable from Value.
`const` | `value_eq()` | Returns function comparing Values.
`const` | `get_allocator()` | Returns allocator used by the rtree.