Outputs

abstract class Outputs<T>

Represents the outputs for an FST, providing the basic algebra required for building and traversing the FST.

Note that any operation that returns NO_OUTPUT must return the same singleton object from .getNoOutput.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
abstract val noOutput: T

NOTE: this output is compared with == so you must ensure that all methods return the single object if it's really no output

Functions

Link copied to clipboard
abstract fun add(prefix: T, output: T): T

Eg add("foo", "bar") -> "foobar"

Link copied to clipboard
abstract fun common(output1: T, output2: T): T

Eg common("foobar", "food") -> "foo"

Link copied to clipboard
fun merge(first: T, second: T): T
Link copied to clipboard
abstract fun outputToString(output: T): String
Link copied to clipboard
abstract fun ramBytesUsed(output: T): Long

Return memory usage for the provided output.

Link copied to clipboard
abstract fun read(in: DataInput): T

Decode an output value previously written with .write.

Link copied to clipboard

Decode an output value previously written with .writeFinalOutput. By default this just calls .read.

Link copied to clipboard

Skip the output previously written with .writeFinalOutput; defaults to just calling .readFinalOutput and discarding the result.

Link copied to clipboard
open fun skipOutput(in: DataInput)

Skip the output; defaults to just calling .read and discarding the result.

Link copied to clipboard
abstract fun subtract(output: T, inc: T): T

Eg subtract("foobar", "foo") -> "bar"

Link copied to clipboard
abstract fun write(output: T, out: DataOutput)

Encode an output value into a DataOutput.

Link copied to clipboard
fun writeFinalOutput(output: T, out: DataOutput)

Encode an final node output value into a DataOutput. By default this just calls .write.