SLIDE 5 5
Programming in the large - Lecture 3
13 Chair of Software Engineering
A stack, concrete object
count representation (array_up) capacity
representation [count] := x “Push” x on stack representation: count := count + 1
1
x x
Programming in the large - Lecture 3
14 Chair of Software Engineering
A stack, concrete object
count representation (array_up) capacity
representation [count] := x
free (array_down) 1 representation
“Push” x on stack representation: count := count + 1 representation [free] := x “Push” x on stack representation: free := free - 1
1
x x x
Programming in the large - Lecture 3
15 Chair of Software Engineering
A stack, concrete object
count representation (array_up) capacity
representation [count] := x
free (array_down) 1 representation
n new (linked) item item previous item previous previous
“Push” x on stack representation: count := count + 1 representation [free] := x “Push” x on stack representation: free := free - 1 “Push” operation: new (n) n.item := x n.previous := last head := n
1
x