Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GQueue ¶
type GQueue[T any] struct { // contains filtered or unexported fields }
GQueue is generic Queue implementation using linked list
Example ¶
package main import ( "fmt" "github.com/sv-tools/gqueue" ) func main() { s := gqueue.New(1, 2, 3, 4) fmt.Println(s.Len()) fmt.Println(s.Pop()) fmt.Println(s.Pop()) fmt.Println(s.Pop()) fmt.Println(s.Pop()) s.Push(5) fmt.Println(s.Peek()) }
Output: 4 1 2 3 4 5
func (*GQueue[T]) Iter ¶ added in v1.0.0
Iter returns a consuming iterator for the queue
Example ¶
package main import ( "fmt" "github.com/sv-tools/gqueue" ) func main() { s := gqueue.New(1, 2, 3, 4) for v := range s.Iter() { fmt.Println(v) } fmt.Println("len:", s.Len()) }
Output: 1 2 3 4 len: 0
func (*GQueue[T]) Peek ¶
func (s *GQueue[T]) Peek() T
Peek returns the first item without removing it or a zero object of given type
Click to show internal directories.
Click to hide internal directories.