skiplist

package
v0.0.0-...-fc15ddb Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicate = errors.New("Duplicate")
)

Functions

This section is empty.

Types

type Compare

type Compare func(a interface{}, b interface{}) int

Compare func interface Allows for users of Skiplist to define sort strategy for skiplists Value "a" is the base subject of the comparison or the "left" side. Value "b" is the new subject or the "right" side. There are 3 possible int return values: "0" - The 2 values are exact matches. "1" - Value "a" is greather than value "b" "-1" - Value "a" is less than value "b"

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

Concurrent-safe iterator to scan the list qithout removing items.

func (*Iterator) Current

func (it *Iterator) Current() interface{}

Return the current item

func (*Iterator) Next

func (it *Iterator) Next() interface{}

Return the next item

func (*Iterator) Seek

func (it *Iterator) Seek(n int) bool

Seek to the n-th offset Returns a bool to signal whether the full seek was successful. Will seek to the nearest n-th if n is out of range.

type List

type List struct {
	// contains filtered or unexported fields
}

func New

func New(compare Compare) *List

New Skiplist Requires a compare func honoring the interface

func (*List) Delete

func (l *List) Delete(item interface{}) bool

Delete an item by value Uses the initilized Compare func

func (*List) Exists

func (l *List) Exists(item interface{}) bool

Verifies if an item is in the queue

func (*List) Insert

func (l *List) Insert(item interface{}) bool

Insert a new item Returns false if the item already exist Returns true on successful insert

func (*List) Iterator

func (l *List) Iterator() *Iterator

func (*List) Len

func (l *List) Len() int

Lengh of items in list

func (*List) Pop

func (l *List) Pop() (interface{}, bool)

Pop an item from the head Follows the comma ok idiom. bool is false if no items are available

type Node

type Node struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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