Stack.st
changeset 188 74c8f104cd71
child 296 3519dbc41ab1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Stack.st	Wed Feb 14 16:04:49 1996 +0100
@@ -0,0 +1,73 @@
+'From Smalltalk/X, Version:2.10.8 on 12-feb-1996 at 15:36:51'                   !
+
+OrderedCollection subclass:#Stack
+	instanceVariableNames:'topPtr'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'T-gen-Scanning/Parsing'
+!
+
+!Stack class methodsFor:'instance creation'!
+
+new
+        ^self new: 100
+! !
+
+!Stack methodsFor:'accessing'!
+
+pop
+        "Answer the object on top of the stack."
+
+    ^ self removeLast
+
+    "Created: 7.2.1996 / 00:12:53 / stefan"
+    "Modified: 7.2.1996 / 00:13:53 / stefan"
+!
+
+pop: numElem 
+        "Pop and discard top numElems and answer receiver"
+
+        self removeLast:numElem
+
+    "Created: 7.2.1996 / 00:12:53 / stefan"
+    "Modified: 7.2.1996 / 00:14:16 / stefan"
+!
+
+push: anObject 
+        "Push anObject onto the top of the stack."
+
+    ^ self add:anObject
+
+    "Created: 7.2.1996 / 00:12:53 / stefan"
+    "Modified: 7.2.1996 / 00:14:52 / stefan"
+!
+
+top
+        "Answer (without removing) the object on top of the stack."
+
+        ^self last
+
+    "Created: 7.2.1996 / 00:12:54 / stefan"
+    "Modified: 7.2.1996 / 00:15:26 / stefan"
+! !
+
+!Stack methodsFor:'enumerating'!
+
+do: aBlock
+        "Evaluate aBlock for each object on the stack, from top to bottom."
+
+        ^ super reverseDo:aBlock
+
+    "Created: 7.2.1996 / 00:12:53 / stefan"
+    "Modified: 7.2.1996 / 00:16:00 / stefan"
+!
+
+reverseDo: aBlock
+        "Evaluate aBlock for each object on the stack, from bottom to top."
+
+        ^ super do:aBlock
+
+    "Created: 7.2.1996 / 00:12:54 / stefan"
+    "Modified: 7.2.1996 / 00:16:18 / stefan"
+! !
+