tabulator

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Indexer

type Indexer[T ordered] struct {
	// contains filtered or unexported fields
}

Indexer holds a unique set of values, and records the order in which they were added. Currently, it supports string and time.Time data.

func MakeIndexer

func MakeIndexer[T ordered]() *Indexer[T]

MakeIndexer returns a new indexer

func (*Indexer[T]) Add

func (idx *Indexer[T]) Add(value T) (index int, added bool)

Add adds a new value to the Indexer. It returns the index of that value and whether the value was actually added.

func (*Indexer[T]) Count

func (idx *Indexer[T]) Count() int

Count returns the number of values in the Indexer

func (*Indexer[T]) GetIndex

func (idx *Indexer[T]) GetIndex(value T) (index int, found bool)

GetIndex returns the index of a value (i.e. when that value was added)

func (*Indexer[T]) List

func (idx *Indexer[T]) List() (values []T)

List returns the (sorted) values in the Indexer

type Tabulator

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

Tabulator tabulates a set of entries in rows by timestamp and columns by label. For performance reasons, data must be added sequentially.

func New

func New(columns ...string) *Tabulator

New creates a new Tabulator

func (*Tabulator) Add

func (d *Tabulator) Add(timestamp time.Time, column string, value float64) bool

Add adds a value for a specified timestamp and column to the table. If there is already a value for that timestamp and column, the specified value is added to the existing value.

Returns false if the column does not exist. Use RegisterColumn to add it first.

func (*Tabulator) GetColumns

func (d *Tabulator) GetColumns() (columns []string)

GetColumns returns the (sorted) list of column names.

func (*Tabulator) GetTimestamps

func (d *Tabulator) GetTimestamps() (timestamps []time.Time)

GetTimestamps returns the (sorted) list of timestamps in the table.

func (*Tabulator) GetValues

func (d *Tabulator) GetValues(column string) (values []float64, ok bool)

GetValues returns the value for the specified column for each timestamp in the table. The values are sorted by timestamp.

func (*Tabulator) RegisterColumn

func (d *Tabulator) RegisterColumn(column ...string)

func (*Tabulator) Size

func (d *Tabulator) Size() int

Size returns the number of rows in the table.

Jump to

Keyboard shortcuts

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