-
Notifications
You must be signed in to change notification settings - Fork 312
Linked list stack implemented #139
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
Linked list stack implemented #139
Conversation
Added new line at the end Co-Authored-By: Gagandeep Singh <gdp.1807@gmail.com>
Co-Authored-By: Gagandeep Singh <gdp.1807@gmail.com>
Co-Authored-By: Gagandeep Singh <gdp.1807@gmail.com>
Co-Authored-By: Gagandeep Singh <gdp.1807@gmail.com>
Co-Authored-By: Gagandeep Singh <gdp.1807@gmail.com>
Co-Authored-By: Gagandeep Singh <gdp.1807@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #139 +/- ##
=============================================
- Coverage 98.173% 98.042% -0.131%
=============================================
Files 21 21
Lines 1588 1635 +47
=============================================
+ Hits 1559 1603 +44
- Misses 29 32 +3
|
Can you please merge the latest |
obj.front = obj.stack.head | ||
obj.tail = obj.stack.tail |
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.
IMO, only obj.top
should suffice and that too as a @property
and not as a separate attribute.
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.
Agreed
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.
peek property is essentially doing the same.
else: | ||
raise TypeError("Expected type: list/tuple") |
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.
Please do input filtering at the entry point of a function/method.
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.
I moved refactored the new method, check it its good enough
else: | ||
raise TypeError("Expected %s but got %s"%(obj._dtype, type(x))) |
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.
+1
def is_empty(self): | ||
return self.size == 0 |
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.
Can we use, self.top
here to figure out whether the stack is empty?
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.
It will lose consistency with LinkedListQueue if i change it.
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.
It looks like that LinkedListQueue
needs some changes in it's __new__
method. Can you please address similar comments there as well.
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.
Sure will solve it in different PR.
pydatastructs/trees/heaps.py
Outdated
else: | ||
if not all(map(lambda x: _check_type(x, TreeNode), elements)): | ||
raise ValueError("Expect a list/tuple of TreeNode got %s"%(elements)) |
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.
Master should be merged as these changes are already there.
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.
thats a mess, I will remove them
non_TreeNode_elements = [ | ||
(7, 7), TreeNode(25, 25), TreeNode(100, 100), | ||
TreeNode(1, 1), (2, 2), TreeNode(3, 3), | ||
TreeNode(17, 17), TreeNode(19, 19), TreeNode(36, 36) | ||
] | ||
assert raises(ValueError, lambda: | ||
BinaryHeap(elements = non_TreeNode_elements, heap_property='min')) |
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.
+1
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.
it broke the code when i removed those 2 files, idk why it is still showing up, any suggestions?
Please resolve the conflicts. |
if len(items) != 0 and dtype is NoneType: | ||
obj._dtype = type(items[0]) | ||
for x in items: | ||
if type(x) == obj._dtype: |
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.
Is it possible to use _check_type
from misc_utils.py
here?
I just observed that some changes are needed in |
This PR has already very messy, I will fork it again and make a bit better one. Just started using git for big projects, sorry for making a mess. |
shall I create 2 different PRs one for queue and one for stack? |
If you are going to close it then first make a PR for fixing |
References to other Issues or PRs or Relevant literature
Fixes #113
Brief description of what is fixed or changed
LinkedListStack implemented with relevant tests
Other comments