Documentation ¶
Index ¶
- type Element
- type Elementer
- type List
- func (l *List) Back() Elementer
- func (l *List) FindElementBackward(start, end Elementer, finder func(e Elementer) (didFind bool)) (found Elementer)
- func (l *List) FindElementForward(start, end Elementer, finder func(e Elementer) (didFind bool)) (found Elementer)
- func (l *List) Front() Elementer
- func (l *List) Init() *List
- func (l *List) InsertAfter(e Elementer, mark Elementer) Elementer
- func (l *List) InsertBefore(e Elementer, mark Elementer) Elementer
- func (l *List) IsSentinel(e Elementer) bool
- func (l *List) Len() int
- func (l *List) MoveAfter(e, mark Elementer)
- func (l *List) MoveBefore(e, mark Elementer)
- func (l *List) MoveToBack(e Elementer)
- func (l *List) MoveToFront(e Elementer)
- func (l *List) PushBack(e Elementer) Elementer
- func (l *List) PushFront(e Elementer) Elementer
- func (l *List) Remove(e Elementer) Elementer
- func (l *List) Replace(e, mark Elementer) Elementer
- type Sentinel
- func (s *Sentinel) List() *List
- func (s *Sentinel) Next() Elementer
- func (s *Sentinel) Prev() Elementer
- func (s *Sentinel) SetList(l *List) (oldList *List)
- func (s *Sentinel) SetNext(e Elementer) (oldElement Elementer)
- func (s *Sentinel) SetPrev(e Elementer) (oldElement Elementer)
- func (s *Sentinel) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct { Sentinel Value interface{} }
Element allow one to use a list with a generic element.
func NewElement ¶
func NewElement(v interface{}) *Element
func SliceOfElements ¶
func SliceOfElements(vals ...interface{}) []*Element
type Elementer ¶
type Elementer interface { // Prev returns the previous list element or nil. Prev() Elementer // Next returns the next list element or nil Next() Elementer // SetNext will set this list element next element to the provided element, and return the element or nil that was point to before. // SetNext does not call SetPrev. SetNext(n Elementer) Elementer // SetPrev will set this list element's prev element to the provided element, if // SetPrev does not call SetNext. SetPrev(n Elementer) Elementer // List is the list this Node belongs to. List() *List // SetList set the list this node should belong to; should return the old list or nil if it does not belong to a list. SetList(l *List) *List }
type List ¶
type List struct {
// contains filtered or unexported fields
}
func (*List) FindElementBackward ¶
func (l *List) FindElementBackward(start, end Elementer, finder func(e Elementer) (didFind bool)) (found Elementer)
FindElementBackward will start at the start elemente working it's way backwards to the end element (or back to the sentinel element of the list if nil is provided) calling the match function. It returns the element that was found or nil if it did not find any element. Both start and end have to be in the list otherwise nil is retured.
func (*List) FindElementForward ¶
func (l *List) FindElementForward(start, end Elementer, finder func(e Elementer) (didFind bool)) (found Elementer)
FindElementForward will start at the start element working it's way to the end element (or back to the sentinel element of the list if nil is provided) calling the match function. It return that element or nil if it did not find a point. Both start and end have to be in the list otherwise the function will return nil.
func (*List) InsertAfter ¶
InsertAfter inserts a new element e immediately after the mark and returns e. If mark is not an element of l, the list is not modified.
func (*List) InsertBefore ¶
InsertBefore inserts a new element e immediately before mark and returns e. If mark is not an element of , the list is not modified.
func (*List) IsSentinel ¶
IsSentinel returns weather or not the provided element is the sentinel element of the list.
func (*List) MoveAfter ¶
MoveAfter move 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) 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 modifed
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.
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.