/
series.go
85 lines (63 loc) · 2.54 KB
/
series.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package dataframe
import ()
type Options struct {
// Don't apply lock
DontLock bool
// Sort in descending order
SortDesc bool
}
type ValueToStringFormatter func(val interface{}) string
type Series interface {
// Name returns the series name
Name() string
// Type returns the type of data the series holds
Type() string
// NRows returns how many rows the series contains
NRows(options ...Options) int
// Value returns the value of a particular row.
// The return value could be nil or the concrete type
// the data type held by the series.
// Pointers are never returned.
Value(row int, options ...Options) interface{}
// ValueString returns a string representation of a
// particular row. The string representation is defined
// by the function set in SetValueToStringFormatter.
// By default, a nil value is returned as "NaN".
ValueString(row int, options ...Options) string
// Prepend is used to set a value to the beginning of the
// series. val can be a concrete data type or nil. Nil
// represents the absence of a value.
Prepend(val interface{}, options ...Options)
// Append is used to set a value to the end of the series.
// val can be a concrete data type or nil. Nil represents
// the absence of a value.
Append(val interface{}, options ...Options) int
// Insert is used to set a value at an arbitary row in
// the series. All existing values from that row onwards
// are shifted by 1. val can be a concrete data type or nil.
// Nil represents the absence of a value.
Insert(row int, val interface{}, options ...Options)
// Remove is used to delete the value of a particular row.
Remove(row int, options ...Options)
// Update is used to update the value of a particular row.
// val can be a concrete data type or nil. Nil represents
// the absence of a value.
Update(row int, val interface{}, options ...Options)
// SetValueToStringFormatter is used to set a function
// to convert the value of a particular row to a string
// representation.
SetValueToStringFormatter(f ValueToStringFormatter)
// Sort will sort the series
Sort(options ...Options)
// IsEqualFunc returns true if a is equal to b
IsEqualFunc(a, b interface{}) bool
// IsLessThanFunc returns true if a is less than b
IsLessThanFunc(a, b interface{}) bool
// Swap is used to swap 2 values based on their row position.
Swap(row1, row2 int, options ...Options)
// Lock will lock the Series allowing you to directly manipulate
// the underlying slice with confidence.
Lock()
// Unlock will unlock the Series that was previously locked.
Unlock()
}