zbcont

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2009 The Go Authors. All rights reserved. c++ stl style list<> container ,written by andrew.zhang in 2018.10

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arg

type Arg[K, V any] struct {
	K K
	V V
}

func NewArg

func NewArg[K, V any](k K, v V) Arg[K, V]

type IntFun

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

---------------------------------------

func (*IntFun) Key

func (e *IntFun) Key() int64

func (*IntFun) SetValue

func (e *IntFun) SetValue(fun func())

func (*IntFun) Value

func (e *IntFun) Value() func()

type IterLst

type IterLst[V any] struct {
	// contains filtered or unexported fields
}

IterLst is an element of a linked list.

func (*IterLst[V]) Among

func (e *IterLst[V]) Among(l *List[V]) bool

func (*IterLst[V]) InAny

func (e *IterLst[V]) InAny() bool

func (*IterLst[V]) Next

func (e *IterLst[V]) Next() *IterLst[V]

Next returns the next list element or nil.

func (*IterLst[V]) Prev

func (e *IterLst[V]) Prev() *IterLst[V]

Prev returns the previous list element or nil.

func (*IterLst[V]) Value

func (e *IterLst[V]) Value() V

type List

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

List represents a doubly linked list. The zero value for List is an empty list ready to use.

func New

func New[V any]() *List[V]

New returns an initialized list.

func (*List[V]) Begin

func (l *List[V]) Begin() *IterLst[V]

Front returns the first element of list l or nil.

func (*List[V]) Clear

func (l *List[V]) Clear()

带有Init()作用

func (*List[V]) Empty

func (l *List[V]) Empty() bool

func (*List[V]) End

func (l *List[V]) End() *IterLst[V]

func (*List[V]) Erase

func (l *List[V]) Erase(e *IterLst[V]) V

Remove removes e from l if e is an element of list l. It returns the element value e.value.

func (*List[V]) Init

func (l *List[V]) Init() *List[V]

Init initializes or clears list l.

func (*List[V]) InsertAfter

func (l *List[V]) InsertAfter(v V, mark *IterLst[V]) *IterLst[V]

InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified.

func (*List[V]) InsertBefore

func (l *List[V]) InsertBefore(v V, mark *IterLst[V]) *IterLst[V]

InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified.

func (*List[V]) Len

func (l *List[V]) Len() int

Len returns the number of elements of list l. The complexity is O(1).

func (*List[V]) MoveAfter

func (l *List[V]) MoveAfter(e, mark *IterLst[V])

MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified.

func (*List[V]) MoveBefore

func (l *List[V]) MoveBefore(e, mark *IterLst[V])

MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified.

func (*List[V]) MoveToBack

func (l *List[V]) MoveToBack(e *IterLst[V])

MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified.

func (*List[V]) MoveToFront

func (l *List[V]) MoveToFront(e *IterLst[V])

MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified.

func (*List[V]) PushBack

func (l *List[V]) PushBack(v V) *IterLst[V]

PushBack inserts a new element e with value v at the back of list l and returns e.

func (*List[V]) PushBackList

func (l *List[V]) PushBackList(other *List[V])

PushBackList inserts a copy of an other list at the back of list l. The lists l and other may be the same.

func (*List[V]) PushFront

func (l *List[V]) PushFront(v V) *IterLst[V]

PushFront inserts a new element e with value v at the front of list l and returns e.

func (*List[V]) PushFrontList

func (l *List[V]) PushFrontList(other *List[V])

PushFrontList inserts a copy of an other list at the front of list l. The lists l and other may be the same.

func (*List[V]) RBegin

func (l *List[V]) RBegin() *IterLst[V]

Back returns the last element of list l or nil.

func (*List[V]) REnd

func (l *List[V]) REnd() *IterLst[V]

type ListIntFun

type ListIntFun struct {
	List[IntFun]
}

type RBtrIstr

type RBtrIstr[V any] struct {
	RBtree[string, V]
}

----------------------------------------------------------- class RBtrIstr

RBtrIstr Key字符串不区分大小写

func NewRBtrIstr

func NewRBtrIstr[V any](canRepeat bool, initargs ...Arg[string, V]) *RBtrIstr[V]

func (*RBtrIstr[V]) Duplicate

func (this *RBtrIstr[V]) Duplicate(deep int) any

type RBtrStr

type RBtrStr[V any] struct {
	RBtree[string, V]
}

func NewRBtrStr

func NewRBtrStr[V any](canRepeat bool, initargs ...Arg[string, V]) *RBtrStr[V]

func (*RBtrStr[V]) Duplicate

func (this *RBtrStr[V]) Duplicate(deep int) any

type RBtree

type RBtree[K, V any] struct {
	// contains filtered or unexported fields
}

func NewRBtree

func NewRBtree[K, V any](canRepeat bool, compfunc func(key1, key2 K) int, initargs ...Arg[K, V]) *RBtree[K, V]

func (*RBtree[K, V]) Append

func (this *RBtree[K, V]) Append(begin, end RBtreeIter[K, V], deep int, iterfunc func(newit RBtreeIter[K, V]))

func (*RBtree[K, V]) Begin

func (this *RBtree[K, V]) Begin() RBtreeIter[K, V]

func (*RBtree[K, V]) Between1

func (this *RBtree[K, V]) Between1(key1, key2 K) (lower, upper RBtreeIter[K, V])

Between1 return x>=key1 && x<key2

func (*RBtree[K, V]) Between2

func (this *RBtree[K, V]) Between2(key1, key2 K) (lower, upper RBtreeIter[K, V])

Between2 return x>=key1 && x<=key2

func (*RBtree[K, V]) Between3

func (this *RBtree[K, V]) Between3(key1, key2 K) (lower, upper RBtreeIter[K, V])

Between3 return x>key1 && x<key2

func (*RBtree[K, V]) Between4

func (this *RBtree[K, V]) Between4(key1, key2 K) (lower, upper RBtreeIter[K, V])

return x>key1 && x<=key2

func (*RBtree[K, V]) Clear

func (this *RBtree[K, V]) Clear(deep int)

func (*RBtree[K, V]) Duplicate

func (this *RBtree[K, V]) Duplicate(deep int) any

func (*RBtree[K, V]) Empty

func (this *RBtree[K, V]) Empty() bool

func (*RBtree[K, V]) End

func (this *RBtree[K, V]) End() RBtreeIter[K, V]

func (*RBtree[K, V]) EqualBound

func (this *RBtree[K, V]) EqualBound(key K) (lower, upper RBtreeIter[K, V])

func (*RBtree[K, V]) Erase

func (this *RBtree[K, V]) Erase(it RBtreeIter[K, V])

func (*RBtree[K, V]) Find

func (this *RBtree[K, V]) Find(key K) RBtreeIter[K, V]

func (*RBtree[K, V]) GetCompFunc

func (this *RBtree[K, V]) GetCompFunc() func(key1, key2 K) int

func (*RBtree[K, V]) Index

func (this *RBtree[K, V]) Index(key K) (val RBtreeIter[K, V], found bool)

func (*RBtree[K, V]) Insert

func (this *RBtree[K, V]) Insert(key K, value V) (sucs bool, it RBtreeIter[K, V])

func (*RBtree[K, V]) IsAmong

func (this *RBtree[K, V]) IsAmong(key K) (found bool)

func (*RBtree[K, V]) LeftIterate

func (this *RBtree[K, V]) LeftIterate(iterfunc func(it RBtreeIter[K, V]) (isbreak bool)) (isbreak bool)

func (*RBtree[K, V]) Len

func (this *RBtree[K, V]) Len() int

func (*RBtree[K, V]) LowerBound

func (this *RBtree[K, V]) LowerBound(key K) RBtreeIter[K, V]

func (*RBtree[K, V]) MidIterate

func (this *RBtree[K, V]) MidIterate(iterfunc func(it RBtreeIter[K, V]) (isbreak bool)) (isbreak bool)

func (*RBtree[K, V]) Move

func (this *RBtree[K, V]) Move(_Right RBtree[K, V])

func (*RBtree[K, V]) RBegin

func (this *RBtree[K, V]) RBegin() RBtreeIter[K, V]

反向遍历获取Begin迭代器

func (*RBtree[K, V]) REnd

func (this *RBtree[K, V]) REnd() RBtreeIter[K, V]

func (*RBtree[K, V]) Remove

func (this *RBtree[K, V]) Remove(key K) int

func (*RBtree[K, V]) RightIterate

func (this *RBtree[K, V]) RightIterate(iterfunc func(it RBtreeIter[K, V]) (isbreak bool)) (isbreak bool)

func (*RBtree[K, V]) Size

func (this *RBtree[K, V]) Size() int

func (*RBtree[K, V]) String

func (this *RBtree[K, V]) String() string

func (*RBtree[K, V]) UpperBound

func (this *RBtree[K, V]) UpperBound(key K) RBtreeIter[K, V]

type RBtreeIter

type RBtreeIter[K, V any] struct {
	// contains filtered or unexported fields
}

func (RBtreeIter[K, V]) Key

func (this RBtreeIter[K, V]) Key() K

func (RBtreeIter[K, V]) Next

func (this RBtreeIter[K, V]) Next() RBtreeIter[K, V]

func (RBtreeIter[K, V]) Prev

func (this RBtreeIter[K, V]) Prev() RBtreeIter[K, V]

func (RBtreeIter[K, V]) SetValue

func (this RBtreeIter[K, V]) SetValue(val V)

func (RBtreeIter[K, V]) Value

func (this RBtreeIter[K, V]) Value() V

type RBtreeKn

type RBtreeKn[K zbcmn.Real, V any] struct {
	RBtree[K, V]
}

----------------------------------------------------------- class RBtreeKn,从小到大排序红黑树

func NewRBtreeKn

func NewRBtreeKn[K zbcmn.Real, V any](canRepeat bool, initargs ...Arg[K, V]) *RBtreeKn[K, V]

func (*RBtreeKn[K, V]) Duplicate

func (this *RBtreeKn[K, V]) Duplicate(deep int) any

type RBtreeRkn

type RBtreeRkn[K zbcmn.Real, V any] struct {
	RBtree[K, V]
}

----------------------------------------------------------- class RBtreeKn,反向从大到小排序红黑树

func NewRBtreeRkn

func NewRBtreeRkn[K zbcmn.Real, V any](canRepeat bool, initargs ...Arg[K, V]) *RBtreeRkn[K, V]

func (*RBtreeRkn[K, V]) Duplicate

func (this *RBtreeRkn[K, V]) Duplicate(deep int) any

Jump to

Keyboard shortcuts

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