Documentation ¶
Overview ¶
Package inlist implements an intrusive doubly linked list.
To iterate over a list (where l is a *List):
for e := l.Front(); e != nil; e = e.Next() { // do something with e }
修改了部分接口,以便和标准的一致 只有MoveFrontList和MoveBackList和标准不一样,因为标准是拷贝,这里是移动合并 增加PopFront和PopBack接口
Index ¶
- func Value(i Intrusive) interface{}
- type Element
- type Hook
- type Intrusive
- type List
- func (l *List) Back() Intrusive
- func (l *List) Front() Intrusive
- func (l *List) Init() *List
- func (l *List) InsertAfter(e Intrusive, mark Intrusive) Intrusive
- func (l *List) InsertBefore(e Intrusive, mark Intrusive) Intrusive
- func (l *List) Len() int
- func (l *List) MoveAfter(e, mark Intrusive)
- func (l *List) MoveBackList(other *List)
- func (l *List) MoveBefore(e, mark Intrusive)
- func (l *List) MoveFrontList(other *List)
- func (l *List) MoveToBack(e Intrusive)
- func (l *List) MoveToFront(e Intrusive)
- func (l *List) PopBack() Intrusive
- func (l *List) PopFront() Intrusive
- func (l *List) PushBack(e Intrusive) Intrusive
- func (l *List) PushFront(e Intrusive) Intrusive
- func (l *List) Remove(e Intrusive) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Intrusive ¶
type Intrusive interface { Prev() Intrusive Next() Intrusive List() *List // contains filtered or unexported methods }
Intrusive interface of Element
func NewElement ¶
func NewElement(v interface{}) Intrusive
NewElement creates an intrusive Element to store the passed value.
type List ¶
type List struct {
// contains filtered or unexported fields
}
func (*List) InsertAfter ¶
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. The mark must not be nil.
func (*List) InsertBefore ¶
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. The mark must not be nil.
func (*List) MoveAfter ¶
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. The element and mark must not be nil.
func (*List) MoveBackList ¶
MoveBackList moves all elements from other to the end of this list. diff with MoveBackList, because that is copy, here is move
func (*List) MoveBefore ¶
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. The element and mark must not be nil.
func (*List) MoveFrontList ¶
MoveFrontList moves all elements from other to the front of this list. diff with PushFrontList, because that is copy, here is move
func (*List) MoveToBack ¶
MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*List) MoveToFront ¶
MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*List) PushBack ¶
PushBack inserts a new element e with value v at the back of list l and returns e.