Files
dolt/types/assert.go
Erik Arvidsson b8be6908f8 Implement Set Union
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))
2015-12-17 10:18:04 -05:00

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()))
}
}
}