{"id":24337747,"url":"https://github.com/rogercoding/stack-operations","last_synced_at":"2025-04-14T19:05:59.266Z","repository":{"id":260721297,"uuid":"882165132","full_name":"rogercoding/Stack-Operations","owner":"rogercoding","description":"A stack is a LIFO data structure supporting push (add to top) and pop (remove from top) operations. It includes is_empty to check if empty and peek to view the top item without removal.","archived":false,"fork":false,"pushed_at":"2024-11-02T03:44:10.000Z","size":7,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T06:17:19.613Z","etag":null,"topics":["algorithms","data-structures","open-source","pop-operation","push-operation","python","stacks"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rogercoding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-02T03:39:04.000Z","updated_at":"2025-01-08T17:57:54.000Z","dependencies_parsed_at":"2024-11-02T04:22:59.418Z","dependency_job_id":"5ab4ecf3-b0b7-47a1-b784-023ddc6ceac8","html_url":"https://github.com/rogercoding/Stack-Operations","commit_stats":null,"previous_names":["rogercoding/stack-operations"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogercoding%2FStack-Operations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogercoding%2FStack-Operations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogercoding%2FStack-Operations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogercoding%2FStack-Operations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogercoding","download_url":"https://codeload.github.com/rogercoding/Stack-Operations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243093647,"owners_count":20235415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","data-structures","open-source","pop-operation","push-operation","python","stacks"],"created_at":"2025-01-18T06:17:24.283Z","updated_at":"2025-03-11T18:44:57.909Z","avatar_url":"https://github.com/rogercoding.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stack-Operations\nThe stack implementation in Python utilizes a simple class-based structure that adheres to the Last-In-First-Out (LIFO) principle, where the most recently added item is the first to be removed. This stack is represented by a list, allowing efficient addition and removal of elements from the top of the stack.\n\n### Class and Initialization\nThe `Stack` class begins with an initializer method, `__init__`, which sets up an empty list, `self.stack`. This list represents the stack where items will be added or removed. The initializer ensures that each instance of `Stack` starts with a clean slate, free of any elements.\n\n### Push Operation\nThe `push` method adds an element to the stack by appending it to the end of `self.stack`. Appending to a list in Python is an O(1) operation, making it efficient for this purpose. The method accepts a single parameter, `item`, which is the element to be pushed onto the stack. After appending, a message is printed to confirm the successful addition of the item.\n\n### Pop Operation\nThe `pop` method handles the removal of the top element from the stack. Before attempting to remove an item, it checks if the stack is empty using the `is_empty` helper method. If the stack is not empty, it removes the last item in `self.stack` and returns it, providing a way for external code to access the removed element. If the stack is empty, it displays an error message to indicate that there are no items to pop, returning `None` to handle the edge case gracefully.\n\n### Peek Operation\nThe `peek` method allows users to view the top element without modifying the stack. Similar to `pop`, it first checks if the stack is empty. If not, it returns the last element of `self.stack`. If the stack is empty, it prints a message indicating that there are no items to peek at.\n\n### is_empty Helper Method\nThe `is_empty` method checks if the stack contains any items by evaluating the length of `self.stack`. This method returns a Boolean value, where `True` indicates an empty stack, and `False` indicates otherwise.\n\nOverall, this stack implementation provides a simple, efficient way to perform core stack operations with a clear output for each action, enhancing usability and error handling.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogercoding%2Fstack-operations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogercoding%2Fstack-operations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogercoding%2Fstack-operations/lists"}