sortedlist

package
v0.0.0-...-d125614 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2023 License: MIT Imports: 0 Imported by: 0

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]) Add

func (l *SortedList[T]) Add(t T)

Add adds an item to the list.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL