functions

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultFunctionCollection

type DefaultFunctionCollection struct {
	FunctionCollection
}

Implements a list filled with standard functions.

func NewDefaultFunctionCollection

func NewDefaultFunctionCollection() *DefaultFunctionCollection

Constructs this list and fills it with the standard functions.

type DelegatedFunction

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

Defines an interface for expression function.

func NewDelegatedFunction

func NewDelegatedFunction(name string, calculator FunctionCalculator) *DelegatedFunction

Constructs this function class with specified parameters.

Parameters:

  • name: The name of this function.
  • calculator: The function calculator delegate.

func (*DelegatedFunction) Calculate

func (c *DelegatedFunction) Calculate(parameters []*variants.Variant,
	variantOperations variants.IVariantOperations) (*variants.Variant, error)

The function calculation method.

Parameters:

  • parameters: A list with function parameters.
  • variantOperations: Variants operations manager.

Returns: A calculated function result.

func (*DelegatedFunction) Name

func (c *DelegatedFunction) Name() string

The function name.

type FunctionCalculator

type FunctionCalculator func(parameters []*variants.Variant,
	variantOperations variants.IVariantOperations) (*variants.Variant, error)

Defines a delegate to implement a function

Parameters:

  • parameters: A list with function parameters
  • variantOperations: A manager for variant operations.

Returns: A calculated function value.

type FunctionCollection

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

Implements a functions list.

func NewFunctionCollection

func NewFunctionCollection() *FunctionCollection

func (*FunctionCollection) Add

func (c *FunctionCollection) Add(function IFunction)

Adds a new function to the collection.

Parameters:

  • function: a function to be added.

func (*FunctionCollection) Clear

func (c *FunctionCollection) Clear()

Clears the collection.

func (*FunctionCollection) FindByName

func (c *FunctionCollection) FindByName(name string) IFunction

Finds function in the list by it's name.

Parameters:

  • name: The function name to be found.

Returns: Function or <code>null</code> if function was not found.

func (*FunctionCollection) FindIndexByName

func (c *FunctionCollection) FindIndexByName(name string) int

Finds function index in the list by it's name.

Parameters:

  • name: The function name to be found.

Returns: Function index in the list or <code>-1</code> if function was not found.

func (*FunctionCollection) Get

func (c *FunctionCollection) Get(index int) IFunction

Get a function by its index.

Parameters:

  • index: a function index.

Returns: a retrieved function.

func (*FunctionCollection) GetAll

func (c *FunctionCollection) GetAll() []IFunction

Get all functions stores in the collection

Returns: a list with functions.

func (*FunctionCollection) Length

func (c *FunctionCollection) Length() int

A number of functions stored in the collection.

func (*FunctionCollection) Remove

func (c *FunctionCollection) Remove(index int)

Removes a function by its index.

Parameters:

  • index: a index of the function to be removed.

func (*FunctionCollection) RemoveByName

func (c *FunctionCollection) RemoveByName(name string)

Removes function by it's name.

Parameters:

  • name: The function name to be removed.

type IFunction

type IFunction interface {
	// The function name.
	Name() string

	// The function calculation method.
	//
	// Parameters:
	//   - parameters: A list with function parameters<
	//   - variantOperations: Variants operations manager.
	Calculate(parameters []*variants.Variant,
		variantOperations variants.IVariantOperations) (*variants.Variant, error)
}

Defines an interface for expression function. </summary>

type IFunctionCollection

type IFunctionCollection interface {
	// Adds a new function to the collection.
	//
	// Parameters:
	//   - function: a function to be added.
	Add(function IFunction)

	// A number of functions stored in the collection.
	Length() int

	// Get a function by its index.
	//
	// Parameters:
	//   - index: a function index.
	// Returns: a retrieved function.
	Get(index int) IFunction

	// Get all functions stores in the collection
	//
	// Returns: a list with functions.
	GetAll() []IFunction

	// Finds function index in the list by it's name.
	//
	// Parameters:
	//   - name: The function name to be found.
	// Returns: Function index in the list or <code>-1</code> if function was not found.
	FindIndexByName(name string) int

	// Finds function in the list by it's name.
	//
	// Parameters:
	//   - name: The function name to be found.
	// Returns: Function or <code>null</code> if function was not found.
	FindByName(name string) IFunction

	// Removes a function by its index.
	//
	// Parameters:
	//   - index: a index of the function to be removed.
	Remove(index int)

	// Removes function by it's name.
	//
	// Parameters:
	// 	 - name: The function name to be removed.
	RemoveByName(name string)

	// Clears the collection.
	Clear()
}

Defines a functions list.

Jump to

Keyboard shortcuts

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