algo

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package algo contains algorithms such as merging, intersecting sorted lists.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFilter

func ApplyFilter(u *task.List, f func(uint64, int) bool)

ApplyFilter applies a filter to our UIDList.

func BlockToList added in v0.7.3

func BlockToList(b *task.List) []uint64

func Difference added in v0.7.2

func Difference(u, v *task.List)

func Idx added in v0.7.3

func Idx(ul *task.List, i, j int) int

func IndexOf

func IndexOf(u *task.List, uid uint64) (int, int)

IndexOf performs a binary search on the uids slice and returns the index at which it finds the uid, else returns -1

func IntersectSorted

func IntersectSorted(lists []*task.List) *task.List

IntersectSorted intersect a list of UIDLists. An alternative is to do pairwise intersections n-1 times where n=number of lists. This is less efficient: Let p be length of shortest list. Let q be average length of lists. So nq = total number of elements. There are many possible cases. Consider the case where the shortest list is the answer (or close to the answer). The following method requires nq reads (each element is read only once) whereas pairwise intersections can require np + nq - p reads, which can be up to ~twice as many.

func IntersectWith

func IntersectWith(u, v *task.List)

func ItemAtIndex added in v0.7.3

func ItemAtIndex(ul *task.List, i int) uint64

func ListLen added in v0.7.3

func ListLen(l *task.List) int

func MergeSorted

func MergeSorted(lists []*task.List) *task.List

MergeSorted merges sorted lists.

func Slice added in v0.7.3

func Slice(ul *task.List, start, end int)

Slice returns a new task.List with the elements between start index and end index of the list passed to it.

func Sort added in v0.7.3

func Sort(ul *task.List)

func SortedListToBlock added in v0.7.3

func SortedListToBlock(l []uint64) *task.List

func Swap added in v0.7.3

func Swap(ul *task.List, i, j int)

func ToUintsListForTest

func ToUintsListForTest(ul []*task.List) [][]uint64

ToUintsListForTest converts to list of uints for testing purpose only.

Types

type AsList added in v0.7.3

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

AsList implements sort.Interface by for block lists

func (AsList) Len added in v0.7.3

func (s AsList) Len() int

func (AsList) Less added in v0.7.3

func (s AsList) Less(i, j int) bool

func (AsList) Swap added in v0.7.3

func (s AsList) Swap(i, j int)

type ListIterator added in v0.7.3

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

ListIterator is used to read through the task.List.

func NewListIterator added in v0.7.3

func NewListIterator(l *task.List) ListIterator

NewListIterator returns a read iterator for the list passed to it.

func (*ListIterator) Next added in v0.7.3

func (l *ListIterator) Next()

Next moves the iterator to the next element and also sets the end if the last element is consumed already.

func (*ListIterator) Seek added in v0.7.3

func (l *ListIterator) Seek(uid uint64, whence int)

Seek seeks to the index whose value is greater than or equal to the given UID. It uses binary search to move around.

func (*ListIterator) SeekToIndex added in v0.7.3

func (l *ListIterator) SeekToIndex(idx int)

SeekToIndex moves the iterator to the specified index.

func (*ListIterator) Val added in v0.7.3

func (l *ListIterator) Val() uint64

Val returns the value pointed to by the iterator.

func (*ListIterator) Valid added in v0.7.3

func (l *ListIterator) Valid() bool

Valid returns true if we haven't reached the end of the list.

type WriteIterator added in v0.7.3

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

WriteIterator is used to append UIDs to a task.List.

func NewWriteIterator added in v0.7.3

func NewWriteIterator(l *task.List, whence int) WriteIterator

func (*WriteIterator) Append added in v0.7.3

func (l *WriteIterator) Append(uid uint64)

Append appends an UID to the end of task.List following the blockSize specified.

func (*WriteIterator) End added in v0.7.3

func (l *WriteIterator) End()

End is called after the write is over to update the MaxInt of the last block.

Jump to

Keyboard shortcuts

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