@@ -3709,6 +3709,18 @@ inline color blendColor(color c1, color c2, int mode) {
37093709 }
37103710 return c2; // fallback
37113711}
3712+ // Array utility functions matching Processing Java
3713+ template <class T > inline ::std::vector<T> append (::std::vector<T> arr, T val) { arr.push_back (val); return arr; }
3714+ template <class T > inline ::std::vector<T> expand (::std::vector<T> arr) { arr.resize (arr.size ()*2 ); return arr; }
3715+ template <class T > inline ::std::vector<T> expand (::std::vector<T> arr, int n) { arr.resize (n); return arr; }
3716+ template <class T > inline ::std::vector<T> shorten (::std::vector<T> arr) { if (!arr.empty ()) arr.pop_back (); return arr; }
3717+ template <class T > inline ::std::vector<T> subset (const ::std::vector<T>& arr, int start) { return ::std::vector<T>(arr.begin ()+start,arr.end ()); }
3718+ template <class T > inline ::std::vector<T> subset (const ::std::vector<T>& arr, int start, int count) { return ::std::vector<T>(arr.begin ()+start,arr.begin ()+start+count); }
3719+ template <class T > inline ::std::vector<T> concat (::std::vector<T> a, const ::std::vector<T>& b) { a.insert (a.end (),b.begin (),b.end ()); return a; }
3720+ template <class T > inline ::std::vector<T> reverse (::std::vector<T> arr) { ::std::reverse (arr.begin (),arr.end ()); return arr; }
3721+ template <class T > inline ::std::vector<T> sort (::std::vector<T> arr) { ::std::sort (arr.begin (),arr.end ()); return arr; }
3722+ template <class T > inline ::std::vector<T> sort (::std::vector<T> arr, int count) { ::std::sort (arr.begin (),arr.begin ()+::std::min ((int )arr.size (),count)); return arr; }
3723+
37123724
37133725// image() -- mixed types, value and pointer variants
37143726// image() -- draw a PImage to screen
0 commit comments