example_test.go 890 B

12345678910111213141516171819202122232425262728293031323334
  1. // CookieJar - A contestant's algorithm toolbox
  2. // Copyright (c) 2013 Peter Szilagyi. All rights reserved.
  3. //
  4. // CookieJar is dual licensed: use of this source code is governed by a BSD
  5. // license that can be found in the LICENSE file. Alternatively, the CookieJar
  6. // toolbox may be used in accordance with the terms and conditions contained
  7. // in a signed written agreement between you and the author(s).
  8. package queue_test
  9. import (
  10. "fmt"
  11. "gopkg.in/karalabe/cookiejar.v2/collections/queue"
  12. )
  13. // Simple usage example that inserts the numbers 0, 1, 2 into a queue and then
  14. // removes them one by one, printing them to the standard output.
  15. func Example_usage() {
  16. // Create a queue an push some data in
  17. q := queue.New()
  18. for i := 0; i < 3; i++ {
  19. q.Push(i)
  20. }
  21. // Pop out the queue contents and display them
  22. for !q.Empty() {
  23. fmt.Println(q.Pop())
  24. }
  25. // Output:
  26. // 0
  27. // 1
  28. // 2
  29. }