Documentation ¶
Index ¶
- type List
- func (l *List[T]) BackNode() *Node[T]
- func (l *List[T]) FrontNode() *Node[T]
- func (l *List[T]) InsertAfter(v T, mark *Node[T]) *Node[T]
- func (l *List[T]) Len() int
- func (l *List[T]) MoveToBack(pre, n *Node[T])
- func (l *List[T]) MoveToFront(pre, n *Node[T])
- func (l *List[T]) PushBack(v T)
- func (l *List[T]) PushFront(v T)
- func (l *List[T]) Remove(pre, n *Node[T]) T
- func (l *List[T]) String() string
- func (l *List[T]) Traversal(visitor visitor.Visitor[T])
- type ListIterator
- func (iter *ListIterator[T]) Clone() iterator.ConstIterator[T]
- func (iter *ListIterator[T]) Equal(other iterator.ConstIterator[T]) bool
- func (iter *ListIterator[T]) IsValid() bool
- func (iter *ListIterator[T]) Next() iterator.ConstIterator[T]
- func (iter *ListIterator[T]) SetValue(value T)
- func (iter *ListIterator[T]) Value() T
- type Node
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type List ¶
List represents a single direction list:
head -> node1 --> node2 --> node3 <- tail
func (*List[T]) FrontNode ¶
FrontNode returns the front node of the list or nil if the list is empty
func (*List[T]) InsertAfter ¶
InsertAfter inserts a new node n with value v immediately after mark and returns n. If mark is not a node of the list, the list is not modified. The mark must not be nil.
func (*List[T]) MoveToBack ¶
MoveToBack moves node n to the back of the list. The n must not be nil.
func (*List[T]) MoveToFront ¶
MoveToFront moves node n to the front of the list. The n must not be nil.
func (*List[T]) PushBack ¶
func (l *List[T]) PushBack(v T)
PushBack inserts a new node n with value v at the back of the list.
func (*List[T]) PushFront ¶
func (l *List[T]) PushFront(v T)
PushFront inserts a new node n with value v at the front of the list.
type ListIterator ¶
type ListIterator[T any] struct { // contains filtered or unexported fields }
ListIterator is an iterator for list
func NewIterator ¶
func NewIterator[T any](node *Node[T]) *ListIterator[T]
NewIterator news a ListIterator
func (*ListIterator[T]) Clone ¶
func (iter *ListIterator[T]) Clone() iterator.ConstIterator[T]
Clone clones iter to a new ListIterator
func (*ListIterator[T]) Equal ¶
func (iter *ListIterator[T]) Equal(other iterator.ConstIterator[T]) bool
Equal returns whether iter is equal to other
func (*ListIterator[T]) IsValid ¶
func (iter *ListIterator[T]) IsValid() bool
IsValid returns whether iter is valid
func (*ListIterator[T]) Next ¶
func (iter *ListIterator[T]) Next() iterator.ConstIterator[T]
Next returns the next iterator
func (*ListIterator[T]) SetValue ¶
func (iter *ListIterator[T]) SetValue(value T)
SetValue sets the value of iter
func (*ListIterator[T]) Value ¶
func (iter *ListIterator[T]) Value() T
Value returns the internal value of iter
type Node ¶
type Node[T any] struct { Value T // contains filtered or unexported fields }
Node is a list node
type Option ¶ added in v1.3.3
type Option func(option *Options)
Option is a function type used to set Options
func WithGoroutineSafe ¶ added in v1.3.3
func WithGoroutineSafe() Option
WithGoroutineSafe is used to set the set goroutine-safe Note that iterators are not goroutine safe, and it is useless to turn on the setting option here. so don't use iterators in multi goroutines