Documentation
¶
Overview ¶
Package sortedlist provides a generic sorted doubly-linked list.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SortedList ¶
type SortedList[T any] struct { // contains filtered or unexported fields }
A sorted doubly-linked list.
func NewSortedList ¶
func NewSortedList[T any](less func(T, T) bool) *SortedList[T]
NewSortedList, given a comparison function, returns a new SortedList.
func (*SortedList[T]) Count ¶
func (l *SortedList[T]) Count() uint
Count returns the number of nodes in the SortedList.
func (*SortedList[T]) IsEmpty ¶
func (l *SortedList[T]) IsEmpty() bool
IsEmpty returns true when the SortedList has no nodes.
func (*SortedList[T]) Traverse ¶
func (l *SortedList[T]) Traverse(f func(T) bool)
Traverse traverses the nodes in the SortedList from head to tail. It calls the provided function for each, passing in the node's value. It stops either when the complete list is traversed, or the function returns false.
func (*SortedList[T]) TraverseR ¶
func (l *SortedList[T]) TraverseR(f func(T) bool)
TraverseR traverses the nodes in the SortedList from tail to head. It calls the provided function for each, passing in the node's value. It stops either when the complete list is traversed, or the function returns false.