Documentation ¶
Index ¶
- func MyCallerFileLine() string
- type Element
- type Elementer
- type List
- func (l *List) Back() Elementer
- func (l *List) Clear()
- func (l *List) FindElementsBetween(start, end Elementer, finder func(e Elementer) (didFind bool)) (found Elementer)
- func (l *List) ForEach(fn func(e Elementer) bool)
- func (l *List) ForEachIdx(fn func(idx int, e Elementer) bool)
- func (l *List) Front() Elementer
- func (l *List) GetBefore(m Elementer) Elementer
- func (l *List) InsertAfter(e Elementer, mark Elementer) Elementer
- func (l *List) InsertBefore(e Elementer, mark Elementer) Elementer
- func (l *List) IsInList(e Elementer) bool
- func (l *List) Len() int
- func (l *List) PushBack(e Elementer) Elementer
- func (l *List) PushFront(e Elementer) Elementer
- func (l *List) Range(ctx context.Context) <-chan Elementer
- func (l *List) Remove(e Elementer) Elementer
- type Sentinel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MyCallerFileLine ¶
func MyCallerFileLine() string
MyCallerFileLine returns the FileLine of the caller of the function that called it :)
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 { // 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 // 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 }
Elementer is a node in the list. Manages it's next and previous elements.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List contains pointers to the start element and the end element of a list.
func (*List) FindElementsBetween ¶
func (l *List) FindElementsBetween(start, end Elementer, finder func(e Elementer) (didFind bool)) (found Elementer)
ForElementsBetween 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) ForEach ¶
ForEach call fn for each element in the list. Return false stops the iteration.
func (*List) ForEachIdx ¶
ForEach call fn for each element in the list. Return false stops the iteration.
func (*List) GetBefore ¶
GetBefore will return the element before this element. If the element is not in the list, it 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) PushFront ¶
PushFront inserts a new element e to the front of the list l and returns e.
func (*List) Range ¶
Range will start up a go routine, and send every element in the list at the time the call is made. It will make a copy of the elements in the list, so that changes in the list does not effect order. The channel is closed and the go routine exists when the list is exhausted or the ctx is done.