The std::vector wrappers have been changed to work by default for elements that are
not default insertable, i.e. have no default constructor. This has been achieved by
not wrapping:
vector(size_type n);
Previously the above had to be ignored via %ignore.
If the above constructor is still required it can be added back in again via %extend:
%extend std::vector {
vector(size_type count) { return new std::vector< T >(count); }
}
Alternatively, the following wrapped constructor could be used as it provides near-enough
equivalent functionality:
vector(jint count, const value_type& value);
The equivalent change to std::list has also been made (std::list
wrappers were not in the previous release [3.0.12] though).
- Add missing vector copy constructor
- Add constructor to initialize the containers. Note that Java's
equivalent constructor for ArrayList just sets the capacity, whereas
the wrappers behave like the C++ constructor and set the size. I've
done this mainly because there has been a vector(size_type) constructor
in the Java wrappers for many years, so best to keep this unchanged.
Derive the class wrapping std::vector<> in Java from java.util.AbstractList<>.
This makes it possible to use it with various algorithms working with Java
collections and, maybe even more importantly, makes it possible to iterate
over the wrapped vectors using for-each loops.
This commit is based on the original patch by Volker Diels-Grabsch from
https://sourceforge.net/p/swig/patches/278/