Additional add/remove methods added to Java std::list wrappers
Add functions similar to java.util.LinkedList<E>: addFirst addLast removeFirst removeLast
This commit is contained in:
parent
c686045f55
commit
ecebbdd0df
2 changed files with 15 additions and 2 deletions
|
|
@ -138,5 +138,15 @@ public class li_std_list_runme {
|
|||
if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed");
|
||||
if (!v9.remove(new Integer(60))) throw new RuntimeException("v9 test (2) failed");
|
||||
if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed");
|
||||
v9.addFirst(-10);
|
||||
v9.addLast(80);
|
||||
if (v9.size() != 8) throw new RuntimeException("v9 test (4) failed");
|
||||
if (v9.get(0) != -10) throw new RuntimeException("v9 test (5) failed");;
|
||||
if (v9.get(v9.size()-1) != 80) throw new RuntimeException("v9 test (6) failed");;
|
||||
v9.removeFirst();
|
||||
if (v9.get(0) != 10) throw new RuntimeException("v9 test (7) failed");;
|
||||
v9.removeLast();
|
||||
if (v9.size() != 6) throw new RuntimeException("v9 test (8) failed");
|
||||
if (v9.get(v9.size()-1) != 70) throw new RuntimeException("v9 test (9) failed");;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ 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";
|
||||
|
|
@ -46,7 +45,7 @@ namespace std {
|
|||
}
|
||||
|
||||
public boolean add($typemap(jboxtype, T) value) {
|
||||
push_back(value);
|
||||
addLast(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -173,9 +172,13 @@ namespace std {
|
|||
%rename(remove) erase;
|
||||
iterator erase(iterator pos);
|
||||
size_type max_size() const;
|
||||
%rename(removeLast) pop_back;
|
||||
void pop_back();
|
||||
%rename(removeFirst) pop_front;
|
||||
void pop_front();
|
||||
%rename(addLast) push_back;
|
||||
void push_back(const T &value);
|
||||
%rename(addFirst) push_front;
|
||||
void push_front(const T &value);
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue