Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
459587b9bc
@ -36,6 +36,7 @@ public class RingList<E> implements List<E> {
|
||||
}
|
||||
|
||||
private Wrapper getWrapper(int index) {
|
||||
if(index == -1) return first;
|
||||
Wrapper wRun;
|
||||
if (index < 0 || index >= size) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@ -58,15 +59,15 @@ public class RingList<E> implements List<E> {
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
Wrapper wrapper = getWrapper(index - 1);
|
||||
E result = wrapper.succ.e;
|
||||
wrapper.succ = wrapper.succ.succ;
|
||||
size--;
|
||||
|
||||
return wrapper.succ.e;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
|
||||
try {
|
||||
int index = indexOf((E) o);
|
||||
if(index == -1) return false;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package xyz.joethei.studium.algodat.vorlesung;
|
||||
package xyz.joethei.studium.algodat.praktikum;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import xyz.joethei.studium.algodat.praktikum.blatt2.List;
|
||||
@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class Blatt2Test {
|
||||
class RingListTest {
|
||||
|
||||
@Test
|
||||
void add() {
|
||||
@ -46,9 +46,12 @@ class Blatt2Test {
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
rList.add(i * i);
|
||||
}
|
||||
assertEquals(Optional.of(49), Optional.ofNullable(rList.remove(5)));
|
||||
assertEquals(Optional.of(1), Optional.of(rList.remove(0)));
|
||||
assertEquals(9, rList.size());
|
||||
assertTrue(rList.get(5) != 36);
|
||||
assertEquals(Optional.of(36), Optional.of(rList.remove(4)));
|
||||
assertEquals(8, rList.size());
|
||||
assertEquals(Optional.of(true), Optional.of(rList.remove((Integer) 100)));
|
||||
assertTrue(rList.get(4) != 36);
|
||||
}
|
||||
|
||||
@Test
|
Loading…
Reference in New Issue
Block a user