16 #include <type_traits> 33 template <
typename InputTypeT>
35 :
_vec([](auto &&input) {
36 static_assert(!std::is_const<InputTypeT>::value,
"Input type cannot be const");
37 std::sort(std::begin(input), std::end(input), LessComp());
38 return decltype(
_vec){
39 std::make_move_iterator(std::begin(input)),
40 std::make_move_iterator(std::end(input))};
41 }(std::move(range))) {}
44 const std::vector<mapped_type> &
GetAll()
const {
52 std::make_reverse_iterator(std::upper_bound(
_vec.begin(),
_vec.end(), k, LessComp())),
58 auto low_bound = (std::lower_bound(
_vec.begin(),
_vec.end(), min_k, LessComp()));
59 auto up_bound = (std::upper_bound(
_vec.begin(),
_vec.end(), max_k, LessComp()));
64 auto low_bound = (std::lower_bound(
_vec.begin(),
_vec.end(), min_k, LessComp()));
65 auto up_bound = (std::upper_bound(low_bound,
_vec.end(), max_k, LessComp()));
66 return MakeListView(std::make_reverse_iterator(up_bound), std::make_reverse_iterator(low_bound));
91 template <
typename ValueT>
93 return value.GetDistance();
96 template <
typename ValueT>
98 return value->GetDistance();
101 template <
typename ValueT>
103 return value->GetDistance();
108 template <
typename LhsT,
typename RhsT>
111 const RhsT &b)
const {
bool operator()(const LhsT &a, const RhsT &b) const
static key_type GetDistance(const std::unique_ptr< ValueT > &value)
auto GetSubsetInRange(const key_type min_k, const key_type max_k) const
Return a list of elements that have a key value in the range [min_k, max_k].
This file contains definitions of common data structures used in traffic manager. ...
RoadElementSet(std::vector< InputTypeT > &&range)
Explicit move constructor.
std::unique_ptr< carla::road::element::RoadInfo > mapped_type
const std::vector< mapped_type > & GetAll() const
Return all values from the set.
A set of elements ordered by its position on the road.
Inherit (privately) to suppress copy construction and assignment.
std::vector< mapped_type > _vec
auto GetReverseSubset(const key_type k) const
Return a reversed list of elements that have key value GetDistance() <= s.
auto GetReverseSubsetInRange(const key_type min_k, const key_type max_k) const
static key_type GetDistance(const ValueT &value)
static key_type GetDistance(const ValueT *value)
static auto MakeListView(Iterator begin, Iterator end)
void sort(I begin, I end, const Pred &pred)
static key_type GetDistance(const key_type key)