Commit ecd23f2f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4e1a25df
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
package xbtree package xbtree
// set of [lo,hi) Key ranges. // set of [lo,hi) Key ranges.
import (
"fmt"
)
// Range represents [lo,hi) Key range. // Range represents [lo,hi) Key range.
type Range struct { type Range struct {
lo Key lo Key
...@@ -69,12 +73,19 @@ func (A *RangeSet) Difference(B *RangeSet) *RangeSet { ...@@ -69,12 +73,19 @@ func (A *RangeSet) Difference(B *RangeSet) *RangeSet {
// -------- // --------
// Clone returns copy of the set.
func (orig *RangeSet) Clone() *RangeSet {
klon := &RangeSet{}
klon.rangev = append(klon.rangev, orig.rangev...)
return klon
}
// XXX RangeSet.verify to check ranges are not overlapping and ↑ // XXX RangeSet.verify to check ranges are not overlapping and ↑
func (r Range) String() string { func (r Range) String() string {
slo := "-∞"; if rn.lo > KeyMin { slo = fmt.Sprintf("%v", rn.lo) } slo := "-∞"; if r.lo > KeyMin { slo = fmt.Sprintf("%v", r.lo) }
shi := "∞"; if rn.hi_ < KeyMax { shi = fmt.Sprintf("%v", rn.hi_+1) } shi := "∞"; if r.hi_ < KeyMax { shi = fmt.Sprintf("%v", r.hi_+1) }
return fmt.Sprintf("[%s,%s)", slo, shi) return fmt.Sprintf("[%s,%s)", slo, shi)
} }
......
...@@ -172,7 +172,7 @@ func (orig *ΔBtail) clone() *ΔBtail { ...@@ -172,7 +172,7 @@ func (orig *ΔBtail) clone() *ΔBtail {
klon.byRoot = make(map[zodb.Oid]*ΔTtail, len(orig.byRoot)) klon.byRoot = make(map[zodb.Oid]*ΔTtail, len(orig.byRoot))
for root, origΔTtail := range orig.byRoot { for root, origΔTtail := range orig.byRoot {
klonΔTtail := &ΔTtail{} klonΔTtail := &ΔTtail{}
klonΔTtail.vδT = append(klonΔTtail.vδT, origΔTtail.vδT...) klonΔTtail.vδT = append(nil, origΔTtail.vδT...)
klonΔTtail.KVAtTail = make(map[Key]Value, len(origΔTtail.KVAtTail)) klonΔTtail.KVAtTail = make(map[Key]Value, len(origΔTtail.KVAtTail))
for k, v := range origΔTtail.KVAtTail { for k, v := range origΔTtail.KVAtTail {
klonΔTtail.KVAtTail[k] = v klonΔTtail.KVAtTail[k] = v
......
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