Skip to content

Commit c54ad02

Browse files
committed
Add Collections and Arrays stub classes
1 parent b620296 commit c54ad02

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/Processing.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,23 @@ class NumberWrapperBase {
23062306
String toString() const { return String(::std::to_string(v)); }
23072307
};
23082308

2309+
// Java Collections and Arrays -- minimal stubs
2310+
class Collections {
2311+
public:
2312+
template<class T> static void sort(::std::vector<T>& v) { ::std::sort(v.begin(),v.end()); }
2313+
template<class T> static void reverse(::std::vector<T>& v) { ::std::reverse(v.begin(),v.end()); }
2314+
template<class T> static void shuffle(::std::vector<T>& v) { ::std::shuffle(v.begin(),v.end(),::std::default_random_engine(rand())); }
2315+
template<class T> static T min(const ::std::vector<T>& v) { return *::std::min_element(v.begin(),v.end()); }
2316+
template<class T> static T max(const ::std::vector<T>& v) { return *::std::max_element(v.begin(),v.end()); }
2317+
};
2318+
class Arrays {
2319+
public:
2320+
template<class T> static void sort(::std::vector<T>& v) { ::std::sort(v.begin(),v.end()); }
2321+
template<class T> static ::std::string toString(const ::std::vector<T>& v) {
2322+
::std::string s="["; for(int i=0;i<(int)v.size();i++){if(i)s+=", ";s+=::std::to_string(v[i]);} return s+"]";
2323+
}
2324+
};
2325+
23092326
// Java System class -- minimal stub for sketches that use System.currentTimeMillis() etc.
23102327
class System {
23112328
public:

0 commit comments

Comments
 (0)