Open zhuoqiang opened 1 year ago
in stl, there are both checked and unchecked method to access the value from container
vector[0]; // unchecked, may UB vector.at(1); // checked, may throw map["key1"]; // auto add missing key map.at("key2"); // checked, may throw
graph as a container, however, does not provide a checked method to access the vertex/edge property using vertex/edge id
graph[vertex_id]; // unchecked, may UB graph[edge_id]; // unchecked, may UB
How about providing a checked access method that throw exception in case of missing id. Also helps to keep the API consist with STL containers
graph.at(vertex_id); // unchecked, may throw graph.at(edge_id); // unchecked, may throw
and in general, not sure if I missed it but could not find API to check if the id is valid or not:
graph.contains(vertex_id); // not sure if it exists
in stl, there are both checked and unchecked method to access the value from container
graph as a container, however, does not provide a checked method to access the vertex/edge property using vertex/edge id
How about providing a checked access method that throw exception in case of missing id. Also helps to keep the API consist with STL containers
and in general, not sure if I missed it but could not find API to check if the id is valid or not: