mirror of https://github.com/emirpasic/gods
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
764 B
Go
24 lines
764 B
Go
// Copyright (c) 2015, Emir Pasic. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
import llq "github.com/emirpasic/gods/v2/queues/linkedlistqueue"
|
|
|
|
// LinkedListQueueExample to demonstrate basic usage of LinkedListQueue
|
|
func main() {
|
|
queue := llq.New[int]() // empty
|
|
queue.Enqueue(1) // 1
|
|
queue.Enqueue(2) // 1, 2
|
|
_ = queue.Values() // 1, 2 (FIFO order)
|
|
_, _ = queue.Peek() // 1,true
|
|
_, _ = queue.Dequeue() // 1, true
|
|
_, _ = queue.Dequeue() // 2, true
|
|
_, _ = queue.Dequeue() // nil, false (nothing to deque)
|
|
queue.Enqueue(1) // 1
|
|
queue.Clear() // empty
|
|
queue.Empty() // true
|
|
_ = queue.Size() // 0
|
|
}
|