FunctionCollection

Implements a list of functions.

Implements: IFunctionCollection

Description

The FunctionCollection class allows you to implement a list of functions

Constructors

NewFunctionCollection

Creates new instances of function collection

NewFunctionCollection() *FunctionCollection

Methods

Add

Adds a new function to the collection.

(c *FunctionCollection) Add(function IFunction)

  • func: IFunction - array with function parameters.

Clear

Clears the collection.

(c *FunctionCollection) Clear()

FindByName

Finds a function in the list by it’s name.

(c *FunctionCollection) FindByName(name string) IFunction

  • name: string - function name to be found.
  • returns: IFunction - function or nil if no function was found.

FindIndexByName

Finds a function’s index in the list by it’s name.

(c *FunctionCollection) FindIndexByName(name string) int

  • name: string - function name to be found.
  • returns: int - function’s index in the list or -1 if no function was found.

Get

Gets a function by its index.

(c *FunctionCollection) Get(index int) IFunction

  • index: int - function’s index.
  • returns: IFunction - retrieved function.

GetAll

Gets all functions stored in the collection.

(c *FunctionCollection) GetAll() []IFunction

Length

Gets the number of functions stored in the collection.

Length() int

  • retuns: int - number of stored functions.

Remove

Removes a function by its index.

(c *FunctionCollection) Remove(index int)

  • index: int - index of the function to be removed.

RemoveByName

Removes a function by its name.

(c *FunctionCollection) RemoveByName(name string)

  • name: string - name of the function to be removed.