Skip to content
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

Queue implementation #83

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Queue implementation #83

wants to merge 3 commits into from

Conversation

ksetoue
Copy link

@ksetoue ksetoue commented Nov 30, 2021

Hello!

This PR adds an implementation of queue using a IntArray.

It includes:

  • enqueue method
  • dequeue method
  • peek first and last items
  • unit tests for enqueue and dequeue methods

@ksetoue ksetoue changed the title ✨ Add queue implementation using IntArray Queue implementation Nov 30, 2021
Comment on lines +57 to +64
* @returns the first item inserted into the queue as string
*/
fun peekFirst(): String = queue[first].toString()

/**
* @returns the last item inserted into the queue as string
*/
fun peekLast(): String = queue[last].toString()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return the int directly should be better, also care about empty list case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants