There are bugs in getFirstsetFirst
, getLastsetLast
, and reverse
. Consider this code:
LList list = new LList(Arrays.asList(1));
list.setFirst(new NodeLL(2));
System.out.printf("%d%n", list.getLast().item);
The expected behaviour would be to print 2, but it actually prints 1.
The same goes for this code:
LList list = new LList(Arrays.asList(1));
list.setLast(new NodeLL(2));
System.out.printf("%d%n", list.getFirst().item);
and this:
LList list = new LList(Arrays.asList(2, 1));
TripletLL.reverse(list);
System.out.printf("%d%n", list.getLast().item);