add special implementation for add

The special implementation does not need to allocate an array for the
varargs of addAll
This commit is contained in:
2017-09-28 18:22:16 +02:00
parent 4da0726185
commit 4a762f39b9
2 changed files with 11 additions and 8 deletions

View File

@@ -39,11 +39,9 @@ public class IntListTest {
@Test
public void testAdd() {
final IntList list = new IntList();
list.addAll();
Assert.assertTrue(list.isEmpty());
Assert.assertEquals(0, list.size());
// setting initial size to one, so that the first add does not need to resize,
// but the second add must
final IntList list = new IntList(1);
list.add(1);
@@ -179,6 +177,10 @@ public class IntListTest {
public void testAddArray() {
final IntList list = new IntList();
list.addAll();
Assert.assertTrue(list.isEmpty());
Assert.assertEquals(0, list.size());
final int size = 100;
final int[] ints = ThreadLocalRandom.current().ints(size).toArray();