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:
parent
a8e948e96d
commit
c686045f55
3 changed files with 22 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue