algo

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2016 License: Apache-2.0 Imports: 4 Imported by: 119

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 IndexOf

func IndexOf(u *task.List, uid uint64) 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)

IntersectWith intersects u with v. The update is made to u. It assumes that u, v are sorted, which are not always the case.

func MergeSorted

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

MergeSorted merges sorted lists.

func ToUintsListForTest

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

ToUintsListForTest converts to list of uints for testing purpose only.

Types

This section is empty.

Jump to

Keyboard shortcuts

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