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

@ -131,5 +131,13 @@ public class li_std_vector_runme {
java.util.ArrayList<Boolean> bl2 = new java.util.ArrayList<Boolean>(bv);
boolean bbb1 = bv.get(0);
Boolean bbb2 = bv.get(0);
IntVector v9 = new IntVector(java.util.Arrays.asList(10, 20, 30, 40));
v9.add(50);
v9.add(60);
v9.add(70);
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");
}
}