-
Notifications
You must be signed in to change notification settings - Fork 42
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
Niv #19
base: master
Are you sure you want to change the base?
Niv #19
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
class Queue | ||
|
||
def initialize | ||
# @store = ... | ||
raise NotImplementedError, "Not yet implemented" | ||
@store = [] | ||
end | ||
|
||
def enqueue(element) | ||
raise NotImplementedError, "Not yet implemented" | ||
@store.push(element) | ||
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. This isn't using a circular buffer, it works, but not what I requested. |
||
end | ||
|
||
def dequeue | ||
raise NotImplementedError, "Not yet implemented" | ||
removed = @store[0] | ||
@store = @store[1..-1] | ||
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. Just a note, |
||
return removed | ||
end | ||
|
||
def front | ||
raise NotImplementedError, "Not yet implemented" | ||
return @store[0] | ||
end | ||
|
||
def size | ||
raise NotImplementedError, "Not yet implemented" | ||
return @store.length | ||
end | ||
|
||
def empty? | ||
raise NotImplementedError, "Not yet implemented" | ||
if @store.length > 0 | ||
return false | ||
else | ||
return true | ||
end | ||
end | ||
|
||
def to_s | ||
|
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.
Great use of a hash!