Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework on Stack Array Data Structure #2683

Merged
merged 14 commits into from
Sep 1, 2024

Conversation

sozelfist
Copy link
Contributor

@sozelfist sozelfist commented Mar 18, 2024

What I have done in this PR:

  • Reorganize code in data_structure namespace and Stack class
  • The destructor is added to the Stack class to ensure memory deallocation
  • Comments are added to the member functions to describe their purpose
  • The self-test function is provided, which demonstrates the usage of the Stack class and its methods.

Description of Change

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:

- The `Stack` class is placed within the `data_structures` namespace
- The destructor is added to the Stack class to ensure memory deallocation
- Comments are added to the member functions to describe their purpose
- The self-test function is provided, which demonstrates the usage of the Stack class
@sozelfist
Copy link
Contributor Author

Please take a look on this PR @realstealthninja, @Panquesito7

Copy link
Contributor

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Author has not responded to the comments for over 2 weeks label Apr 19, 2024
@sozelfist
Copy link
Contributor Author

Could you have a look on this PR @realstealthninja

Copy link

@mrmagic2020 mrmagic2020 left a comment

Choose a reason for hiding this comment

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

Both maintainers of this repo are rather busy these days, so I'll do a quick review.
Very solid rework and documentation. Have you considered adding methods like empty() and full()? They might help client code to handle these cases before operations like pop() and push().
Overall I think this is merge-worthy. Up to the maintainers to make further decision :)

@sozelfist
Copy link
Contributor Author

sozelfist commented Apr 30, 2024

Can you add don't-close label for this PR, @mrmagic2020?

@mrmagic2020
Copy link

mrmagic2020 commented Apr 30, 2024

Can you add don't-close label for this PR, @mrmagic2020?

Sorry, I don't have write access to this repo... you still need to wait for the maintainers

@github-actions github-actions bot removed the stale Author has not responded to the comments for over 2 weeks label Jul 26, 2024
Copy link
Contributor

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Author has not responded to the comments for over 2 weeks label Aug 25, 2024
Copy link
Collaborator

@realstealthninja realstealthninja left a comment

Choose a reason for hiding this comment

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

Very lovely contribution. Other than some technical assumptions being wrong. This is a great implementation. I would recommend using TOS instead of stack index. The bottom is unnecessary imo since stack follows lifo principle

data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
data_structures/stack_using_array.cpp Show resolved Hide resolved
data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
@realstealthninja realstealthninja added Improvement improvement in previously written codes dont-close This issue/pull request shouldn't be closed awaiting modification Do not merge until modifications are made and removed stale Author has not responded to the comments for over 2 weeks dont-close This issue/pull request shouldn't be closed labels Aug 26, 2024
sozelfist and others added 2 commits August 31, 2024 09:28
- Use TOS instead of stack index
- Add tests for overflow and underflow
@sozelfist
Copy link
Contributor Author

Thanks, @realstealthninja. Can you have a look?

data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
@sozelfist
Copy link
Contributor Author

Thanks for the quick fixes.

@realstealthninja
Copy link
Collaborator

@TruongNhanNguyen could you delete the stack.hpp file from that directory as well? thanks.

@realstealthninja
Copy link
Collaborator

On second thought revert that, we can do that in another pr. Sorry for the confusion. The stack.hpp problem seems out of the scope of this pr

data_structures/stack_using_array.cpp Show resolved Hide resolved
Copy link
Collaborator

@realstealthninja realstealthninja left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! ❤️

@sozelfist
Copy link
Contributor Author

Thanks for kindly reviews, and quick responses. This PR existed for a long time, so I am delighted to see it merged.

@realstealthninja realstealthninja added 1st Review: Passed and removed awaiting modification Do not merge until modifications are made labels Aug 31, 2024
Copy link
Collaborator

@realstealthninja realstealthninja left a comment

Choose a reason for hiding this comment

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

Commit this the most recent push must be done by you

data_structures/stack_using_array.cpp Outdated Show resolved Hide resolved
@realstealthninja
Copy link
Collaborator

Merging this! thanks for your contribution ❤️

@realstealthninja realstealthninja merged commit 54a20b4 into TheAlgorithms:master Sep 1, 2024
6 checks passed
@sozelfist sozelfist deleted the ds/stack branch September 1, 2024 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1st Review: Passed Improvement improvement in previously written codes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants