File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,12 @@ func (n *Node[T]) IsLeafNode() bool {
292292 return n .Left == nil && n .Right == nil
293293}
294294
295+ // IsFullNode returns true, if the node contains left and right
296+ // children
297+ func (n * Node [T ]) IsFullNode () bool {
298+ return n .Left != nil && n .Right != nil
299+ }
300+
295301// AddSkipNodeFunc adds a new handler for determining whether a
296302// node from the tree should be skipped while traversing it.
297303func (n * Node [T ]) AddSkipNodeFunc (handler SkipNodeFunc [T ]) {
@@ -353,8 +359,7 @@ func (n *Node[T]) IsFullTree() bool {
353359 continue
354360 }
355361
356- both := node .Left != nil && node .Right != nil
357- if ! both {
362+ if ! node .IsFullNode () {
358363 return false
359364 }
360365
@@ -378,8 +383,8 @@ func (n *Node[T]) IsDegenerateTree() bool {
378383 if node .IsLeafNode () {
379384 continue
380385 }
381- both := node . Left != nil && node . Right != nil
382- if both {
386+
387+ if node . IsFullNode () {
383388 return false
384389 }
385390
You can’t perform that action at this time.
0 commit comments