chiark
/
gitweb
/
~mdw
/
fringe
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e4e035b
)
smalltalk: Abstract out the common iteration protocol into a superclass.
author
Mark Wooding
<mdw@distorted.org.uk>
Sun, 29 Nov 2009 23:26:41 +0000
(23:26 +0000)
committer
Mark Wooding
<mdw@distorted.org.uk>
Sun, 29 Nov 2009 23:26:41 +0000
(23:26 +0000)
smalltalk-fringe.st
patch
|
blob
|
blame
|
history
diff --git
a/smalltalk-fringe.st
b/smalltalk-fringe.st
index 0d319da31e42db35a8ba5a58e0fee9e36270a097..653c31ae68b4aad59d8df42955ca3b1eaf0564e3 100644
(file)
--- a/
smalltalk-fringe.st
+++ b/
smalltalk-fringe.st
@@
-5,7
+5,19
@@
Smalltalk implementation of a `same-fringe' solver.
Use GNU Smalltalk syntax -- it seems more Emacs-friendly.
"
Use GNU Smalltalk syntax -- it seems more Emacs-friendly.
"
-Object subclass: Node [
+Object subclass: BasicNode [
+ <comment: 'I am provide common behaviour for my subclasses Node and
+LeafNode. Otherwise, I''m not particularly interesting.'>
+
+ iterator [
+ "Return a new iterator to walk this node."
+
+ <category: 'iteration'>
+ ^NodeIterator for: self
+ ]
+]
+
+BasicNode subclass: Node [
| left right data |
<comment: 'I represent simple binary tree nodes. My instances consist of
| left right data |
<comment: 'I represent simple binary tree nodes. My instances consist of
@@
-69,13
+81,6
@@
instances of LeafNode.'>
^false
]
^false
]
- iterator [
- "Answer a new iterator to walk this node."
-
- <category: 'iteration'>
- ^NodeIterator for: self
- ]
-
inorderTell: aBlock tell: aNodeIterator [
"This is the hairy part of the iteration protocol.
inorderTell: aBlock tell: aNodeIterator [
"This is the hairy part of the iteration protocol.
@@
-179,7
+184,7
@@
PositionableStream extend [
]
]
]
]
-
Object
subclass: LeafNode [
+
BasicNode
subclass: LeafNode [
<comment: 'I represent the leaves of a tree of Nodes. I don''t hold any
kind of interesting state. My methods provide the base cases for some of the
recursive protocols used to handle Nodes.'>
<comment: 'I represent the leaves of a tree of Nodes. I don''t hold any
kind of interesting state. My methods provide the base cases for some of the
recursive protocols used to handle Nodes.'>
@@
-201,13
+206,6
@@
recursive protocols used to handle Nodes.'>
^true
]
^true
]
- iterator [
- "Return a new iterator to walk this node."
-
- <category: 'iteration'>
- ^NodeIterator for: self
- ]
-
inorderTell: aBlock tell: aNodeIterator [
"This is the hairy part of the iteration protocol.
inorderTell: aBlock tell: aNodeIterator [
"This is the hairy part of the iteration protocol.