Beispiel Iterator Java

static <E extends Comparable<E>> 
List<E> merge(List<E> xs, List<E> ys) {
	List<E> zs = new LinkedList<E>();
	Iterator<E> xi = xs.iterator();
	Iterator<E> yi = ys.iterator();
        // FIXME:
	while (xi.hasNext() && yi.hasNext()) {
		E x = xi.next();
		E y = yi.next();
		if (x.compareTo(y) < 0) {
			zs.add(x);
		} else {
			zs.add(y);
		}
	}
	return zs;
}



2009-06-15