tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 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