mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-24 10:30:48 -06:00
This is done by creating a cursor for each set. This is a cursor for the actual values in the sets. We then pick the "smallest" value from the cursors and advance that cursor. This continues until we have exhausted all the cursors. setA.Union(set0, ... setN) The time complexity is O(len(setA) + len(set0)) + ... len(setN))
32 lines
706 B
Go
32 lines
706 B
Go
package types
|
|
|
|
import "github.com/attic-labs/noms/d"
|
|
|
|
func assertType(t Type, v ...Value) {
|
|
if t.Kind() != ValueKind {
|
|
for _, v := range v {
|
|
d.Chk.True(t.Equals(v.Type()), "Invalid type. Expected: %s, found: %s", t.Describe(), v.Type().Describe())
|
|
}
|
|
}
|
|
}
|
|
|
|
func assertSetsSameType(s Set, v ...Set) {
|
|
if s.elemType().Kind() != ValueKind {
|
|
t := s.Type()
|
|
for _, v := range v {
|
|
d.Chk.True(t.Equals(v.Type()))
|
|
}
|
|
}
|
|
}
|
|
|
|
func assertMapElemTypes(m mapLeaf, v ...Value) {
|
|
elemTypes := m.elemTypes()
|
|
keyType := elemTypes[0]
|
|
valueType := elemTypes[0]
|
|
if keyType.Kind() != ValueKind || valueType.Kind() != ValueKind {
|
|
for i, v := range v {
|
|
d.Chk.True(elemTypes[i%2].Equals(v.Type()))
|
|
}
|
|
}
|
|
}
|