xydata

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

XYDATA

A data structure for a set of (x,y) data pairs with basic functionality access and manipulate data, as well sort, filter and apply functions to data. Data accessing is done by indexing to data array via Map or "active data index". For example when sorting, the actual data is not sorted but the Map is re-ordered in a way that the data appears sorted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type XY

type XY struct {
	Map   []int  // Maps the active data index to real data index -- used to access desired data in desired order outside XY
	Error string // Error string -- cleared when any new XY function call is made
	// contains filtered or unexported fields
}

xy data

func NewXY added in v0.19.0

func NewXY(x, y []float64) *XY

Creates new XY object

func (*XY) AddXY

func (xy *XY) AddXY(x, y float64)

Adds XY pair to the tail of data array.

func (*XY) Apply added in v0.21.0

func (xy *XY) Apply(f func(x, y float64) (float64, float64))

Apply function to active data.

func (*XY) FilterX added in v0.20.1

func (xy *XY) FilterX(f func(x float64) bool)

Filters all X data with given function.

func (*XY) FilterY added in v0.20.1

func (xy *XY) FilterY(f func(y float64) bool)

Filters all Y data with given function.

func (*XY) FindIndex added in v0.21.0

func (xy *XY) FindIndex(x, y float64) int

Finds the index of given X and/or Y value(s). Index is gone through in ascending order and the first match is returned. Use math.NaN() to disable matching. Function returns -1 is not match is found.

func (*XY) GetX

func (xy *XY) GetX(i int) (x float64)

Returns X from given index

func (*XY) GetXY

func (xy *XY) GetXY(i int) (x, y float64)

Returns X and Y from given index

func (*XY) GetY

func (xy *XY) GetY(i int) (y float64)

Returns Y from given index

func (*XY) InsertXY

func (xy *XY) InsertXY(x, y float64, i int)

Inserts XY pair into data array.

func (*XY) Len

func (xy *XY) Len() int

Length of data

func (*XY) RemoveXY

func (xy *XY) RemoveXY(i int)

Removes XY pair from given index. Note that this actually removes the data, not just the index to it.

func (*XY) ReplaceXY

func (xy *XY) ReplaceXY(x, y float64, i int)

Replaces XY pair from given index.

func (*XY) ResetMap added in v0.21.0

func (xy *XY) ResetMap()

Resets Map to reflect real data index

func (*XY) SortI

func (xy *XY) SortI(ascending bool)

Sorts the active index ascending or descending.

func (*XY) SortX

func (xy *XY) SortX(ascending bool)

Sorts the active X values ascending or descending.

func (*XY) SortY

func (xy *XY) SortY(ascending bool)

Sorts the active Y values ascending or descending.

func (*XY) ViewX

func (xy *XY) ViewX() *[]float64

Returns a view of active X data.

func (*XY) ViewXY added in v0.21.0

func (xy *XY) ViewXY() (x *[]float64, y *[]float64)

Returns views to active X and Y data.

func (*XY) ViewY

func (xy *XY) ViewY() *[]float64

Returns a view of active Y data.

Jump to

Keyboard shortcuts

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