Skip to content

Instantly share code, notes, and snippets.

@jay3ss
Created Jun 15, 2019
Embed
What would you like to do?
import abc
class StackInterface(abc.ABC):
"""An abstract base class that defines a stack"""
@abc.abstractmethod
def is_empty(self):
"""Determines if the stack is empty
:return True if the stack is empty, False otherwise
"""
pass
@abc.abstractmethod
def peek(self):
"""Returns the top of the stack
:pre The stack isn't empty
:return The entry at the top of the stack
"""
pass
@abc.abstractmethod
def pop(self):
"""Removes the entry from the top of the stack
:post The entry at the top of the stack will be removed, if possible
:return True if removal was successful, False otherwise
"""
pass
@abc.abstractmethod
def push(self, entry):
"""Adds an entry to the top of the stack
:post The entry will be added to the top of the stack, if possible
:return True if addition was successful, False otherwise
"""
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment