188
|
1 |
'From Smalltalk/X, Version:2.10.8 on 12-feb-1996 at 15:36:51' !
|
|
2 |
|
|
3 |
OrderedCollection subclass:#Stack
|
|
4 |
instanceVariableNames:'topPtr'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'T-gen-Scanning/Parsing'
|
|
8 |
!
|
|
9 |
|
|
10 |
!Stack class methodsFor:'instance creation'!
|
|
11 |
|
|
12 |
new
|
|
13 |
^self new: 100
|
|
14 |
! !
|
|
15 |
|
|
16 |
!Stack methodsFor:'accessing'!
|
|
17 |
|
|
18 |
pop
|
|
19 |
"Answer the object on top of the stack."
|
|
20 |
|
|
21 |
^ self removeLast
|
|
22 |
|
|
23 |
"Created: 7.2.1996 / 00:12:53 / stefan"
|
|
24 |
"Modified: 7.2.1996 / 00:13:53 / stefan"
|
|
25 |
!
|
|
26 |
|
|
27 |
pop: numElem
|
|
28 |
"Pop and discard top numElems and answer receiver"
|
|
29 |
|
|
30 |
self removeLast:numElem
|
|
31 |
|
|
32 |
"Created: 7.2.1996 / 00:12:53 / stefan"
|
|
33 |
"Modified: 7.2.1996 / 00:14:16 / stefan"
|
|
34 |
!
|
|
35 |
|
|
36 |
push: anObject
|
|
37 |
"Push anObject onto the top of the stack."
|
|
38 |
|
|
39 |
^ self add:anObject
|
|
40 |
|
|
41 |
"Created: 7.2.1996 / 00:12:53 / stefan"
|
|
42 |
"Modified: 7.2.1996 / 00:14:52 / stefan"
|
|
43 |
!
|
|
44 |
|
|
45 |
top
|
|
46 |
"Answer (without removing) the object on top of the stack."
|
|
47 |
|
|
48 |
^self last
|
|
49 |
|
|
50 |
"Created: 7.2.1996 / 00:12:54 / stefan"
|
|
51 |
"Modified: 7.2.1996 / 00:15:26 / stefan"
|
|
52 |
! !
|
|
53 |
|
|
54 |
!Stack methodsFor:'enumerating'!
|
|
55 |
|
|
56 |
do: aBlock
|
|
57 |
"Evaluate aBlock for each object on the stack, from top to bottom."
|
|
58 |
|
|
59 |
^ super reverseDo:aBlock
|
|
60 |
|
|
61 |
"Created: 7.2.1996 / 00:12:53 / stefan"
|
|
62 |
"Modified: 7.2.1996 / 00:16:00 / stefan"
|
|
63 |
!
|
|
64 |
|
|
65 |
reverseDo: aBlock
|
|
66 |
"Evaluate aBlock for each object on the stack, from bottom to top."
|
|
67 |
|
|
68 |
^ super do:aBlock
|
|
69 |
|
|
70 |
"Created: 7.2.1996 / 00:12:54 / stefan"
|
|
71 |
"Modified: 7.2.1996 / 00:16:18 / stefan"
|
|
72 |
! !
|
|
73 |
|