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

Please accept the pull request I had done some changes in the codes of stack #192

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Mar 10, 2021

  1. Configuration menu
    Copy the full SHA
    799b346 View commit details
    Browse the repository at this point in the history
  2. We should use Deque instead of Stack because

    it's more sensible in terms of inheritance. The fact that Stack extends Vector is really strange.Early in Java, inheritance was overused IMO - Properties being another example.
    
    Deque exposes a set of operations which is all about being able to fetch/add/remove items from the start or end of a collection, iterate etc - and that's it. There's deliberately no way to access an element by position, which Stack exposes because it's a subclass of Vector.
    
    Oh, and also Stack has no interface, so if you know you need Stack operations you end up committing to a specific concrete class, which isn't usually a good idea.
    
    And earlier r.peek()<temp was sorting the stack in descending order so I had changed it to r.peek()>temp now it is sorting a stack in ascending order
    TanyaAgarwal28 committed Mar 10, 2021
    Configuration menu
    Copy the full SHA
    b5dc956 View commit details
    Browse the repository at this point in the history