neighbor

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package neighbor holds structs to describe the results of FindNearest, which performs nearest neighbor checks against a provided subject and options.

Each Neighbor holds a Neighbor.Name, which identifies it, and a Neighbor.Distance, describing the distance between the resulting Neighbor and the original subject.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Neighbor

type Neighbor struct {
	Name     string
	Distance int
}

Neighbor is a struct representing a neighbor, with a Distance to its relation and a Name to use as identification.

type Neighbors

type Neighbors []*Neighbor

Neighbors is a slice of Neighbor objects.

func FindNearest

func FindNearest(subject string, options []string, limit int) Neighbors

FindNearest returns the nearest, up to the given limit, Neighbors for the given subject.

func (Neighbors) Len

func (n Neighbors) Len() int

Len provides the number of Neighbor object in the current slice.

func (Neighbors) Less

func (n Neighbors) Less(i, j int) bool

Less will determine if the Neighbor at offset i has a lesser Neighbor.Distance than Neighbor at offset j.

func (Neighbors) Swap

func (n Neighbors) Swap(i, j int)

Swap Neighbor at offset i with Neighbor at offset j.

Jump to

Keyboard shortcuts

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