aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2019-12-15 19:18:01 +0100
committerbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2019-12-15 19:18:01 +0100
commita70a8c6c1684beaf6f65a8db6f59840a27054d29 (patch)
tree1f121021f9c8b1cddaf11552930bff7331040f25 /src/main
parent6c5e31cd64bf9ca7877771314cc98d2ad6b81711 (diff)
downloadGT5-Unofficial-a70a8c6c1684beaf6f65a8db6f59840a27054d29.tar.gz
GT5-Unofficial-a70a8c6c1684beaf6f65a8db6f59840a27054d29.tar.bz2
GT5-Unofficial-a70a8c6c1684beaf6f65a8db6f59840a27054d29.zip
worked on AccessPriorityList
+ switching now works fine + toArray() now works as expected + added Exceptions Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Former-commit-id: b4707dfa63c6239a70f2ae829fef1b19d6ea7a58
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java74
1 files changed, 42 insertions, 32 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java
index bd4482741d..a1067b051e 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/accessprioritylist/AccessPriorityList.java
@@ -22,6 +22,8 @@
package com.github.bartimaeusnek.bartworks.util.accessprioritylist;
+import org.apache.commons.lang3.NotImplementedException;
+
import java.util.*;
public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@@ -30,7 +32,7 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
transient AccessPriorityListNode<E> head;
transient AccessPriorityListNode<E> tail;
- public static AccessPriorityList create(){
+ public static AccessPriorityList create() {
return new AccessPriorityList();
}
@@ -62,32 +64,32 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public boolean offerFirst(E e) {
- return false;
+ throw new NotImplementedException("");
}
@Override
public boolean offerLast(E e) {
- return false;
+ throw new NotImplementedException("");
}
@Override
public E removeFirst() {
- return null;
+ throw new NotImplementedException("");
}
@Override
public E removeLast() {
- return null;
+ throw new NotImplementedException("");
}
@Override
public E pollFirst() {
- return null;
+ throw new NotImplementedException("");
}
@Override
public E pollLast() {
- return null;
+ throw new NotImplementedException("");
}
@Override
@@ -112,12 +114,12 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public boolean removeFirstOccurrence(Object o) {
- return false;
+ throw new NotImplementedException("");
}
@Override
public boolean removeLastOccurrence(Object o) {
- return false;
+ throw new NotImplementedException("");
}
@Override
@@ -132,7 +134,7 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public boolean contains(Object o) {
- return false;
+ throw new NotImplementedException("");
}
@Override
@@ -148,16 +150,18 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public Object[] toArray() {
Object[] ret = new Object[size];
- while (listIterator().hasNext())
- ret[listIterator().nextIndex()-1] = listIterator().next();
+ int index = 0;
+ for (Iterator<E> it = iterator(); it.hasNext(); index++)
+ ret[index] = it.next();
return ret;
}
@Override
public <T> T[] toArray(T[] a) {
T[] ret = (T[]) new Object[size];
- while (listIterator().hasNext())
- ret[listIterator().nextIndex()-1] = (T) listIterator().next();
+ int index = 0;
+ for (Iterator<T> it = (Iterator<T>) iterator(); it.hasNext(); index++)
+ ret[index] = it.next();
return ret;
}
@@ -181,6 +185,8 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
if (beforeBefore != null)
beforeBefore.setNext(node);
+ else
+ head = node;
// <0,1,3> <1,2,3> N<0,3,4> <3,4,5>
before.setBefore(node);
@@ -191,6 +197,8 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
if (next != null)
next.setBefore(before);
+ else
+ tail = before;
// <0,1,3> N<0,3,4> <3,2,4> <2,4,5>
node.setNext(before);
@@ -213,26 +221,28 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public boolean offer(E e) {
- return false;
+ throw new NotImplementedException("");
}
private boolean isValidIndex(int index) {
- return index >= 0 && index < size;
+ if (index >= 0 && index < size)
+ return true;
+ throw new ArrayIndexOutOfBoundsException("NOT A VAILD INDEX!");
}
@Override
public E remove() {
- return null;
+ throw new NotImplementedException("");
}
@Override
public E poll() {
- return null;
+ throw new NotImplementedException("");
}
@Override
public E element() {
- return null;
+ throw new NotImplementedException("");
}
@Override
@@ -247,17 +257,17 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public E pop() {
- return null;
+ throw new NotImplementedException("");
}
@Override
public boolean remove(Object o) {
- return false;
+ throw new NotImplementedException("");
}
@Override
public boolean containsAll(Collection<?> c) {
- return false;
+ throw new NotImplementedException("");
}
@Override
@@ -270,17 +280,17 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public boolean addAll(int index, Collection<? extends E> c) {
- return false;
+ throw new NotImplementedException("");
}
@Override
public boolean removeAll(Collection<?> c) {
- return false;
+ throw new NotImplementedException("");
}
@Override
public boolean retainAll(Collection<?> c) {
- return false;
+ throw new NotImplementedException("");
}
@Override
@@ -323,27 +333,27 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public E set(int index, E element) {
- return null;
+ throw new NotImplementedException("");
}
@Override
public void add(int index, E element) {
-
+ throw new NotImplementedException("");
}
@Override
public E remove(int index) {
- return null;
+ throw new NotImplementedException("");
}
@Override
public int indexOf(Object o) {
- return 0;
+ throw new NotImplementedException("");
}
@Override
public int lastIndexOf(Object o) {
- return 0;
+ throw new NotImplementedException("");
}
@Override
@@ -358,11 +368,11 @@ public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> {
@Override
public List<E> subList(int fromIndex, int toIndex) {
- return null;
+ throw new NotImplementedException("");
}
@Override
public Spliterator<E> spliterator() {
- return null;
+ throw new NotImplementedException("");
}
}