Commit Graph

13 Commits

Author SHA1 Message Date
Brad Kotsopoulos 55e835e0ae Java std::vector constructor performance improvement
Reserve before loop of push_back
Refactor li_std_vector testcase

This is a squash merge of #1552
2019-06-06 19:29:11 +01:00
William S Fulton be491506a4 Java std::vector improvements for types that do not have a default constructor.
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).
2019-03-01 18:01:14 +00:00
William S Fulton e6035d625a Java 9 deprecation warning fixes for test-suite and examples 2019-02-21 13:47:39 -08:00
William S Fulton 44cd658a53 Add in missing Java std::list listIterator index range checking 2017-06-29 19:32:34 +01:00
William S Fulton 90d2ba884c Java std::list std::vector - test addAll and subList 2017-06-26 13:42:19 +01:00
William S Fulton c686045f55 More efficient add implementation for Java std::list
The default implementation in AbstractSequentialList<E>
calls add(size(), e) and size() might be expensive.
2017-06-24 23:33:31 +01:00
William S Fulton ea55c5bba0 Java std::vector std::list enhancements
- 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.
2017-06-24 14:30:03 +01:00
William S Fulton 428b332e68 Improve Java std::list std::vector runtime tests and wrap std::list::clear 2017-06-23 15:42:59 +01:00
William S Fulton bc7c80b862 More Java vector runtime tests 2017-06-05 19:33:45 +01:00
William S Fulton 65abd9558d Merge branch 'java-vector-test'
* java-vector-test:
  Java std_vector runtime test

Conflicts:
	Examples/test-suite/java/li_std_vector_runme.java
2017-06-05 19:23:31 +01:00
William S Fulton 30b7424f8e Java std_vector runtime test
From Volker Diels-Grabsch in SF patch https://sourceforge.net/p/swig/patches/278/
2017-06-05 19:15:32 +01:00
Vadim Zeitlin c79dd9d420 Make std::vector<> wrappers conform to List interface in Java
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/
2016-11-29 17:46:38 +01:00
William S Fulton d551b655f2 vector wrapper runtime tests
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8071 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-26 23:31:28 +00:00