Lookup and Queries
Method |
---|
Multimap |
Returns the number of elements matching specific key |
size_type count(const key_type &p) const; |
template <class L> size_type count(const L &p) const |
Finds element with specific key |
iterator find(const key_type &p); |
const_iterator find(const key_type &p) const; |
template <class L> iterator find(const L &p) |
template <class L> const_iterator find(const L &p) const; |
Checks if the container contains element with specific key |
bool contains(const key_type &p) const; |
template <class L> bool contains(const L &p) const; |
SpatialContainer |
Get iterator to first element that passes the predicates |
const_iterator find(const predicate_list_type &ps) const noexcept; |
iterator find(const predicate_list_type &ps) noexcept; |
Find intersection between point and container |
iterator find_intersection(const key_type &p); |
const_iterator find_intersection(const key_type &p) const; |
Find intersection between container and query box |
iterator find_intersection(const key_type &lb, const key_type &ub); |
const_iterator find_intersection(const key_type &lb, const key_type &ub) const; |
Find points inside a query box (excluding borders) |
iterator find_within(const key_type &lb, const key_type &ub); |
const_iterator find_within(const key_type &lb, const key_type &ub) const |
Find points outside a query box |
iterator find_disjoint(const key_type &lb, const key_type &ub); |
const_iterator find_disjoint(const key_type &lb, const key_type &ub) const; |
Find the elements closest to a point |
iterator find_nearest(const key_type &p); |
const_iterator find_nearest(const key_type &p) const; |
iterator find_nearest(const key_type &p, size_t k); |
const_iterator find_nearest(const key_type &p, size_t k) const; |
iterator find_nearest(const box_type &b, size_t k); |
const_iterator find_nearest(const box_type &b, size_t k) const; |
Find min/max elements |
iterator max_element(size_t dimension) |
const_iterator max_element(size_t dimension) const |
iterator min_element(size_t dimension) |
const_iterator min_element(size_t dimension) const |
Parameters
ps
- a list of predicatesp
- a point of typekey_value
or convertible tokey_value
lb
andub
- lower and upper bounds of the query boxk
- number of nearest elements
Return value
count()
:size_type
: number of elements with a given keycontainer()
:bool
:true
if and only if the container contains an element with the given keyp
find_*
:iterator
andconst_iterator
- Iterator to the first element that passes the query predicatesfind
returns a normal iterator- all other
find_*
functions return a query iterator (see below) size_type
- Number of elements erased
Complexity
Notes
Query iterators might store a list of predicates that limit iterators to query results. A query iterator skips all elements that do not match its predicates.
There are five types of predicates:
Predicate type | Description |
---|---|
intersects |
return only elements that intersect a given query box. |
within |
return only elements within a given query box. This is the same as intersects but it excludes the borders. |
disjoint |
return only elements that do not intersect a given query box. |
nearest |
return only the \(k\) nearest elements to a reference point or query box. |
satisfies |
return only elements that pass a predicate provided by the user. |
Predicate lists
Query iterators contain an element of type pareto::predicate_list
.
When a predicate_list
is being constructed, it will:
1) compress to predicates to eliminate any redundancy in the search requirements, and
2) sort the predicates by how restrictive they are so that the search for the next element is as efficient as possible.
Comparing Iterators
Although a normal iterator and a query iterator that point to the same element compare equal, this does not mean their operator++
will return the same element. The past-the-end element of all query iterators is also the end()
iterator.
Lower and Upper bounds
Because of how spatial container work, we do not guarantee equivalent elements are necessarily stored in sequence. Thus, unlike std::multimap
there are no equal_range
, lower_bound
and upper_bound
functions. The same behaviour must be achieved with the find_intersection
function.
Examples
Continuing from the previous example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|