From 5b886a23fd98eee96a8b9642a710e45a70084ddd Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 15 Sep 2021 21:34:16 -0700 Subject: [PATCH] [wpiutil] jni_util: Add size, operator[] to JArrayRef (#3569) These make it usable more like a standard container. --- wpiutil/src/main/native/include/wpi/jni_util.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wpiutil/src/main/native/include/wpi/jni_util.h b/wpiutil/src/main/native/include/wpi/jni_util.h index 557cfa2652..edee80fcb9 100644 --- a/wpiutil/src/main/native/include/wpi/jni_util.h +++ b/wpiutil/src/main/native/include/wpi/jni_util.h @@ -194,6 +194,10 @@ class JArrayRefBase : public JArrayRefInner, T> { return {this->m_elements, this->m_size}; } + size_t size() const { return this->m_size; } + T& operator[](size_t i) { return this->m_elements[i]; } + const T& operator[](size_t i) const { return this->m_elements[i]; } + JArrayRefBase(const JArrayRefBase&) = delete; JArrayRefBase& operator=(const JArrayRefBase&) = delete;