Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhance BinaryTreeNode: Add type checking for child nodes#1163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
apantzar wants to merge1 commit intotrekhleb:master
base:master
Choose a base branch
Loading
fromapantzar:enhancement/type-checking-binary-tree-node

Conversation

apantzar
Copy link

Summary

This pull request introduces type checking to thesetLeft andsetRight methods of theBinaryTreeNode class. The enhancement ensures that only instances ofBinaryTreeNode can be assigned as children, which prevents potential bugs caused by invalid node assignments.

Changes Made

  • Added type checks tosetLeft andsetRight methods to ensure onlyBinaryTreeNode instances can be set as children.
  • If an invalid node type is provided, an error is thrown to prevent incorrect usage.

Why This Change is Necessary

Type safety is crucial in maintaining the integrity of the binary tree structure. Without these checks, there's a risk of assigning incompatible objects as child nodes, which could lead to unexpected behavior or errors in tree operations.

Impact

These changes should not affect existing functionality but will enhance the robustness of the binary tree implementation.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anandfreshanandfreshanandfresh approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@apantzar@anandfresh

[8]ページ先頭

©2009-2025 Movatter.jp