Sooth.Context (Sooth v0.3.1)

Provides the Context module for Sooth.

This module is mainly used for internal implementation details of the Sooth.Predictor module and should not be used directly.

Summary

Types

t()

A Context of id/count/statistics

Functions

Find a statistic in a context.

Create a new context.

Observe an event in a context.

Types

@type t() :: %Sooth.Context{
  count: non_neg_integer(),
  id: non_neg_integer(),
  statistic_objects: map(),
  statistic_set: :gb_sets
}

A Context of id/count/statistics

Functions

Link to this function

find_statistic(context, event)

@spec find_statistic(t(), non_neg_integer()) :: Sooth.Statistic.t() | nil

Find a statistic in a context.

This is an implementation detail and should not be used directly.

@spec new(non_neg_integer()) :: t()

Create a new context.

Examples

iex> Sooth.Context.new(0)
#Sooth.Context<id: 0, count: 0, statistic_set: [], statistic_objects: %{}>
Link to this function

observe(context, event)

@spec observe(t(), non_neg_integer()) :: {t(), Sooth.Statistic.t()}

Observe an event in a context.

Examples

iex> context = Sooth.Context.new(0)
iex> {context, _} = Sooth.Context.observe(context, 3)
iex> context
#Sooth.Context<id: 0, count: 1, statistic_set: [3], statistic_objects: %{3 => %Sooth.Statistic{count: 1, event: 3}}>
Link to this function

walk_statistics(context)