Enable readability-container-contains clang-tidy check (#6909)
This commit is contained in:
parent
1a6f4c44e7
commit
9aaab7a53f
@ -82,7 +82,6 @@ Checks: >
|
|||||||
-readability-make-member-function-const,
|
-readability-make-member-function-const,
|
||||||
-readability-redundant-string-init,
|
-readability-redundant-string-init,
|
||||||
-readability-non-const-parameter,
|
-readability-non-const-parameter,
|
||||||
-readability-container-contains,
|
|
||||||
-readability-static-accessed-through-instance
|
-readability-static-accessed-through-instance
|
||||||
|
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: '*'
|
||||||
|
@ -17,18 +17,18 @@ struct TrafficSignals
|
|||||||
|
|
||||||
inline bool HasSignal(NodeID from, NodeID to) const
|
inline bool HasSignal(NodeID from, NodeID to) const
|
||||||
{
|
{
|
||||||
return bidirectional_nodes.count(to) > 0 || unidirectional_segments.count({from, to}) > 0;
|
return bidirectional_nodes.contains(to) || unidirectional_segments.contains({from, to});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Compress(NodeID from, NodeID via, NodeID to)
|
void Compress(NodeID from, NodeID via, NodeID to)
|
||||||
{
|
{
|
||||||
bidirectional_nodes.erase(via);
|
bidirectional_nodes.erase(via);
|
||||||
if (unidirectional_segments.count({via, to}))
|
if (unidirectional_segments.contains({via, to}))
|
||||||
{
|
{
|
||||||
unidirectional_segments.erase({via, to});
|
unidirectional_segments.erase({via, to});
|
||||||
unidirectional_segments.insert({from, to});
|
unidirectional_segments.insert({from, to});
|
||||||
}
|
}
|
||||||
if (unidirectional_segments.count({via, from}))
|
if (unidirectional_segments.contains({via, from}))
|
||||||
{
|
{
|
||||||
unidirectional_segments.erase({via, from});
|
unidirectional_segments.erase({via, from});
|
||||||
unidirectional_segments.insert({to, from});
|
unidirectional_segments.insert({to, from});
|
||||||
|
@ -125,9 +125,9 @@ std::vector<RouteStep> anticipateLaneChange(std::vector<RouteStep> steps,
|
|||||||
|
|
||||||
if (previous_is_straight)
|
if (previous_is_straight)
|
||||||
{
|
{
|
||||||
if (isLeftTurn(current_inst) || is_straight_left.count(¤t) > 0)
|
if (isLeftTurn(current_inst) || is_straight_left.contains(¤t))
|
||||||
is_straight_left.insert(&previous);
|
is_straight_left.insert(&previous);
|
||||||
else if (isRightTurn(current_inst) || is_straight_right.count(¤t) > 0)
|
else if (isRightTurn(current_inst) || is_straight_right.contains(¤t))
|
||||||
is_straight_right.insert(&previous);
|
is_straight_right.insert(&previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,9 +190,9 @@ std::vector<RouteStep> anticipateLaneChange(std::vector<RouteStep> steps,
|
|||||||
//
|
//
|
||||||
// coming from right, going to left (in direction of way) -> handle as left turn
|
// coming from right, going to left (in direction of way) -> handle as left turn
|
||||||
|
|
||||||
if (is_straight_left.count(¤t) > 0)
|
if (is_straight_left.contains(¤t))
|
||||||
anticipate_for_left_turn();
|
anticipate_for_left_turn();
|
||||||
else if (is_straight_right.count(¤t) > 0)
|
else if (is_straight_right.contains(¤t))
|
||||||
anticipate_for_right_turn();
|
anticipate_for_right_turn();
|
||||||
else // FIXME: right-sided driving
|
else // FIXME: right-sided driving
|
||||||
anticipate_for_right_turn();
|
anticipate_for_right_turn();
|
||||||
|
@ -248,7 +248,7 @@ filterViaCandidatesByViaNotOnPath(const WeightedViaNodePackedPath &path, RandIt
|
|||||||
for (const auto &edge : path.path)
|
for (const auto &edge : path.path)
|
||||||
nodes.insert(std::get<1>(edge));
|
nodes.insert(std::get<1>(edge));
|
||||||
|
|
||||||
const auto via_on_path = [&](const auto via) { return nodes.count(via.node) > 0; };
|
const auto via_on_path = [&](const auto via) { return nodes.contains(via.node); };
|
||||||
|
|
||||||
return std::remove_if(first, last, via_on_path);
|
return std::remove_if(first, last, via_on_path);
|
||||||
}
|
}
|
||||||
@ -308,7 +308,7 @@ RandIt filterPackedPathsByCellSharing(RandIt first,
|
|||||||
{
|
{
|
||||||
const auto source_cell = get_cell(std::get<0>(edge));
|
const auto source_cell = get_cell(std::get<0>(edge));
|
||||||
const auto target_cell = get_cell(std::get<1>(edge));
|
const auto target_cell = get_cell(std::get<1>(edge));
|
||||||
return cells.count(source_cell) < 1 && cells.count(target_cell) < 1;
|
return !cells.contains(source_cell) && !cells.contains(target_cell);
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto different = std::count_if(begin(packed.path), end(packed.path), not_seen);
|
const auto different = std::count_if(begin(packed.path), end(packed.path), not_seen);
|
||||||
@ -491,7 +491,7 @@ RandIt filterUnpackedPathsBySharing(RandIt first,
|
|||||||
{
|
{
|
||||||
auto node_duration = facade.GetNodeDuration(node);
|
auto node_duration = facade.GetNodeDuration(node);
|
||||||
total_duration += node_duration;
|
total_duration += node_duration;
|
||||||
if (nodes.count(node) > 0)
|
if (nodes.contains(node))
|
||||||
{
|
{
|
||||||
return duration + node_duration;
|
return duration + node_duration;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
|||||||
EdgeDuration initial_duration,
|
EdgeDuration initial_duration,
|
||||||
EdgeDistance initial_distance)
|
EdgeDistance initial_distance)
|
||||||
{
|
{
|
||||||
if (target_nodes_index.count(node))
|
if (target_nodes_index.contains(node))
|
||||||
{
|
{
|
||||||
// Source and target on the same edge node. If target is not reachable directly via
|
// Source and target on the same edge node. If target is not reachable directly via
|
||||||
// the node (e.g destination is before source on oneway segment) we want to allow
|
// the node (e.g destination is before source on oneway segment) we want to allow
|
||||||
|
@ -49,7 +49,7 @@ std::vector<TurnData> generateTurns(const datafacade &facade,
|
|||||||
{
|
{
|
||||||
// operator[] will construct an empty vector at [edge.u] if there is no value.
|
// operator[] will construct an empty vector at [edge.u] if there is no value.
|
||||||
directed_graph[edge.u].push_back({edge.v, edge.forward_segment_id.id});
|
directed_graph[edge.u].push_back({edge.v, edge.forward_segment_id.id});
|
||||||
if (edge_based_node_info.count(edge.forward_segment_id.id) == 0)
|
if (!edge_based_node_info.contains(edge.forward_segment_id.id))
|
||||||
{
|
{
|
||||||
edge_based_node_info[edge.forward_segment_id.id] = {true, get_geometry_id(edge)};
|
edge_based_node_info[edge.forward_segment_id.id] = {true, get_geometry_id(edge)};
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ std::vector<TurnData> generateTurns(const datafacade &facade,
|
|||||||
if (edge.reverse_segment_id.enabled)
|
if (edge.reverse_segment_id.enabled)
|
||||||
{
|
{
|
||||||
directed_graph[edge.v].push_back({edge.u, edge.reverse_segment_id.id});
|
directed_graph[edge.v].push_back({edge.u, edge.reverse_segment_id.id});
|
||||||
if (edge_based_node_info.count(edge.reverse_segment_id.id) == 0)
|
if (!edge_based_node_info.contains(edge.reverse_segment_id.id))
|
||||||
{
|
{
|
||||||
edge_based_node_info[edge.reverse_segment_id.id] = {false, get_geometry_id(edge)};
|
edge_based_node_info[edge.reverse_segment_id.id] = {false, get_geometry_id(edge)};
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ std::vector<TurnData> generateTurns(const datafacade &facade,
|
|||||||
{
|
{
|
||||||
// If the target of this edge doesn't exist in our directed
|
// If the target of this edge doesn't exist in our directed
|
||||||
// graph, it's probably outside the tile, so we can skip it
|
// graph, it's probably outside the tile, so we can skip it
|
||||||
if (directed_graph.count(approachedge.target_node) == 0)
|
if (!directed_graph.contains(approachedge.target_node))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// For each of the outgoing edges from our target coordinate
|
// For each of the outgoing edges from our target coordinate
|
||||||
|
@ -167,7 +167,7 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
|||||||
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_1]].annotation_id =
|
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_1]].annotation_id =
|
||||||
forward_data.annotation_data;
|
forward_data.annotation_data;
|
||||||
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_1]].segregated =
|
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_1]].segregated =
|
||||||
segregated_edges.count(edge_id_1) > 0;
|
segregated_edges.contains(edge_id_1);
|
||||||
|
|
||||||
if (nbe_to_ebn_mapping[edge_id_2] != SPECIAL_EDGEID)
|
if (nbe_to_ebn_mapping[edge_id_2] != SPECIAL_EDGEID)
|
||||||
{
|
{
|
||||||
@ -176,7 +176,7 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
|||||||
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_2]].annotation_id =
|
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_2]].annotation_id =
|
||||||
reverse_data.annotation_data;
|
reverse_data.annotation_data;
|
||||||
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_2]].segregated =
|
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_2]].segregated =
|
||||||
segregated_edges.count(edge_id_2) > 0;
|
segregated_edges.contains(edge_id_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add segments of edge-based nodes
|
// Add segments of edge-based nodes
|
||||||
@ -382,7 +382,7 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const WayRestrictionMap &way_re
|
|||||||
m_edge_based_node_container.nodes[edge_based_node_id].annotation_id =
|
m_edge_based_node_container.nodes[edge_based_node_id].annotation_id =
|
||||||
edge_data.annotation_data;
|
edge_data.annotation_data;
|
||||||
m_edge_based_node_container.nodes[edge_based_node_id].segregated =
|
m_edge_based_node_container.nodes[edge_based_node_id].segregated =
|
||||||
segregated_edges.count(eid) > 0;
|
segregated_edges.contains(eid);
|
||||||
|
|
||||||
const auto ebn_weight = m_edge_based_node_weights[nbe_to_ebn_mapping[eid]];
|
const auto ebn_weight = m_edge_based_node_weights[nbe_to_ebn_mapping[eid]];
|
||||||
BOOST_ASSERT((ebn_weight & EdgeWeight{0x7fffffff}) == edge_data.weight);
|
BOOST_ASSERT((ebn_weight & EdgeWeight{0x7fffffff}) == edge_data.weight);
|
||||||
@ -942,7 +942,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
|||||||
|
|
||||||
const auto turn_nodes = NodeBasedTurn{
|
const auto turn_nodes = NodeBasedTurn{
|
||||||
incoming_edge.node, intersection_node, outgoing_edge_target};
|
incoming_edge.node, intersection_node, outgoing_edge_target};
|
||||||
const auto is_maneuver_turn = unresolved_turns.count(turn_nodes) > 0;
|
const auto is_maneuver_turn = unresolved_turns.contains(turn_nodes);
|
||||||
|
|
||||||
if (is_maneuver_turn)
|
if (is_maneuver_turn)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if v is an entry/exit via node for a turn restriction
|
// check if v is an entry/exit via node for a turn restriction
|
||||||
if (incompressible_via_nodes.count(node_v) > 0)
|
if (incompressible_via_nodes.contains(node_v))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -622,7 +622,7 @@ IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &gr
|
|||||||
for (const auto &outgoing_edge : outgoing_edges)
|
for (const auto &outgoing_edge : outgoing_edges)
|
||||||
{
|
{
|
||||||
const auto edge_it = findEdge(edge_geometries, outgoing_edge.edge);
|
const auto edge_it = findEdge(edge_geometries, outgoing_edge.edge);
|
||||||
const auto is_merged = merged_edges.count(outgoing_edge.edge) != 0;
|
const auto is_merged = merged_edges.contains(outgoing_edge.edge);
|
||||||
const auto is_turn_allowed = intersection::isTurnAllowed(graph,
|
const auto is_turn_allowed = intersection::isTurnAllowed(graph,
|
||||||
node_data_container,
|
node_data_container,
|
||||||
restriction_map,
|
restriction_map,
|
||||||
|
@ -28,7 +28,7 @@ bool SuffixTable::isSuffix(const std::string &possible_suffix) const
|
|||||||
|
|
||||||
bool SuffixTable::isSuffix(std::string_view possible_suffix) const
|
bool SuffixTable::isSuffix(std::string_view possible_suffix) const
|
||||||
{
|
{
|
||||||
return suffix_set.count(possible_suffix) > 0;
|
return suffix_set.contains(possible_suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace osrm::extractor
|
} // namespace osrm::extractor
|
||||||
|
@ -18,7 +18,7 @@ std::size_t WayRestrictionMap::NumberOfDuplicatedNodes() const
|
|||||||
|
|
||||||
bool WayRestrictionMap::IsViaWayEdge(const NodeID from, const NodeID to) const
|
bool WayRestrictionMap::IsViaWayEdge(const NodeID from, const NodeID to) const
|
||||||
{
|
{
|
||||||
return restriction_graph.via_edge_to_node.count({from, to}) > 0;
|
return restriction_graph.via_edge_to_node.contains({from, to});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<DuplicatedNodeID> WayRestrictionMap::DuplicatedNodeIDs(const NodeID from,
|
std::vector<DuplicatedNodeID> WayRestrictionMap::DuplicatedNodeIDs(const NodeID from,
|
||||||
|
@ -302,7 +302,7 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
|
|||||||
if (roundabout == circular)
|
if (roundabout == circular)
|
||||||
return RoundaboutType::None;
|
return RoundaboutType::None;
|
||||||
|
|
||||||
while (0 == roundabout_nodes.count(last_node))
|
while (!roundabout_nodes.contains(last_node))
|
||||||
{
|
{
|
||||||
// only count exits/entry locations
|
// only count exits/entry locations
|
||||||
if (node_based_graph.GetOutDegree(last_node) > 2)
|
if (node_based_graph.GetOutDegree(last_node) > 2)
|
||||||
@ -346,7 +346,7 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
|
|||||||
// when we handle references separately or if the useage is more consistent
|
// when we handle references separately or if the useage is more consistent
|
||||||
const auto is_rotary = (1 == roundabout_name_ids.size()) &&
|
const auto is_rotary = (1 == roundabout_name_ids.size()) &&
|
||||||
(circular || //
|
(circular || //
|
||||||
((0 == connected_names.count(*roundabout_name_ids.begin())) && //
|
((!connected_names.contains(*roundabout_name_ids.begin())) && //
|
||||||
(radius > MAX_ROUNDABOUT_RADIUS)));
|
(radius > MAX_ROUNDABOUT_RADIUS)));
|
||||||
|
|
||||||
if (is_rotary)
|
if (is_rotary)
|
||||||
|
@ -508,7 +508,7 @@ bool TurnLaneHandler::isSimpleIntersection(const LaneDataVector &lane_data,
|
|||||||
}();
|
}();
|
||||||
BOOST_ASSERT(best_match != intersection.end());
|
BOOST_ASSERT(best_match != intersection.end());
|
||||||
std::size_t match_index = std::distance(intersection.begin(), best_match);
|
std::size_t match_index = std::distance(intersection.begin(), best_match);
|
||||||
all_simple &= (matched_indices.count(match_index) == 0);
|
all_simple &= (!matched_indices.contains(match_index));
|
||||||
matched_indices.insert(match_index);
|
matched_indices.insert(match_index);
|
||||||
// in case of u-turns, we might need to activate them first
|
// in case of u-turns, we might need to activate them first
|
||||||
all_simple &= (best_match->entry_allowed ||
|
all_simple &= (best_match->entry_allowed ||
|
||||||
|
@ -22,7 +22,7 @@ auto makeHasNeighborNotInCheck(const DinicMaxFlow::SourceSinkNodes &set,
|
|||||||
return [&](const NodeID nid)
|
return [&](const NodeID nid)
|
||||||
{
|
{
|
||||||
const auto is_not_contained = [&set](const BisectionEdge &edge)
|
const auto is_not_contained = [&set](const BisectionEdge &edge)
|
||||||
{ return set.count(edge.target) == 0; };
|
{ return !set.contains(edge.target); };
|
||||||
return view.EndEdges(nid) !=
|
return view.EndEdges(nid) !=
|
||||||
std::find_if(view.BeginEdges(nid), view.EndEdges(nid), is_not_contained);
|
std::find_if(view.BeginEdges(nid), view.EndEdges(nid), is_not_contained);
|
||||||
};
|
};
|
||||||
@ -128,7 +128,7 @@ DinicMaxFlow::ComputeLevelGraph(const BisectionGraphView &view,
|
|||||||
levels[node_id] = 0;
|
levels[node_id] = 0;
|
||||||
level_queue.push(node_id);
|
level_queue.push(node_id);
|
||||||
for (const auto &edge : view.Edges(node_id))
|
for (const auto &edge : view.Edges(node_id))
|
||||||
if (source_nodes.count(edge.target))
|
if (source_nodes.contains(edge.target))
|
||||||
levels[edge.target] = 0;
|
levels[edge.target] = 0;
|
||||||
}
|
}
|
||||||
// check if there is flow present on an edge
|
// check if there is flow present on an edge
|
||||||
@ -139,7 +139,7 @@ DinicMaxFlow::ComputeLevelGraph(const BisectionGraphView &view,
|
|||||||
const auto relax_node = [&](const NodeID node_id)
|
const auto relax_node = [&](const NodeID node_id)
|
||||||
{
|
{
|
||||||
// don't relax sink nodes
|
// don't relax sink nodes
|
||||||
if (sink_nodes.count(node_id))
|
if (sink_nodes.contains(node_id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto level = levels[node_id] + 1;
|
const auto level = levels[node_id] + 1;
|
||||||
@ -264,7 +264,7 @@ std::vector<NodeID> DinicMaxFlow::GetAugmentingPath(LevelGraph &levels,
|
|||||||
dfs_stack.top().edge_iterator++;
|
dfs_stack.top().edge_iterator++;
|
||||||
|
|
||||||
// check if the edge is valid
|
// check if the edge is valid
|
||||||
const auto has_capacity = flow[target].count(path.back()) == 0;
|
const auto has_capacity = !flow[target].contains(path.back());
|
||||||
const auto descends_level_graph = levels[target] + 1 == levels[path.back()];
|
const auto descends_level_graph = levels[target] + 1 == levels[path.back()];
|
||||||
|
|
||||||
if (has_capacity && descends_level_graph)
|
if (has_capacity && descends_level_graph)
|
||||||
@ -300,8 +300,9 @@ bool DinicMaxFlow::Validate(const BisectionGraphView &view,
|
|||||||
// sink and source cannot share a common node
|
// sink and source cannot share a common node
|
||||||
const auto separated = std::find_if(source_nodes.begin(),
|
const auto separated = std::find_if(source_nodes.begin(),
|
||||||
source_nodes.end(),
|
source_nodes.end(),
|
||||||
[&sink_nodes](const auto node)
|
[&sink_nodes](const auto node) {
|
||||||
{ return sink_nodes.count(node); }) == source_nodes.end();
|
return sink_nodes.contains(node);
|
||||||
|
}) == source_nodes.end();
|
||||||
|
|
||||||
const auto invalid_id = [&view](const NodeID nid) { return nid >= view.NumberOfNodes(); };
|
const auto invalid_id = [&view](const NodeID nid) { return nid >= view.NumberOfNodes(); };
|
||||||
const auto in_range_source =
|
const auto in_range_source =
|
||||||
|
Loading…
Reference in New Issue
Block a user