Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
a18c7fc5
Commit
a18c7fc5
authored
Jun 03, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
348288f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
20 deletions
+22
-20
wcfs/internal/xbtree/rangeset.go
wcfs/internal/xbtree/rangeset.go
+21
-19
wcfs/internal/xbtree/rangeset_test.go
wcfs/internal/xbtree/rangeset_test.go
+1
-1
No files found.
wcfs/internal/xbtree/rangeset.go
View file @
a18c7fc5
...
...
@@ -30,37 +30,39 @@ type Range struct {
hi_
Key
// NOTE _not_ hi) to avoid overflow at ∞; hi = hi_ + 1
}
// RangeSet is set of non-overlapping Key ranges.
// XXX RangeSet is set of Keys with adjacent keys coaleced into Ranges.
// RangeSet is set of Keys with adjacent keys coaleced into Ranges.
// XXX -> RangedSet ?
type
RangeSet
struct
{
// TODO rework to use BTree lo->hi_ instead if performance turns out to
// be not acceptable
// TODO rework to use BTree lo->hi_ instead if in practice in treediff,
// and other usage places, N(ranges) turns out to be not small
// (i.e. performance turns out to be not acceptable)
rangev
[]
Range
// lo↑
}
// XXX Add/Del - just add/del key
// Add adds key k to the set.
func
(
S
*
RangeSet
)
Add
(
k
Key
)
{
S
.
AddRange
(
Range
{
lo
:
k
,
hi_
:
k
})
}
// Del removes key k from the set.
func
(
S
*
RangeSet
)
Del
(
k
Key
)
{
S
.
DelRange
(
Range
{
lo
:
k
,
hi_
:
k
})
}
// XXX Has?
// Add adds Range r to the set of keys. // XXX -> UnionInplace1 ?
// XXX -> AddRange ?
func
(
S
*
RangeSet
)
Add
(
r
Range
)
{
// AddRange adds Range r to the set.
func
(
S
*
RangeSet
)
AddRange
(
r
Range
)
{
panic
(
"TODO"
)
// XXX
}
// Del removes Range r from the set of keys. // XXX -> DifferenceInplace1 ?
// XXX -> DelRange?
func
(
S
*
RangeSet
)
Del
(
r
Range
)
{
// Del removes Range r from the set.
func
(
S
*
RangeSet
)
DelRange
(
r
Range
)
{
panic
(
"TODO"
)
// XXX
}
// XXX Has?
// XXX AddKey ?
// XXX DelKey ?
// XXX HasKey
// Union returns RangeSet(A.keys | B.keys).
func
(
A
*
RangeSet
)
Union
(
B
*
RangeSet
)
*
RangeSet
{
...
...
@@ -85,7 +87,7 @@ func (A *RangeSet) UnionInplace(B *RangeSet) {
// XXX dumb
for
_
,
r
:=
range
B
.
rangev
{
A
.
Add
(
r
)
A
.
Add
Range
(
r
)
}
}
...
...
@@ -96,7 +98,7 @@ func (A *RangeSet) DifferenceInplace(B *RangeSet) {
// XXX dumb
for
_
,
r
:=
range
B
.
rangev
{
A
.
Del
(
r
)
A
.
Del
Range
(
r
)
}
}
...
...
wcfs/internal/xbtree/rangeset_test.go
View file @
a18c7fc5
...
...
@@ -46,7 +46,7 @@ func TestRangeSet(t *testing.T) {
}
S
:=
&
RangeSet
{}
for
i
:=
0
;
i
<
l
/
2
;
i
++
{
S
.
Add
(
Range
{
kv
[
2
*
i
],
kv
[
2
*
i
+
1
]})
S
.
Add
Range
(
Range
{
kv
[
2
*
i
],
kv
[
2
*
i
+
1
]})
}
return
S
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment