1
0
Эх сурвалжийг харах

adjacency_matrix: ::empty function

Michele Caini 2 жил өмнө
parent
commit
c1b7229238

+ 13 - 0
src/entt/graph/adjacency_matrix.hpp

@@ -217,6 +217,19 @@ public:
         swap(vert, other.vert);
     }
 
+    /**
+     * @brief Returns true if an adjacency matrix is empty, false otherwise.
+     *
+     * @warning
+     * Potentially expensive, try to avoid it on hot paths.
+     *
+     * @return True if the adjacency matrix is empty, false otherwise.
+     */
+    [[nodiscard]] bool empty() const noexcept {
+        const auto iterable = edges();
+        return (iterable.begin() == iterable.end());
+    }
+
     /**
      * @brief Returns the number of vertices.
      * @return The number of vertices.