Professional Documents
Culture Documents
Спој листи - Java
Спој листи - Java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.NoSuchElementException;
protected E element;
this.element = elem;
this.succ = succ;
@Override
return element.toString();
}
public SLL() {
this.first = null;
first = null;
int ret;
if (first != null) {
ret = 1;
tmp = tmp.succ;
ret++;
return ret;
} else
return 0;
@Override
if (first != null) {
tmp = tmp.succ;
} else
return ret;
first = ins;
}
public void insertAfter(E o, SLLNode<E> node) {
if (node != null) {
node.succ = ins;
} else {
if (first != null) {
if (first == before) {
this.insertFirst(o);
return;
// ako first!=before
tmp = tmp.succ;
if (tmp.succ == before) {
tmp.succ = ins;
} else {
} else {
System.out.println("Listata e prazna");
if (first != null) {
tmp = tmp.succ;
tmp.succ = ins;
} else {
insertFirst(o);
return first;
// left-to-right order.
return new LRIterator<E>();
@SuppressWarnings("unchecked")
private LRIterator() {
public E next() {
if (place == null)
E nextElem = place.element;
place = place.succ;
return nextElem;
}
public void remove() {
// Not implemented
System.in));
String s = stdin.readLine();
int N = Integer.parseInt(s);
s = stdin.readLine();
lista1.insertLast(Integer.parseInt(pomniza[i]));
}
s = stdin.readLine();
N = Integer.parseInt(s);
s = stdin.readLine();
lista2.insertLast(Integer.parseInt(pomniza[i]));
Iterator<Integer> it = spoeni.iterator();
while (it.hasNext()) {
System.out.print(it.next());
if(it.hasNext())
System.out.print(" ");