-
Notifications
You must be signed in to change notification settings - Fork 312
Added Stack data structure in linear data structures #11
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
Conversation
@@ -5,5 +5,6 @@ python: | |||
install: | |||
- pip install -r requirements.txt | |||
script: | |||
- python -m unittest discover pydatastructs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed. The current framework of pydatastructs
uses pytest for testing. Please remove this
This PR looks good. Just do one thing rewrite the tests. Follow the pattern given here in this file. |
.replace("<class '", '', 1)\ | ||
.replace("<type '", '', 1)\ | ||
.replace("'>", '', 1) | ||
_check_type = lambda a, t: isinstance(a, t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import _check_type
from the arrays.py
file.
max_size : int, optional | ||
Maximum size of stack allowed | ||
type_restriction : list, optional | ||
List of types(as strings) for element which can be inserted into Stack, provide empty list for no restrictions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split this line into 2.
>>> my_stack.push(2) | ||
>>> my_stack.pop() | ||
2 | ||
>>> print(my_stack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use print, try using my_stack
directly.
""" | ||
Used for printing | ||
""" | ||
return "<Stack length:{}>".format(str(self.stack)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return the whole stack contents in a standard list format, which can be reused. Something like, return str(self.stack)
.
""" | ||
|
||
def __init__( | ||
self, max_size=10 ** 15, type_restriction=list() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the max size unbounded. We can keep it dependent on the amount of memory available.
Or, otherwise DO NOT make any changes for now, I will make a PR to your branch with the desired modifications. You can merge that PR there and I will merge it here. Thanks. |
Added stack data structure, with appropriate tests written using unittests python testing framework.
References
Stack data structure