Documentation
¶
Overview ¶
Package ds contains useful data structures.
Index ¶
- func NewLookup[T any, K comparable, V any](items []*T, entry func(*T) (K, V)) map[K]V
- func NewLookupPlain[T any, K comparable, V any](items []T, entry func(T) (K, V)) map[K]V
- type CodeIDLookup
- type Coords
- type DLLNode
- type DataRows
- type Edge
- type EdgeSet
- type Graph
- func (g Graph) ActiveNeighbors(vertex Vertex, activeEdges EdgeSet) []Vertex
- func (g *Graph) AddDirectedEdge(vertex1, vertex2 Vertex)
- func (g *Graph) AddUndirectedEdge(vertex1, vertex2 Vertex)
- func (g *Graph) AddVertex(vertex Vertex)
- func (g Graph) BFSTraversal(start Vertex, activeEdges EdgeSet) []Vertex
- func (g Graph) EdgeNames() []string
- func (g Graph) EdgeWeight(edge Edge) (float64, bool)
- func (g Graph) Neighbors(vertex Vertex) []Vertex
- type IDCodeLookup
- type List
- type ListWithLookup
- type LookupCode
- type LookupID
- type MapWithLookup
- type Queue
- type Set
- func (s *Set[T]) Add(item T)
- func (s *Set[T]) AddItems(items []T)
- func (s *Set[T]) Delete(item T)
- func (s1 Set[T]) Difference(s2 *Set[T]) *Set[T]
- func (s Set[T]) Has(item T) bool
- func (s Set[T]) HasNo(item T) bool
- func (s1 Set[T]) Intersection(s2 *Set[T]) *Set[T]
- func (s Set[T]) IsEmpty() bool
- func (s Set[T]) Items() []T
- func (s Set[T]) Len() int
- func (s Set[T]) NotEmpty() bool
- func (s1 Set[T]) Union(s2 *Set[T]) *Set[T]
- type Stack
- type Vertex
- type VertexSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLookup ¶
func NewLookup[T any, K comparable, V any](items []*T, entry func(*T) (K, V)) map[K]V
Create new lookup from list of ref items, using entry function
func NewLookupPlain ¶ added in v0.5.78
func NewLookupPlain[T any, K comparable, V any](items []T, entry func(T) (K, V)) map[K]V
Create new lookup from list of items, using entry function
Types ¶
type CodeIDLookup ¶
func NewCodeIDLookup ¶
func NewCodeIDLookup[T identifiable](items []*T) CodeIDLookup
Create new CodeIDLookup from list of ref items
func NewCodeIDLookupPlain ¶ added in v0.5.78
func NewCodeIDLookupPlain[T identifiable](items []T) CodeIDLookup
Create new CodeIDLookup from list of items
type DLLNode ¶
Doubly-Linked list node
func NewDLLNode ¶
Create new DLL node that contains value, Prev and Next pointers initialized to self
type DataRows ¶
type DataRows struct {
Rows string
}
Struct for lines of data rows, separated by comma
type Edge ¶
type Edge [2]Vertex
func NewDirectedEdge ¶ added in v0.5.29
Create new directed Edge from v1->v2 string
type Graph ¶
type Graph struct {
Vertices []Vertex
Edges []Edge
IndexOf map[Vertex]int
EdgesOf map[Vertex][]Edge
NeighborsOf map[Vertex]VertexSet
EdgeWeightOf map[Edge]float64
}
func DirectedGraphFrom ¶ added in v0.5.29
Create directed graph from vertices (separated by whitespace), and edgePairs (v1->v2 edges separated by whitespace)
func GraphFrom ¶
Create undirected graph from vertices (separated by whitespace), and edgePairs (v1-v2 edges separated by whitespace)
func (Graph) ActiveNeighbors ¶
Get list of vertex neighbors, considering the active edge set
func (*Graph) AddDirectedEdge ¶
Add directed edge to graph
func (*Graph) AddUndirectedEdge ¶
Add undirected edge to graph
func (Graph) BFSTraversal ¶
Perform BFS traversal on the graph, starting at given vertex, considering the active edge set, return list of vertices visited
type IDCodeLookup ¶
func NewIDCodeLookup ¶
func NewIDCodeLookup[T identifiable](items []*T) IDCodeLookup
Create new IDCodeLookup from list of ref items
func NewIDCodeLookupPlain ¶ added in v0.5.78
func NewIDCodeLookupPlain[T identifiable](items []T) IDCodeLookup
Create new IDCodeLookup from list of items
type ListWithLookup ¶
Struct for list of items, with associated lookup table, T = item type, L = lookup item type
func NewListWithLookup ¶
func NewListWithLookup[T, L any](items []T) *ListWithLookup[T, L]
Create new ListWithLookup from given list of items, Initialize lookup to empty map
type LookupCode ¶
func LookupCodeFromID ¶
Create new LookupCode from given LookupID, Use nil set to skip code validation
func NewLookupCode ¶
func NewLookupCode[T hasCode](items []*T) LookupCode[*T]
Create new LookupCode from list of ref items
func NewLookupCodePlain ¶ added in v0.5.78
func NewLookupCodePlain[T hasCode](items []T) LookupCode[T]
Create new LookupCode from list of items
type LookupID ¶
func LookupIDFromCode ¶
Create new LookupID from given LookupCode, Use nil set to skip id validation
func NewLookupID ¶
func NewLookupID[T hasID](items []*T) LookupID[*T]
Create new LookupID from list of ref items
func NewLookupIDPlain ¶ added in v0.5.78
func NewLookupIDPlain[T hasID](items []T) LookupID[T]
Create new LookupID from list of items
type MapWithLookup ¶
type MapWithLookup[K comparable, V, L any] struct { Items map[K]V Lookup map[string]L Count int }
Struct for map of items, with associated lookup table, K, V = map key/value types, L = lookup item type
func NewMapWithLookup ¶
func NewMapWithLookup[K comparable, V, L any](items map[K]V) *MapWithLookup[K, V, L]
Create new MapWithLookup from given map of items, Initialize lookup to empty map
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func (Set[T]) Difference ¶
Compute difference of two sets
func (Set[T]) Intersection ¶
Compute intersection of two sets