'From VisualWorks(TM), Release 1.0 of 8 October 1992 on 4 November 1994 at 2:09:02 pm'! Collection subclass: #BinaryTree2 instanceVariableNames: 'nodeOrNil ' classVariableNames: '' poolDictionaries: '' category: 'Collections-Abstract'! !BinaryTree2 methodsFor: 'constructors'! add: item self isEmpty ifTrue: [nodeOrNil := BinaryNode new. nodeOrNil setValue: item.] ifFalse: [nodeOrNil add: item].! remove: item ifAbsent: aBlock self isEmpty ifTrue: [ ^self ] ifFalse: [ nodeOrNil := nodeOrNil remove: item ifAbsent: aBlock ].! ! !BinaryTree2 methodsFor: 'predicates'! includes: item self isEmpty ifTrue: [^false.] ifFalse: [^(nodeOrNil includes: item)]! isEmpty ^nodeOrNil = nil.! max self isEmpty ifTrue: [ ^nil ] ifFalse: [ ^nodeOrNil max ]! ! !BinaryTree2 methodsFor: 'printing'! printOn: aStream "standard print method" self inorderDo: [:node | aStream nextPutAll: node value printString. aStream space.].! ! !BinaryTree2 methodsFor: 'traversals'! do: aBlock self isEmpty ifFalse: [nodeOrNil inorder: aBlock].! inorderDo: aBlock self isEmpty ifFalse: [nodeOrNil inorder: aBlock].! postorderDo: aBlock self isEmpty ifFalse: [nodeOrNil postorder: aBlock].! preorderDo: aBlock self isEmpty ifFalse: [nodeOrNil preorder: aBlock].! !