containers

package
v0.0.0-...-c1f947c Latest Latest
Warning

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

Go to latest
Published: May 13, 2015 License: GPL-3.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyTree       = errors.New("empty tree")
	ErrElementNotFound = errors.New("element not found")
)
View Source
var (
	ErrInvalidIndex     = errors.New("invalid index")
	ErrListNodeNotFound = errors.New("list node not found")
	ErrEmptyList        = errors.New("empty list")
)
View Source
var (
	ErrDuplicateElement = errors.New("duplicate element")
)
View Source
var (
	ErrTokenizer = FragmentTreeError("not a simple URL")
)

Functions

func TokenizeURL

func TokenizeURL(url *url.URL) (tok []string, err error)

Tokenize an URL into separate alphanumeric words for indexing purposes.

Types

type BinaryTree

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

A binary search tree

func (*BinaryTree) AddNode

func (b *BinaryTree) AddNode(val string) (res *string, err error)

Add a node to the tree.

func (*BinaryTree) GetNode

func (b *BinaryTree) GetNode(key string) (res *string, err error)

Retrieve a node by index

func (*BinaryTree) RemoveNode

func (b *BinaryTree) RemoveNode(key string) (err error)

Remove a node by key from the tree. (oh yeah, it rhymes, deal with it).

func (*BinaryTree) Size

func (b *BinaryTree) Size() int

Return the size of the tree (nr. of nodes).

func (*BinaryTree) String

func (b *BinaryTree) String() string

A string representation of the binary tree.

func (*BinaryTree) Walk

func (b *BinaryTree) Walk(f func(Node))

Iterate over each node in the tree and perform the function f.

type BinaryTreeNode

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

func (BinaryTreeNode) Value

func (b BinaryTreeNode) Value() string

type Container

type Container interface {
	AddNode(url string) (*string, error)
	RemoveNode(key string) error
	Size() int
}

type FragmentTree

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

The data structure that allows for lower storage requirements by fragmenting urls and storing each fragment as a key. For this to be succesfull, a large number of links need to stored (compared to a simple string list.

func NewFragmentTree

func NewFragmentTree() (t *FragmentTree, err error)

Make a new FragmentTree object.

func (*FragmentTree) AddNode

func (f *FragmentTree) AddNode(url *url.URL) (err error)

Add a url by fragmenting it and using each fragment as a key in a tree.

func (*FragmentTree) GetUrl

func (f *FragmentTree) GetUrl(i int) (result string, err error)

type FragmentTreeError

type FragmentTreeError string

func (FragmentTreeError) Error

func (e FragmentTreeError) Error() string

type List

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

func (*List) AddNode

func (l *List) AddNode(key string) (result *string, err error)

Add a node to the list.

func (*List) GetNode

func (l *List) GetNode(i int) (result *string, err error)

Retrieve a node from the list by index.

func (*List) RemoveNode

func (l *List) RemoveNode(key string) (err error)

Remove the node from the list.

func (*List) Size

func (l *List) Size() int

Return the size of the list.

func (*List) String

func (l *List) String() string

A string representation of the list.

func (*List) Walk

func (l *List) Walk(f func(Node))

Iterate over the items in the list and execute the function f.

type ListNode

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

func (ListNode) Value

func (l ListNode) Value() string

type Node

type Node interface {
	Value() string
}

Jump to

Keyboard shortcuts

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