suggest

package
v0.0.0-...-fe13f99 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package suggest contains routines to implement a suggest engine

Package suggest contains routines to implement a suggest engine

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adder

type Adder interface {
	// Add makes best effort to eventually add s to this instance.
	Add(s string)
}

Adder is the interface for adding to a suggest engine.

type Engine

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

Engine represents a suggest engine which multiple goroutines may safely use.

func NewEngine

func NewEngine() *Engine

NewEngine creates a new engine.

func (*Engine) Add

func (e *Engine) Add(s string)

Add implements the Adder interface.

Add returns immediately before s is added. While Add makes best effort to ensure that s is eventually added to this instance, Add makes no guarantee that it will happen.

func (*Engine) Await

func (e *Engine) Await()

Await blocks the caller until all in progress add requests complete.

func (*Engine) Suggest

func (e *Engine) Suggest(max int, q string) (result []string)

Suggest implements the Suggester interface.

type Suggester

type Suggester interface {
	// Suggest returns the strings in this instance that start with q.
	// If max > 0, then Suggest returns at most max results; otherwise, it
	// returns all results.
	Suggest(max int, q string) (result []string)
}

Suggester is the interface for all suggest engines

func NewSuggester

func NewSuggester(suggestions ...string) Suggester

NewSuggester returns a Suggester that presents the given suggestions in the same order. NewSuggester takes a defensive copy of suggestions.

Jump to

Keyboard shortcuts

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