Relational Operators
These are non-member functions.
Method |
---|
Multimap |
Compares the values in the multimap |
template <class K, size_t M, class T, class C, class A> bool operator==(const spatial_map<K, M, T, C, A> &lhs, const spatial_map<K, M, T, C, A> &rhs); |
template <class K, size_t M, class T, class C, class A> bool operator!=(const spatial_map<K, M, T, C, A> &lhs, const spatial_map<K, M, T, C, A> &rhs); |
Parameters
lhs
,rhs
-spatial_map
s whose contents to compare
Return value
true
if the internal contents of the spatial_map
s are equal, false otherwise.
Complexity
Notes
Warning
This operator tells us if the internal trees are equal and not if they contain the same elements. This is because the standard defines that this operation should take \(O(n)\) time. Two trees might contain the same elements in different subtrees if their insertion order was different.
If you need to compare if the elements of lhs
and rhs
are the same, regardless of their internal representation, you have to iterate lhs
and iteratively call find
on the second container. This operation takes \(O(m n \log n)\) time.
We do not include operator<
, operator>
, operator<=
, operator>=
for spatial containers because std::lexicographical_compare would be semantically meaningless in a multidimensional context where we need to return a value in \(O(n)\) time and, by definition, there is no priority between key dimensions.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
1 2 |
|