-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexampleLinkedList.txt
70 lines (60 loc) · 1.05 KB
/
exampleLinkedList.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class main : Base {
function main () {
ll = new LinkedList;
ll.size = 0;
i = 5;
while(i != 0){
this.print("-------BEG:");
this.print(ll.size);
this.print(ll.value);
ll.add(i, ll);
this.print(ll.size);
this.print(ll.value);
this.print("-------END:");
i = i - 1;
}
this.print("-------Finished Cycle Done size:");
ll.to_string(ll);
return 1;
}
}
class LinkedList : Base {
value;
next;
size;
function add(tvalue, ll){
this.print(ll);
this.print(tvalue);
if(ll.size == 0){
this.print("------SIZE ====== 0");
this.print(tvalue);
ll.value = tvalue;
ll.next = 0;
ll.size = 1;
return 1;
}else{
this.print("------SIZE != 0");
g = ll.size;
t = ll;
while(g != 1){
t = t.next;
g = g - 1;
}
h = new LinkedList;
h.value = tvalue;
h.next = 0;
t.next = h;
ll.size = ll.size + 1;
return 1;
}
}
function to_string(ll){
g = ll.size;
while(g != 0){
this.print(ll.value);
ll = ll.next;
g = g - 1;
}
return 1;
}
}