summaryrefslogtreecommitdiff
path: root/core/cowdata.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/cowdata.h')
-rw-r--r--core/cowdata.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/cowdata.h b/core/cowdata.h
index 319e61d261..3e40ad0f4b 100644
--- a/core/cowdata.h
+++ b/core/cowdata.h
@@ -179,6 +179,8 @@ public:
return OK;
};
+ int find(const T &p_val, int p_from = 0) const;
+
_FORCE_INLINE_ CowData();
_FORCE_INLINE_ ~CowData();
_FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); };
@@ -316,6 +318,24 @@ Error CowData<T>::resize(int p_size) {
}
template <class T>
+int CowData<T>::find(const T &p_val, int p_from) const {
+ int ret = -1;
+
+ if (p_from < 0 || size() == 0) {
+ return ret;
+ }
+
+ for (int i = p_from; i < size(); i++) {
+ if (get(i) == p_val) {
+ ret = i;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+template <class T>
void CowData<T>::_ref(const CowData *p_from) {
_ref(*p_from);
}