Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/Containers-AVL-Tree/CTAVLAbstractNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ CTAVLAbstractNode >> isLeaf [
^ self subclassResponsibility
]

{ #category : 'testing' }
CTAVLAbstractNode >> isNilNode [

^ false
]

{ #category : 'accessing' }
CTAVLAbstractNode >> parent [

Expand Down
15 changes: 9 additions & 6 deletions src/Containers-AVL-Tree/CTAVLNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ CTAVLNode >> balanceFactor [

{ #category : 'accessing' }
CTAVLNode >> children [

^ { left . right }
| validChildren |
validChildren := OrderedCollection new: 2.
left isEmpty ifFalse: [ validChildren add: left ].
right isEmpty ifFalse: [ validChildren add: right ].
^ validChildren asArray
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -175,10 +178,10 @@ CTAVLNode >> left: aNode [

{ #category : 'copying' }
CTAVLNode >> postCopy [
super postCopy.
left isNilNode ifFalse: [ left := left copy ].
right isNilNode ifFalse: [ right := right copy ]
super postCopy.

left := left copy.
right := right copy
]

{ #category : 'enumerating' }
Expand Down
9 changes: 4 additions & 5 deletions src/Containers-AVL-Tree/CTAVLTree.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ CTAVLTree >> addAll: aCollection [
CTAVLTree >> allChildren [
| allNodes queue currentNode |
allNodes := OrderedCollection new.
self root isNilNode ifTrue: [ ^ allNodes ].
self root isEmpty ifTrue: [ ^ allNodes ].

queue := OrderedCollection with: self root.
[ queue isNotEmpty ] whileTrue: [
currentNode := queue removeFirst.
allNodes add: currentNode.
currentNode left isNilNode ifFalse: [ queue add: currentNode left ].
currentNode right isNilNode ifFalse: [ queue add: currentNode right ]
queue addAll: currentNode children
].

^ allNodes
Expand Down Expand Up @@ -231,8 +230,8 @@ CTAVLTree >> last [

{ #category : 'copying' }
CTAVLTree >> postCopy [
super postCopy.
root := root copy.
super postCopy.
root := root copy.
]

{ #category : 'enumerating' }
Expand Down
Loading