More efficient add implementation for Java std::list

The default implementation in AbstractSequentialList<E>
calls add(size(), e) and size() might be expensive.
This commit is contained in:
William S Fulton 2017-06-24 23:33:31 +01:00
commit c686045f55
3 changed files with 22 additions and 0 deletions

View file

@ -14,6 +14,7 @@ SWIGINTERN jint SWIG_ListSize(size_t size) {
}
}
%javamethodmodifiers std::list::push_back "private";
%javamethodmodifiers std::list::begin "private";
%javamethodmodifiers std::list::insert "private";
%javamethodmodifiers std::list::doSize "private";
@ -44,6 +45,11 @@ namespace std {
return doSize();
}
public boolean add($typemap(jboxtype, T) value) {
push_back(value);
return true;
}
public java.util.ListIterator<$typemap(jboxtype, T)> listIterator(int index) {
return new java.util.ListIterator<$typemap(jboxtype, T)>() {
private Iterator pos;