[llvm] [PBQP] Add begin and end to Vector (NFC) (PR #136454)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 19 13:29:37 PDT 2025
================
@@ -48,12 +48,18 @@ class Vector {
V.Length = 0;
}
+ // Iterator-based access.
+ const PBQPNum *begin() const { return Data.get(); }
+ const PBQPNum *end() const { return Data.get() + Length; }
+ PBQPNum *begin() { return Data.get(); }
+ PBQPNum *end() { return Data.get() + Length; }
+
/// Comparison operator.
bool operator==(const Vector &V) const {
assert(Length != 0 && Data && "Invalid vector");
if (Length != V.Length)
return false;
- return std::equal(Data.get(), Data.get() + Length, V.Data.get());
+ return std::equal(begin(), end(), V.begin());
----------------
kazutakahirata wrote:
Yes, the variant of `std::equal` that takes four arguments is exposed via `llvm::equal`. That variant compares the size with `std::distance`, so I should be able to remove the `Length` comparison above. Thanks!
https://github.com/llvm/llvm-project/pull/136454
More information about the llvm-commits
mailing list