searchablelist

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2017 License: Apache-2.0 Imports: 1 Imported by: 0

README

SearchableList

Package `searchablelist` implements the `list` package doubly linked list
and extends it with search methods

type SearchableList
    New () *SearchableList
    ContainsElement (t *Element) bool
    Contains (t *Element) bool
    ContainsValue (v interface{}) bool
    FindFirst (v interface{}) *Element
    FindLast (v interface{}) *Element
    FindAll (v interface{}) []*Element

type Element
    func (e *Element) Next() *Element
    func (e *Element) Prev() *Element

type List
    func (l *List) Back() *Element
    func (l *List) Front() *Element
    func (l *List) Init() *List
    func (l *List) InsertAfter(v interface{}, mark *Element) *Element
    func (l *List) InsertBefore(v interface{}, mark *Element) *Element
    func (l *List) Len() int
    func (l *List) MoveAfter(e, mark *Element)
    func (l *List) MoveBefore(e, mark *Element)
    func (l *List) MoveToBack(e *Element)
    func (l *List) MoveToFront(e *Element)
    func (l *List) PushBack(v interface{}) *Element
    func (l *List) PushBackList(other *List)
    func (l *List) PushFront(v interface{}) *Element
    func (l *List) PushFrontList(other *List)
    func (l *List) Remove(e *Element) interface{}

Documentation

Overview

Example
package main

import (
	"fmt"

	"github.com/clarketm/searchablelist"
)

func main() {
	sl := searchablelist.New()
	e1 := sl.PushFront(1)
	sl.InsertAfter(2, e1)
	e4 := sl.PushBack(1)
	sl.InsertBefore(2, e4)

	fmt.Println(sl.Contains(e1))
	fmt.Println(sl.ContainsElement(e4))
	fmt.Println(sl.ContainsValue(1))

	firstOneElement := sl.FindFirst(1)
	fmt.Println(e1 == firstOneElement)

	lastOneElement := sl.FindLast(1)
	fmt.Println(e4 == lastOneElement)

	allOneElements := sl.FindAll(1)
	fmt.Println(e1 == allOneElements[0])
	fmt.Println(e4 == allOneElements[1])

}
Output:

true
true
true
true
true
true
true

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SearchableList

type SearchableList struct {
	*list.List
}

SearchableList list.List

func New

func New() *SearchableList

New () *list.List

func (*SearchableList) Contains

func (l *SearchableList) Contains(t *list.Element) bool

Contains (t *list.Element) bool alias -> ContainsElement

func (*SearchableList) ContainsElement

func (l *SearchableList) ContainsElement(t *list.Element) bool

ContainsElement (t *list.Element) bool

func (*SearchableList) ContainsValue

func (l *SearchableList) ContainsValue(v interface{}) bool

ContainsValue (v interface{}) bool

func (*SearchableList) FindAll

func (l *SearchableList) FindAll(v interface{}) []*list.Element

FindAll (v interface{}) []*list.Element

func (*SearchableList) FindFirst

func (l *SearchableList) FindFirst(v interface{}) *list.Element

FindFirst (v interface{}) *list.Element

func (*SearchableList) FindLast

func (l *SearchableList) FindLast(v interface{}) *list.Element

FindLast (v interface{}) *list.Element

Jump to

Keyboard shortcuts

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