Commit 348288f6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a9a791c5
...@@ -147,7 +147,7 @@ func (A PPTreeSubSet) Union(B PPTreeSubSet) PPTreeSubSet { ...@@ -147,7 +147,7 @@ func (A PPTreeSubSet) Union(B PPTreeSubSet) PPTreeSubSet {
// In other words it adds B nodes to A. // In other words it adds B nodes to A.
func (A PPTreeSubSet) UnionInplace(B PPTreeSubSet) { func (A PPTreeSubSet) UnionInplace(B PPTreeSubSet) {
if debugPPSet { if debugPPSet {
fmt.Printf("\n\nUnionInplace:\n") fmt.Printf("\n\nUnion:\n")
fmt.Printf(" A: %s\n", A) fmt.Printf(" A: %s\n", A)
fmt.Printf(" B: %s\n", B) fmt.Printf(" B: %s\n", B)
defer fmt.Printf("->U: %s\n", A) defer fmt.Printf("->U: %s\n", A)
...@@ -175,7 +175,7 @@ func (A PPTreeSubSet) Difference(B PPTreeSubSet) PPTreeSubSet { ...@@ -175,7 +175,7 @@ func (A PPTreeSubSet) Difference(B PPTreeSubSet) PPTreeSubSet {
// In other words it removes B nodes from A while still maintaining A as PP-connected. // In other words it removes B nodes from A while still maintaining A as PP-connected.
func (A PPTreeSubSet) DifferenceInplace(B PPTreeSubSet) { func (A PPTreeSubSet) DifferenceInplace(B PPTreeSubSet) {
if debugPPSet { if debugPPSet {
fmt.Printf("\n\nDifferenceInplace:\n") fmt.Printf("\n\nDifference:\n")
fmt.Printf(" A: %s\n", A) fmt.Printf(" A: %s\n", A)
fmt.Printf(" B: %s\n", B) fmt.Printf(" B: %s\n", B)
defer fmt.Printf("->D: %s\n", A) defer fmt.Printf("->D: %s\n", A)
...@@ -192,7 +192,7 @@ func (A PPTreeSubSet) DifferenceInplace(B PPTreeSubSet) { ...@@ -192,7 +192,7 @@ func (A PPTreeSubSet) DifferenceInplace(B PPTreeSubSet) {
func (A PPTreeSubSet) xUnionInplace(B PPTreeSubSet) { func (A PPTreeSubSet) xUnionInplace(B PPTreeSubSet) {
if debugPPSet { if debugPPSet {
fmt.Printf("\n\n xUnionInplace:\n") fmt.Printf("\n\n xUnion:\n")
fmt.Printf(" a: %s\n", A) fmt.Printf(" a: %s\n", A)
fmt.Printf(" b: %s\n", B) fmt.Printf(" b: %s\n", B)
defer fmt.Printf(" ->u: %s\n", A) defer fmt.Printf(" ->u: %s\n", A)
...@@ -226,7 +226,7 @@ func (A PPTreeSubSet) xUnionInplace(B PPTreeSubSet) { ...@@ -226,7 +226,7 @@ func (A PPTreeSubSet) xUnionInplace(B PPTreeSubSet) {
func (A PPTreeSubSet) xDifferenceInplace(B PPTreeSubSet) { func (A PPTreeSubSet) xDifferenceInplace(B PPTreeSubSet) {
if debugPPSet { if debugPPSet {
fmt.Printf("\n\n xDifferenceInplace:\n") fmt.Printf("\n\n xDifference:\n")
fmt.Printf(" a: %s\n", A) fmt.Printf(" a: %s\n", A)
fmt.Printf(" b: %s\n", B) fmt.Printf(" b: %s\n", B)
defer fmt.Printf(" ->d: %s\n", A) defer fmt.Printf(" ->d: %s\n", A)
......
...@@ -31,18 +31,25 @@ type Range struct { ...@@ -31,18 +31,25 @@ type Range struct {
} }
// RangeSet is set of non-overlapping Key ranges. // RangeSet is set of non-overlapping Key ranges.
// XXX RangeSet is set of Keys with adjacent keys coaleced into Ranges.
// XXX -> RangedSet ?
type RangeSet struct { type RangeSet struct {
// TODO rework to use BTree lo->hi_ instead if performance turns out to // TODO rework to use BTree lo->hi_ instead if performance turns out to
// be not acceptable // be not acceptable
rangev []Range // lo↑ rangev []Range // lo↑
} }
// XXX Add/Del - just add/del key
// Add adds Range r to the set of keys. // XXX -> UnionInplace1 ? // Add adds Range r to the set of keys. // XXX -> UnionInplace1 ?
// XXX -> AddRange ?
func (S *RangeSet) Add(r Range) { func (S *RangeSet) Add(r Range) {
panic("TODO") // XXX panic("TODO") // XXX
} }
// Del removes Range r from the set of keys. // XXX -> DifferenceInplace1 ? // Del removes Range r from the set of keys. // XXX -> DifferenceInplace1 ?
// XXX -> DelRange?
func (S *RangeSet) Del(r Range) { func (S *RangeSet) Del(r Range) {
panic("TODO") // XXX panic("TODO") // XXX
} }
...@@ -118,12 +125,12 @@ func (S *RangeSet) verify() { ...@@ -118,12 +125,12 @@ func (S *RangeSet) verify() {
hi_Prev := KeyMin hi_Prev := KeyMin
for i, r := range S.rangev { for i, r := range S.rangev {
if !(r.hi_ >= r.lo) { if !(hi_Prev <= r.lo) {
badf("[%d]: hi_ < lo", i)
}
if !(r.lo >= hi_Prev) {
badf("[%d]: lo < hi_Prev", i) badf("[%d]: lo < hi_Prev", i)
} }
if !(r.lo < r.hi_) {
badf("[%d]: lo >= hi_", i)
}
hi_Prev = r.hi_ hi_Prev = r.hi_
} }
} }
......
...@@ -64,7 +64,9 @@ func TestRangeSet(t *testing.T) { ...@@ -64,7 +64,9 @@ func TestRangeSet(t *testing.T) {
S(1,2), // U S(1,2), // U
S()), // D S()), // D
// XXX // XXX Add -> merge
// XXX Del -> split
// XXX several ranges -> Del(-oo, oo) -> ø
} }
for _, tt := range testv { for _, tt := range testv {
......
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