Commit 8ab1fe64 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 704483e5
...@@ -56,3 +56,53 @@ func (s Set) Elements() []VALUE { ...@@ -56,3 +56,53 @@ func (s Set) Elements() []VALUE {
} }
return ev return ev
} }
// Union returns s t
func (s Set) Union(t Set) Set {
u := Set{}
for v := range s {
u.Add(v)
}
for v := range t {
u.Add(v)
}
return u
}
// Intersection returns s t
func (s Set) Intersection(t Set) Set {
i := Set{}
for v := range s {
if t.Has(v) {
i.Add(v)
}
}
return i
}
// Difference returns s\t.
func (s Set) Difference(t Set) Set {
d := Set{}
for v := range s {
if !t.Has(v) {
d.Add(v)
}
}
return d
}
// SymmetricDifference returns s Δ t.
func (s Set) SymmetricDifference(t Set) Set {
d := Set{}
for v := range s {
if !t.Has(v) {
d.Add(v)
}
}
for v := range t {
if !s.Has(v) {
d.Add(v)
}
}
return d
}
...@@ -58,3 +58,53 @@ func (s SetBigFile) Elements() []*BigFile { ...@@ -58,3 +58,53 @@ func (s SetBigFile) Elements() []*BigFile {
} }
return ev return ev
} }
// Union returns s ∪ t
func (s SetBigFile) Union(t SetBigFile) SetBigFile {
u := SetBigFile{}
for v := range s {
u.Add(v)
}
for v := range t {
u.Add(v)
}
return u
}
// Intersection returns s ∩ t
func (s SetBigFile) Intersection(t SetBigFile) SetBigFile {
i := SetBigFile{}
for v := range s {
if t.Has(v) {
i.Add(v)
}
}
return i
}
// Difference returns s\t.
func (s SetBigFile) Difference(t SetBigFile) SetBigFile {
d := SetBigFile{}
for v := range s {
if !t.Has(v) {
d.Add(v)
}
}
return d
}
// SymmetricDifference returns s Δ t.
func (s SetBigFile) SymmetricDifference(t SetBigFile) SetBigFile {
d := SetBigFile{}
for v := range s {
if !t.Has(v) {
d.Add(v)
}
}
for v := range t {
if !s.Has(v) {
d.Add(v)
}
}
return d
}
...@@ -58,3 +58,53 @@ func (s SetI64) Elements() []int64 { ...@@ -58,3 +58,53 @@ func (s SetI64) Elements() []int64 {
} }
return ev return ev
} }
// Union returns s ∪ t
func (s SetI64) Union(t SetI64) SetI64 {
u := SetI64{}
for v := range s {
u.Add(v)
}
for v := range t {
u.Add(v)
}
return u
}
// Intersection returns s ∩ t
func (s SetI64) Intersection(t SetI64) SetI64 {
i := SetI64{}
for v := range s {
if t.Has(v) {
i.Add(v)
}
}
return i
}
// Difference returns s\t.
func (s SetI64) Difference(t SetI64) SetI64 {
d := SetI64{}
for v := range s {
if !t.Has(v) {
d.Add(v)
}
}
return d
}
// SymmetricDifference returns s Δ t.
func (s SetI64) SymmetricDifference(t SetI64) SetI64 {
d := SetI64{}
for v := range s {
if !t.Has(v) {
d.Add(v)
}
}
for v := range t {
if !s.Has(v) {
d.Add(v)
}
}
return d
}
...@@ -58,3 +58,53 @@ func (s SetOid) Elements() []Oid { ...@@ -58,3 +58,53 @@ func (s SetOid) Elements() []Oid {
} }
return ev return ev
} }
// Union returns s ∪ t
func (s SetOid) Union(t SetOid) SetOid {
u := SetOid{}
for v := range s {
u.Add(v)
}
for v := range t {
u.Add(v)
}
return u
}
// Intersection returns s ∩ t
func (s SetOid) Intersection(t SetOid) SetOid {
i := SetOid{}
for v := range s {
if t.Has(v) {
i.Add(v)
}
}
return i
}
// Difference returns s\t.
func (s SetOid) Difference(t SetOid) SetOid {
d := SetOid{}
for v := range s {
if !t.Has(v) {
d.Add(v)
}
}
return d
}
// SymmetricDifference returns s Δ t.
func (s SetOid) SymmetricDifference(t SetOid) SetOid {
d := SetOid{}
for v := range s {
if !t.Has(v) {
d.Add(v)
}
}
for v := range t {
if !s.Has(v) {
d.Add(v)
}
}
return d
}
...@@ -161,6 +161,7 @@ type ΔValue struct { ...@@ -161,6 +161,7 @@ type ΔValue struct {
// XXX -> multiple readers / single writer? // XXX -> multiple readers / single writer?
// //
// See also zodb.ΔTail // See also zodb.ΔTail
// XXX naming -> ΔBTail ?
type ΔBtail struct { type ΔBtail struct {
// raw ZODB changes; Kept to rebuild δBtail/byRoot after new Track. // raw ZODB changes; Kept to rebuild δBtail/byRoot after new Track.
// includes all changed objects, not only tracked ones. // includes all changed objects, not only tracked ones.
...@@ -494,6 +495,12 @@ func (tidx trackIndex) AddPath(path []zodb.Oid) { ...@@ -494,6 +495,12 @@ func (tidx trackIndex) AddPath(path []zodb.Oid) {
} }
} }
// rebuild rebuilds ΔBtree taking trackNew requests into account. XXX
// XXX place
func (δBtail *ΔBtail) rebuild() {
panic("TODO")
}
// Update updates δB with per-object level ZODB changes. // Update updates δB with per-object level ZODB changes.
// //
// Only those objects from δZ that belong to tracked set are guaranteed to be // Only those objects from δZ that belong to tracked set are guaranteed to be
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment