Documentation
¶
Index ¶
- type List
- func (l *List) Back() interface{}
- func (l *List) BackNode() *Node
- func (l *List) Clear()
- func (l *List) Empty() bool
- func (l *List) Front() interface{}
- func (l *List) FrontNode() *Node
- func (l *List) InsertAfter(v interface{}, mark *Node) *Node
- func (l *List) InsertBefore(v interface{}, mark *Node) *Node
- func (l *List) Len() int
- func (l *List) MoveAfter(n, mark *Node)
- func (l *List) MoveToBack(n *Node)
- func (l *List) MoveToFront(n *Node)
- func (l *List) PopBack() interface{}
- func (l *List) PopFront() interface{}
- func (l *List) PushBack(v interface{})
- func (l *List) PushBackList(other *List)
- func (l *List) PushFront(v interface{})
- func (l *List) PushFrontList(other *List)
- func (l *List) Remove(n *Node) interface{}
- func (l *List) Size() int
- func (l *List) String() string
- func (l *List) Traversal(visitor visitor.Visitor)
- type ListIterator
- func (iter *ListIterator) Clone() iterator.ConstIterator
- func (iter *ListIterator) Equal(other iterator.ConstIterator) bool
- func (iter *ListIterator) IsValid() bool
- func (iter *ListIterator) Next() iterator.ConstIterator
- func (iter *ListIterator) Prev() iterator.ConstBidIterator
- func (iter *ListIterator) SetValue(value interface{})
- func (iter *ListIterator) Value() interface{}
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
List represents a bidirectional list:
head -> node1 -- node2 -- node3 | | node6 -- node5 -- node4
func (*List) InsertAfter ¶
InsertAfter inserts a new node n with value v immediately after mark and returns n. If mark is not a node of l list, the list is not modified. The mark must not be nil.
func (*List) InsertBefore ¶
InsertBefore inserts a new node n with value v immediately before mark and returns n. If mark is not a node of l list, the list is not modified. The mark must not be nil.
func (*List) MoveAfter ¶
MoveAfter moves node n to its new position after mark. If n or mark is not a node of the list, or n == mark, the list is not modified. The node and mark must not be nil.
func (*List) MoveToBack ¶
MoveToBack moves node n to the back of the list. If e is not a node of the list, the list is not modified. The node must not be nil.
func (*List) MoveToFront ¶
MoveToFront moves node n to the front of the list. If n is not a node of the list, the list is not modified. The n must not be nil.
func (*List) PopBack ¶
func (l *List) PopBack() interface{}
PopBack removes the last node in the list and returns its value
func (*List) PopFront ¶
func (l *List) PopFront() interface{}
PopFront removes the first node in the list and returns its value
func (*List) PushBack ¶
func (l *List) PushBack(v interface{})
PushBack inserts a new node n with value v at the back of the list
func (*List) PushBackList ¶
PushBackList inserts a copy of an other list at the back of the list. The list and other may be the same. They must not be nil.
func (*List) PushFront ¶
func (l *List) PushFront(v interface{})
PushFront inserts a new node n with value v at the front of the list.
func (*List) PushFrontList ¶
PushFrontList inserts a copy of an other list at the front of the list. The list and other may be the same. They must not be nil.
func (*List) Remove ¶
Remove removes n from l list if n is a node of l list. It returns the n value n.Value. The node must not be nil.
type ListIterator ¶
type ListIterator struct {
// contains filtered or unexported fields
}
ListIterator is an implementation of list iterator
func (*ListIterator) Clone ¶
func (iter *ListIterator) Clone() iterator.ConstIterator
Clone clones the iterator to a new iterator
func (*ListIterator) Equal ¶
func (iter *ListIterator) Equal(other iterator.ConstIterator) bool
Equal returns true if the iterator is equal to the passed iterator, otherwise returns false
func (*ListIterator) IsValid ¶
func (iter *ListIterator) IsValid() bool
IsValid returns true if the iterator is valid, otherwise returns false
func (*ListIterator) Next ¶
func (iter *ListIterator) Next() iterator.ConstIterator
Next moves the pointer of iterator to the next node and returns itself
func (*ListIterator) Prev ¶
func (iter *ListIterator) Prev() iterator.ConstBidIterator
Prev moves the pointer of iterator to the previous node and returns itself
func (*ListIterator) SetValue ¶
func (iter *ListIterator) SetValue(value interface{})
SetValue sets the node's value of the iterator point to
func (*ListIterator) Value ¶
func (iter *ListIterator) Value() interface{}
Value returns the node's value of the iterator point to