Documentation ¶
Overview ¶
Package table implements a loose 2d collection of values
Index ¶
- type Sparse
- func (s Sparse) Apply(ctx changes.Context, c changes.Change) changes.Value
- func (s Sparse) Cell(row, col interface{}) (interface{}, bool)
- func (s Sparse) GC(rowKey, colKey func(interface{}) interface{}) (Sparse, changes.Change)
- func (s Sparse) RemoveCell(row, col interface{}) (Sparse, changes.Change)
- func (s Sparse) SpliceCols(offset, remove int, ids []interface{}) (Sparse, changes.Change)
- func (s Sparse) SpliceRows(offset, remove int, ids []interface{}) (Sparse, changes.Change)
- func (s Sparse) UpdateCell(row, col, value interface{}) (Sparse, changes.Change)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sparse ¶
Sparse represents a table where the data is stored in a map accessed by the row and column ids. Not all row-col pairs may have a corresponding value (hence the sparse). In addition, deletion of rowIDs and column IDs do not automatically delete the corresponding data -- that is expected to be handled in a late garbage-collection phase.
The row ID and column ID collections can also be used to store other row-ID specific or column-ID specific data but in that case, the caller must implement a rowKey and/or colKey function that maps these to the corresponding key in the data map. This is only used by GC().
Under some very contrived conditions, RowIDs and ColIDs may contain duplicates. For this reason, the callers should take care when iterating these arrays. To maintain consistency, only the first occurrence of an ID should be considered and all further occurrences ignored.
func (Sparse) Cell ¶
Cell returns the value at a given cell position. The bool return value indicates if the element exists or not
func (Sparse) GC ¶
GC finds all cells that are orphaned by prior row/column deletes and clears them out. It returns the changes matching the delete as well. The rowKey and colKey functions provide the mapping from the corresponding IDs to the key. These can be nil to indicate the IDs are themselves the keys into the Data map.
func (Sparse) RemoveCell ¶
RemoveCell removes the value of a cell (which need not exist)
func (Sparse) SpliceCols ¶
SpliceCols splices a set of colIDs at the provided offset, first removing the specified count of IDs
func (Sparse) SpliceRows ¶
SpliceRows splices a set of rowIDs at the provided offset, first removing the specified count of IDs.