forked from AdaGold/stacks-queues
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Sara - Branches #35
Open
sarashahbaig
wants to merge
7
commits into
Ada-C12:master
Choose a base branch
from
sarashahbaig:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sara - Branches #35
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ecc712e
completed stacks
sarashahbaig c315c60
Merge branch 'master' of https://github.com/Ada-C12/stacks-queues
sarashahbaig b1bd7b3
completed wave 1
sarashahbaig 6dbb5b5
edited code
sarashahbaig 3aa7717
edited test code
sarashahbaig 57afe9b
removed unwanted code
sarashahbaig 3ae4c28
edited code
sarashahbaig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,61 @@ | ||
# Wave 2 | ||
# require_relative './stack.rb' | ||
require "./linked_list" | ||
|
||
class Queue | ||
|
||
def initialize | ||
# @store = ... | ||
raise NotImplementedError, "Not yet implemented" | ||
@store = LinkedList.new | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These work, but using a LinkedList wasn't the assignment. |
||
@front = @back = -1 | ||
# @front = -1 | ||
# @back = -1 | ||
end | ||
|
||
def enqueue(element) | ||
raise NotImplementedError, "Not yet implemented" | ||
if @front == -1 && @back == -1 | ||
@front = 0 | ||
@back = 1 | ||
end | ||
|
||
if @front == @back | ||
raise ArgumentError.new("Error") | ||
end | ||
|
||
return @store.add_last(element) | ||
|
||
end | ||
|
||
def dequeue | ||
raise NotImplementedError, "Not yet implemented" | ||
# if @front == -1 && @back == -1 | ||
# @front = 0 | ||
# @back = 1 | ||
# end | ||
|
||
if @store.length > 0 | ||
return @store.remove_first() | ||
end | ||
|
||
# puts @store | ||
# puts @front | ||
# puts @back | ||
|
||
end | ||
|
||
def front | ||
raise NotImplementedError, "Not yet implemented" | ||
# raise NotImplementedError, "Not yet implemented" | ||
return @store.get_first() | ||
end | ||
|
||
def size | ||
raise NotImplementedError, "Not yet implemented" | ||
# raise NotImplementedError, "Not yet implemented" | ||
return @store.length | ||
end | ||
|
||
def empty? | ||
raise NotImplementedError, "Not yet implemented" | ||
# raise NotImplementedError, "Not yet implemented" | ||
# return true if @front == @back | ||
return @store.empty? | ||
|
||
end | ||
|
||
def to_s | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should be a require_relative, although you don't need a linked list in this class for the assignment.