tree

package
v0.0.0-...-8f845b4 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Value *document.Term `json:"value"`

	Left   *Node `json:"left"`
	Right  *Node `json:"right"`
	Parent *Node `json:"-"`
}

Node is an individual element in the tree

func NewNode

func NewNode(term *document.Term) *Node

NewNode creates a new tree node with a specified value.

func (*Node) FindDocument

func (node *Node) FindDocument(documentName string) *document.Document

FindDocument searches this node's value for a specific document. It returns nil if one is not found.

type Tree

type Tree struct {
	Root *Node `json:"root"`
}

Tree is a tree structure which is the index of our text files and their matching terms/values

func NewTree

func NewTree(rootTerm *document.Term) *Tree

NewTree creates a new tree with a specific root node

func (*Tree) Add

func (tree *Tree) Add(term *document.Term) *Node

Add creates a new tree node and inserts it into the tree.

func (*Tree) Find

func (tree *Tree) Find(term *document.Term) *Node

Find searches for a specific term in the tree. If it is not found nil is returned.

func (*Tree) Search

func (tree *Tree) Search(searchTerm string) []*Node

Search returns a set of nodes who's values contain a search term

func (*Tree) ToJSON

func (tree *Tree) ToJSON() string

ToJSON returns a pretty printed string of this tree as JSON

Jump to

Keyboard shortcuts

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