basic

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fifo added in v0.1.3

type Fifo[T any] interface {
	Front() T
	PopFront()
	PushBack(v T)
}

type Filo added in v0.1.3

type Filo[T any] interface {
	Back() T
	PopBack()
	PushBack(e T)
}

type List added in v0.1.3

type List[T any] struct {
	// contains filtered or unexported fields
}

func NewList added in v0.1.3

func NewList[T any]() *List[T]

func (*List[T]) Front added in v0.1.3

func (q *List[T]) Front() T

func (*List[T]) PopFront added in v0.1.3

func (q *List[T]) PopFront()

func (*List[T]) PushBack added in v0.1.3

func (q *List[T]) PushBack(e T)

func (*List[T]) Size added in v0.1.3

func (q *List[T]) Size() int

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any](cap int) *Queue[T]

func QueueFrom

func QueueFrom[T any](elems []T) *Queue[T]

func (*Queue[T]) Back added in v0.1.3

func (q *Queue[T]) Back() T

func (*Queue[T]) Clone

func (q *Queue[T]) Clone() []T

func (*Queue[T]) Front added in v0.1.3

func (q *Queue[T]) Front() T

func (*Queue[T]) PopBack added in v0.1.3

func (q *Queue[T]) PopBack()

func (*Queue[T]) PopFront

func (q *Queue[T]) PopFront()

func (*Queue[T]) PushBack

func (q *Queue[T]) PushBack(e T)

func (*Queue[T]) Size

func (q *Queue[T]) Size() int

type Set

type Set[T comparable] map[T]struct{}

func NewSet

func NewSet[T comparable]() Set[T]

func (Set[T]) Add

func (s Set[T]) Add(e T)

func (Set[T]) Clear

func (s Set[T]) Clear()

func (Set[T]) Contains

func (s Set[T]) Contains(e T) bool

func (Set[T]) Drain

func (s Set[T]) Drain() []T

func (Set[T]) Len

func (s Set[T]) Len() int

func (Set[T]) Remove

func (s Set[T]) Remove(e T)

func (Set[T]) TakeOne

func (s Set[T]) TakeOne() T

TakeOne take out an element

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}
Example
testTimes := 100
s := NewStack[int](10)
for i := 0; i < testTimes; i++ {
	s.PushBack(i)
}
for i := 0; i < testTimes; i++ {
	e := s.Back()
	s.PopBack()
	fmt.Print(e, " ")
}

func NewStack

func NewStack[T any](c int) *Stack[T]

func NewStackFrom added in v0.1.3

func NewStackFrom[T any](elems []T) *Stack[T]

func (*Stack[T]) Back added in v0.1.3

func (s *Stack[T]) Back() T

func (*Stack[T]) Cap

func (s *Stack[T]) Cap() int

func (*Stack[T]) Find added in v0.1.3

func (s *Stack[T]) Find(fn func(T) bool) int

func (*Stack[T]) IterRange added in v0.1.3

func (s *Stack[T]) IterRange(src, dst int, fn func(T) bool)

func (*Stack[T]) Iterate

func (s *Stack[T]) Iterate(popOrd bool, fn func(T) bool)

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() T

func (*Stack[T]) PeekAt added in v0.1.3

func (s *Stack[T]) PeekAt(i int) T

func (*Stack[T]) PopBack added in v0.1.3

func (s *Stack[T]) PopBack()

func (*Stack[T]) PushBack added in v0.1.3

func (s *Stack[T]) PushBack(e T)

func (*Stack[T]) Reverse

func (s *Stack[T]) Reverse()

func (*Stack[T]) Size

func (s *Stack[T]) Size() int

func (*Stack[T]) String

func (s *Stack[T]) String() string

func (*Stack[T]) ToSlice added in v0.1.3

func (s *Stack[T]) ToSlice() []T

type StackCmp

type StackCmp[T comparable] struct {
	Stack[T]
}

func NewStackCmp

func NewStackCmp[T comparable](c int) *StackCmp[T]

func (*StackCmp[T]) Find added in v0.1.3

func (s *StackCmp[T]) Find(e T) int

type UnionFind

type UnionFind struct {
	// contains filtered or unexported fields
}

func NewUnionFind

func NewUnionFind(numV int) *UnionFind

func (*UnionFind) Find

func (uf *UnionFind) Find(v int) int

func (*UnionFind) IsConnected

func (uf *UnionFind) IsConnected(v1, v2 int) bool

func (*UnionFind) NumConnectedComponent

func (uf *UnionFind) NumConnectedComponent() int

func (*UnionFind) Union

func (uf *UnionFind) Union(v1, v2 int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL