|
|
@@ -6,6 +6,7 @@
|
|
|
*/
|
|
|
package net.ranides.assira.collection.lists;
|
|
|
|
|
|
+import java.io.Serializable;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -13,9 +14,11 @@ import java.util.*;
|
|
|
* @param <T>
|
|
|
* @author Ranides Atterwim <ranides@gmail.com>
|
|
|
*/
|
|
|
-public class JoinList<T> extends AbstractSequentialList<T> {
|
|
|
+public class JoinList<T> extends AbstractSequentialList<T> implements Serializable {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
|
|
|
- private final List<List<T>> content;
|
|
|
+ private final LinkedList<List<T>> content;
|
|
|
|
|
|
public JoinList() {
|
|
|
content = new LinkedList<>();
|
|
|
@@ -117,7 +120,11 @@ public class JoinList<T> extends AbstractSequentialList<T> {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- throw new IndexOutOfBoundsException("index=" + index + " size=" + end );
|
|
|
+ if(index == end) {
|
|
|
+ content.getLast().add(element);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ throw new IndexOutOfBoundsException("index=" + index + " size=" + end );
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -130,7 +137,10 @@ public class JoinList<T> extends AbstractSequentialList<T> {
|
|
|
return list.addAll(index - begin, values);
|
|
|
}
|
|
|
}
|
|
|
- throw new IndexOutOfBoundsException("index=" + index + " size=" + end );
|
|
|
+ if(index == end) {
|
|
|
+ return content.getLast().addAll(values);
|
|
|
+ }
|
|
|
+ throw new IndexOutOfBoundsException("index=" + index + " size=" + end );
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -165,6 +175,11 @@ public class JoinList<T> extends AbstractSequentialList<T> {
|
|
|
public ListIterator<T> listIterator(int index) {
|
|
|
return new JoinIterator<>(content, index);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<T> subList(int begin, int end) {
|
|
|
+ return ListUtils.sublist(this, begin, end);
|
|
|
+ }
|
|
|
|
|
|
private static final class JoinIterator<T> implements ListIterator<T> {
|
|
|
|