list

package
v0.0.0-...-3590e8a Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var V = []interface{}{1, "a", 2, "b", 3, "c", 4, "d"}

V holds the value for basic list tests

View Source
var VLen = len(V)

VLen is the length of V

Functions

This section is empty.

Types

type Iterator

type Iterator interface {
	// Next iterates to the next element in the list and returns the iterator, or nil if there is no next element
	Next() Iterator
	// Previous iterates to the previous element in the list and returns the iterator, or nil if there is no previous element
	Previous() Iterator

	// Get returns the value of the iterator's current element
	Get() interface{}
	// Set sets the value of the iterator's current element
	Set(v interface{})
}

Iterator defines a list iterator

type List

type List interface {
	// Clear resets the list to zero elements and resets the list's meta data
	Clear()
	// Len returns the current list length
	Len() int
	// Empty returns true if the current list length is zero
	Empty() bool

	// Chan returns a channel which iterates from the front to the back of the list
	Chan(n int) <-chan interface{}
	// ChanBack returns a channel which iterates from the back to the front of the list
	ChanBack(n int) <-chan interface{}

	// Iter returns an iterator which starts at the front of the list, or nil if there are no elements in the list
	Iter() Iterator
	// IterBack returns an iterator which starts at the back of the list, or nil if there are no elements in the list
	IterBack() Iterator

	// First returns the first value of the list and true, or false if there is no value
	First() (interface{}, bool)
	// Last returns the last value of the list and true, or false if there is no value
	Last() (interface{}, bool)
	// Get returns the value of the given index and nil, or an out of bound error if the index is incorrect
	Get(i int) (interface{}, error)
	// GetFunc returns the value of the first element selected by the given function and true, or false if there is no such element
	GetFunc(m func(v interface{}) bool) (interface{}, bool)
	// Set sets the value of the given index and returns nil, or an out of bound error if the index is incorrect
	Set(i int, v interface{}) error
	// SetFunc sets the value of the first element selected by the given function and returns true, or false if there is no such element
	SetFunc(m func(v interface{}) bool, v interface{}) bool
	// Swap swaps the value of index i with the value of index j
	Swap(i, j int)

	// Contains returns true if the value exists in the list, or false if it does not
	Contains(v interface{}) bool
	// IndexOf returns the first index of the given value and true, or false if it does not exists
	IndexOf(v interface{}) (int, bool)
	// LastIndexOf returns the last index of the given value and true, or false if it does not exists
	LastIndexOf(v interface{}) (int, bool)

	// Copy returns an exact copy of the list
	Copy() List
	// Slice returns a copy of the list as a slice
	Slice() []interface{}

	// Insert inserts a value into the list and returns nil, or an out of bound error if the index is incorrect
	Insert(i int, v interface{}) error
	// Remove removes and returns the value with the given index and nil, or an out of bound error if the index is incorrect
	Remove(i int) (interface{}, error)
	// RemoveFirstOccurrence removes the first occurrence of the given value in the list and returns true, or false if there is no such element
	RemoveFirstOccurrence(v interface{}) bool
	// RemoveLastOccurrence removes the last occurrence of the given value in the list and returns true, or false if there is no such element
	RemoveLastOccurrence(v interface{}) bool
	// Pop removes and returns the last element and true, or false if there is no such element
	Pop() (interface{}, bool)
	// Push inserts the given value at the end of the list
	Push(v interface{})
	// PushList pushes the given list
	PushList(l2 List)
	// Shift removes and returns the first element and true, or false if there is no such element
	Shift() (interface{}, bool)
	// Unshift inserts the given value at the beginning of the list
	Unshift(v interface{})
	// UnshiftList unshifts the given list
	UnshiftList(l2 List)

	// MoveAfter moves the element at index i after the element at index m and returns nil, or an out of bound error if an index is incorrect
	MoveAfter(i, m int) error
	// MoveToBack moves the element at index i to the back of the list and returns nil, or an out of bound error if the index is incorrect
	MoveToBack(i int) error
	// MoveBefore moves the element at index i before the element at index m and returns nil, or an out of bound error if an index is incorrect
	MoveBefore(i, m int) error
	// MoveToFront moves the element at index i to the front of the list and returns nil, or an out of bound error if the index is incorrect
	MoveToFront(i int) error
}

List defines a list

type ListBenchmark

type ListBenchmark struct {
	New func(b *testing.B) List
}

ListBenchmark is the base for all benchmarks of lists

func (*ListBenchmark) BenchmarkPushSequentiel

func (lb *ListBenchmark) BenchmarkPushSequentiel(b *testing.B)

func (*ListBenchmark) BenchmarkUnshiftSequentiel

func (lb *ListBenchmark) BenchmarkUnshiftSequentiel(b *testing.B)

type ListTest

type ListTest struct {
	New func(t *testing.T) List
}

ListTest is the base for all tests of lists

func (*ListTest) FillList

func (lt *ListTest) FillList(t *testing.T, l List)

FillList fills up a given list with V

func (*ListTest) NewDigitList

func (lt *ListTest) NewDigitList(t *testing.T) List

NewDigitList creates a new list and fills it with numbers from 0 to 4

func (*ListTest) NewFilledList

func (lt *ListTest) NewFilledList(t *testing.T) List

NewFilledList creates a new list and calls FillList on it

func (*ListTest) Run

func (lt *ListTest) Run(t *testing.T)

Run executes all basic list tests

func (*ListTest) TestAddLists

func (lt *ListTest) TestAddLists(t *testing.T)

TestAddLists tests the insert list methods

func (*ListTest) TestBasic

func (lt *ListTest) TestBasic(t *testing.T)

TestBasic tests basic list functionality

func (*ListTest) TestChannels

func (lt *ListTest) TestChannels(t *testing.T)

TestChannels tests list channels

func (*ListTest) TestClear

func (lt *ListTest) TestClear(t *testing.T)

TestClear tests clearing the list

func (*ListTest) TestCopy

func (lt *ListTest) TestCopy(t *testing.T)

TestCopy tests copying a list

func (*ListTest) TestFuncs

func (lt *ListTest) TestFuncs(t *testing.T)

TestFuncs tests all methods with functions as parameters

func (*ListTest) TestGetSet

func (lt *ListTest) TestGetSet(t *testing.T)

TestGetSet tests getters and setters

func (*ListTest) TestIndexOf

func (lt *ListTest) TestIndexOf(t *testing.T)

TestIndexOf tests the index of methods

func (*ListTest) TestInserts

func (lt *ListTest) TestInserts(t *testing.T)

TestInserts tests some insert methods

func (*ListTest) TestIterator

func (lt *ListTest) TestIterator(t *testing.T)

TestIterator tests list iterators

func (*ListTest) TestLeaks

func (lt *ListTest) TestLeaks(t *testing.T)

TestLeaks test for leaks

func (*ListTest) TestMoves

func (lt *ListTest) TestMoves(t *testing.T)

TestMoves tests all move methods

func (*ListTest) TestRemove

func (lt *ListTest) TestRemove(t *testing.T)

TestRemove tests some remove methods

func (*ListTest) TestRemoveOccurrence

func (lt *ListTest) TestRemoveOccurrence(t *testing.T)

TestRemoveOccurrence tests the remove occurrence methods

func (*ListTest) TestSlice

func (lt *ListTest) TestSlice(t *testing.T)

TestSlice tests converting the list to slice

func (*ListTest) TestSwap

func (lt *ListTest) TestSwap(t *testing.T)

TestSwap tests swap

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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