Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
47 changes: 41 additions & 6 deletions src/Containers-AVL-Tree-Inspector/CTAVLTree.extension.st
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
Extension { #name : 'CTAVLTree' }

{ #category : '*Containers-AVL-Tree-Inspector' }
CTAVLTree >> inspectorCanvas: aBuilder [
CTAVLTree >> allChildren [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the CI is failing because this method should be in the Containers-ALV-Tree package and not in the Containers-ALV-Tree-Inspector.

Now this method is an extension, it should be not. Could you change that please? If you need more info about what the problem is write me on Discord

| allNodes queue currentNode |
allNodes := OrderedCollection new.
self root isNilNode 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 ]
].

^ allNodes
]

{ #category : '*Containers-AVL-Tree-Inspector' }
CTAVLTree >> inspectorCanvas: aBuilder [
<inspectorPresentationOrder: 90 title: 'AVL'>

self size > 10000 ifTrue: [
^ aBuilder newText
text: 'Tree is too large to render graphically (', self size asString, ' nodes). Please use the Tree tab.';
yourself ].

^ (aBuilder instantiate: SpRoassalInspectorPresenter)
canvas: (CTAVLTreeVisualizer new
tree: self;
build;
canvas);
yourself
canvas: (CTAVLTreeVisualizer new
tree: self;
build;
canvas);
yourself
]

{ #category : '*Containers-AVL-Tree-Inspector' }
CTAVLTree >> inspectorTree: aBuilder [
<inspectorPresentationOrder: 91 title: 'Tree'>
^ aBuilder newTree
roots: { self root };
children: [ :node |
Array streamContents: [ :s |
node left isNilNode ifFalse: [ s nextPut: node left ].
node right isNilNode ifFalse: [ s nextPut: node right ] ] ];
display: [ :node | node contents asString ];
yourself
]
2 changes: 1 addition & 1 deletion src/Containers-AVL-Tree-Tests/CTAVLTreeTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CTAVLTreeTest >> testAddSingleElement [

{ #category : 'tests' }
CTAVLTreeTest >> testAllChildren [

| elements |
elements := (1 to: 10000) collect: [ :i | Random new nextIntegerBetween: 1 and: 100000000 ].
tree addAll: elements.
Expand Down
15 changes: 0 additions & 15 deletions src/Containers-AVL-Tree/CTAVLTree.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,6 @@ CTAVLTree >> addAll: aCollection [
^ aCollection
]

{ #category : 'accessing' }
CTAVLTree >> allChildren [

| currentNode nodesToVisit children |
children := Set new.
nodesToVisit := LinkedList with: root.

[ nodesToVisit isNotEmpty ] whileTrue: [
currentNode := nodesToVisit removeFirst.
children add: currentNode.
nodesToVisit addAll: (currentNode children reject: #isNilNode) ].

^ children
]

{ #category : 'enumerating' }
CTAVLTree >> anySatisfy: aBlock [

Expand Down
Loading