Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
27
Task/Queue-Definition/Groovy/queue-definition-2.groovy
Normal file
27
Task/Queue-Definition/Groovy/queue-definition-2.groovy
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
def q = new Queue()
|
||||
assert q.empty
|
||||
|
||||
['Crosby', 'Stills'].each { q.push(it) }
|
||||
assert !q.empty
|
||||
['Nash', 'Young'].each { q.enqueue(it) }
|
||||
println q
|
||||
assert !q.empty
|
||||
assert q.pop() == 'Crosby'
|
||||
println q
|
||||
assert !q.empty
|
||||
assert q.dequeue() == 'Stills'
|
||||
println q
|
||||
assert !q.empty
|
||||
assert q.pop() == 'Nash'
|
||||
println q
|
||||
assert !q.empty
|
||||
q.push('Crazy Horse')
|
||||
println q
|
||||
assert q.dequeue() == 'Young'
|
||||
println q
|
||||
assert !q.empty
|
||||
assert q.pop() == 'Crazy Horse'
|
||||
println q
|
||||
assert q.empty
|
||||
try { q.pop() } catch (NoSuchElementException e) { println e }
|
||||
try { q.dequeue() } catch (NoSuchElementException e) { println e }
|
||||
Loading…
Add table
Add a link
Reference in a new issue