Skip to content

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.

2 participants