fixes
This commit is contained in:
@@ -63,6 +63,11 @@ public class NodePositionListTest {
|
|||||||
System.out.print(it.next());
|
System.out.print(it.next());
|
||||||
System.out.print(it.hasNext());
|
System.out.print(it.hasNext());
|
||||||
|
|
||||||
|
System.out.print(a.positions().iterator());
|
||||||
|
System.out.print(it.hasNext());
|
||||||
|
System.out.print(((Position<Integer>)(it.next().);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -198,13 +198,26 @@ public class NodePositionList<E> implements PositionList<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// inception style. a dream in a dream in a dream
|
||||||
|
|
||||||
public Iterator<Position<E>> positions() {
|
public Iterable<Position<E>> positions() {
|
||||||
return new MyPositionsIterator(this);
|
return new MyPositionsIterable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyPositionsIterator implements Iterator<Position<E>>{
|
class MyPositionsIterable implements Iterable<Position<E>>{
|
||||||
|
|
||||||
|
private NodePositionList<E> base = null;
|
||||||
|
|
||||||
|
public MyPositionsIterable(NodePositionList<E> in){
|
||||||
|
base = in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<Position<E>> iterator() {
|
||||||
|
return new MyPositionsIterator(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyPositionsIterator <E> implements Iterator<Position<E>> {
|
||||||
public MyPositionsIterator (NodePositionList<E> structure){
|
public MyPositionsIterator (NodePositionList<E> structure){
|
||||||
|
|
||||||
new_structure = new NodePositionList<Position<E>>();
|
new_structure = new NodePositionList<Position<E>>();
|
||||||
@@ -264,7 +277,12 @@ public class NodePositionList<E> implements PositionList<E> {
|
|||||||
|
|
||||||
NodePositionList<Position<E>> new_structure;
|
NodePositionList<Position<E>> new_structure;
|
||||||
Position<Position<E>> pos = null;
|
Position<Position<E>> pos = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// end inception style
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class SortedListPriorityQueue<K,V> implements PriorityQueue<K,V> {
|
|||||||
data.addFirst(t);
|
data.addFirst(t);
|
||||||
return t;
|
return t;
|
||||||
} else {
|
} else {
|
||||||
Iterator<Position<MyEntry<K, V>>> itp = data.positions();
|
Iterator<Position<MyEntry<K, V>>> itp = data.positions().iterator();
|
||||||
int status;
|
int status;
|
||||||
Position<MyEntry<K, V>> temp_pos = null;
|
Position<MyEntry<K, V>> temp_pos = null;
|
||||||
for (; itp.hasNext(); ) {
|
for (; itp.hasNext(); ) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class UnsortedListPriorityQueue<K,V> implements PriorityQueue<K,V> {
|
|||||||
if (isEmpty()){
|
if (isEmpty()){
|
||||||
throw new EmptyPriorityQueueException();
|
throw new EmptyPriorityQueueException();
|
||||||
} else {
|
} else {
|
||||||
Iterator<Position<MyEntry<K, V>>> itp = data.positions();
|
Iterator<Position<MyEntry<K, V>>> itp = data.positions().iterator();
|
||||||
int status;
|
int status;
|
||||||
Position<MyEntry<K, V>> min = null;
|
Position<MyEntry<K, V>> min = null;
|
||||||
Position<MyEntry<K, V>> temp_pos = null;
|
Position<MyEntry<K, V>> temp_pos = null;
|
||||||
@@ -83,7 +83,7 @@ public class UnsortedListPriorityQueue<K,V> implements PriorityQueue<K,V> {
|
|||||||
if (isEmpty()){
|
if (isEmpty()){
|
||||||
throw new EmptyPriorityQueueException();
|
throw new EmptyPriorityQueueException();
|
||||||
} else {
|
} else {
|
||||||
Iterator<Position<MyEntry<K, V>>> itp = data.positions();
|
Iterator<Position<MyEntry<K, V>>> itp = data.positions().iterator();
|
||||||
int status;
|
int status;
|
||||||
Position<MyEntry<K, V>> min = null;
|
Position<MyEntry<K, V>> min = null;
|
||||||
Position<MyEntry<K, V>> temp_pos = null;
|
Position<MyEntry<K, V>> temp_pos = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user