Algorithmen & Datenstrukturen mit Java: Ein sehr einfacher erster Test |
1package tests.destructive.list;
2
3import ds.interfaces.List;
4import ds.util.E;
5
6import static ds.destructive.list.LinkedRing.empty;
7import static ds.destructive.list.LinkedRing.stats;
8import static ds.util.E.mkE;
9
10import static java.lang.System.out;
11
12public class LinkedRing1 {
13 public static void main(String [] argv) {
14 List l = empty();
15
16 l = l.cons(mkE(4)).cons(mkE(3)).cons(mkE(2)).cons(mkE(1));
17 l = l.concat(l.copy()); // requires cloning before concat
18
19 out.println("");
20 out.println("l : " + l);
21 out.println("l.isEmpty() : " + l.isEmpty());
22 out.println("l.length() : " + l.length());
23 out.println("l.head() : " + l.head());
24 out.println("l.last() : " + l.last());
25 out.println("l.at(3) : " + l.at(3));
26 out.println("l.member(3) : " + l.member(mkE(3)));
27 out.println("l.member(9) : " + l.member(mkE(9)));
28
29 List l2 = l.tail();
30 out.println("l2 = l.tail() : " + l2);
31 out.println("l2.length() : " + l2.length());
32
33 List l3 = l2.reverse();
34 out.println("l3 = l2.reverse() : " + l3);
35 out.println("");
36 out.println("l : " + l);
37
38 out.println("\n" + stats());
39 }
40}
|
Letzte Änderung: 02.11.2015 | © Prof. Dr. Uwe Schmidt |