Documentation ¶
Index ¶
- func Compare(a, b interface{}) int
- type DFSTraversal
- type HashMap
- func (h *HashMap) Copy() *HashMap
- func (h *HashMap) Delete(k T)
- func (h *HashMap) Equal(other *HashMap) bool
- func (h *HashMap) Get(k T) (T, bool)
- func (h *HashMap) Hash() int
- func (h *HashMap) Iter(iter func(T, T) bool) bool
- func (h *HashMap) Len() int
- func (h *HashMap) Put(k T, v T)
- func (h *HashMap) String() string
- func (h *HashMap) Update(other *HashMap) *HashMap
- type T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
func Compare(a, b interface{}) int
Compare returns 0 if a equals b, -1 if a is less than b, and 1 if b is than a.
For comparison between values of different types, the following ordering is used: nil < bool < float64 < string < []interface{} < map[string]interface{}. Slices and maps are compared recursively. If one slice or map is a subset of the other slice or map it is considered "less than". Nil is always equal to nil.
Types ¶
type DFSTraversal ¶
type DFSTraversal interface { // Edges should return the neighbours of node "u". Edges(u T) []T // Equals should return true if node "u" equals node "v". Equals(u T, v T) bool // Visited should return true if node "u" has already been visited in this // traversal. If the same traversal is used multiple times, the state that // tracks visited nodes should be reset. Visited(u T) bool }
DFSTraversal defines the basic interface required to perform a depth first traveral.
type HashMap ¶
type HashMap struct {
// contains filtered or unexported fields
}
HashMap represents a key/value map.
func NewHashMap ¶
NewHashMap returns a new empty HashMap.
func (*HashMap) Equal ¶
Equal returns true if this HashMap equals the other HashMap. Two hash maps are equal if they contain the same key/value pairs.
func (*HashMap) Iter ¶
Iter invokes the iter function for each element in the HashMap. If the iter function returns true, iteration stops and the return value is true. If the iter function never returns true, iteration proceeds through all elements and the return value is false.
func (*HashMap) Put ¶
Put inserts a key/value pair into this HashMap. If the key is already present, the existing value is overwritten.