Skip to content

Instantly share code, notes, and snippets.

@h0lyalg0rithm
Created April 10, 2014 13:38
Show Gist options
  • Save h0lyalg0rithm/10383189 to your computer and use it in GitHub Desktop.
Save h0lyalg0rithm/10383189 to your computer and use it in GitHub Desktop.
Queues in CoffeeScript
class Queue
constructor:()->
@dataStore = []
enqueue:(element)->
@dataStore.push(element)
dequeue:(element)->
@dataStore.shift()
front:()->
@dataStore[0]
back:()->
@dataStore[@dataStore.length-1]
toString:()->
@dataStore
empty:()->
if @dataStore.length == 0
return true
else
return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment