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
9631b4e6
Commit
9631b4e6
authored
Jun 03, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
42b6e542
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
2 deletions
+58
-2
wcfs/internal/xbtree/rangeset.go
wcfs/internal/xbtree/rangeset.go
+58
-2
No files found.
wcfs/internal/xbtree/rangeset.go
View file @
9631b4e6
...
@@ -102,7 +102,7 @@ func (S *RangeSet) AddRange(r Range) {
...
@@ -102,7 +102,7 @@ func (S *RangeSet) AddRange(r Range) {
S
.
rangev
[
:
ilo
],
append
([]
Range
{
S
.
rangev
[
:
ilo
],
append
([]
Range
{
Range
{
lo
,
hi_
}},
Range
{
lo
,
hi_
}},
S
.
rangev
[
jhi
:
]
...
)
...
)
S
.
rangev
[
jhi
:
]
...
)
...
)
debugfRSet
(
"
\t
merge [%d:%d]
\t
-> %s
\n
"
,
ilo
,
jhi
,
S
)
debugfRSet
(
"
\t
merge
S
[%d:%d]
\t
-> %s
\n
"
,
ilo
,
jhi
,
S
)
}
}
jhi
=
-
1
// no longer valid
jhi
=
-
1
// no longer valid
...
@@ -162,7 +162,63 @@ func (S *RangeSet) DelRange(r Range) {
...
@@ -162,7 +162,63 @@ func (S *RangeSet) DelRange(r Range) {
S
.
verify
()
S
.
verify
()
defer
S
.
verify
()
defer
S
.
verify
()
panic
(
"TODO"
)
// XXX
// find first ilo: r.lo < [ilo].hi
l
:=
len
(
S
.
rangev
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
return
r
.
lo
<=
S
.
rangev
[
i
]
.
hi_
})
debugfRSet
(
"
\t
ilo: %d
\n
"
,
ilo
)
if
ilo
==
l
{
// not found
debugfRSet
(
"
\t
non-overlap right"
)
return
}
// find last jhi: [jhi].lo < r.hi
jhi
:=
ilo
for
;;
jhi
++
{
if
jhi
==
l
{
break
}
if
S
.
rangev
[
jhi
]
.
lo
<=
r
.
hi_
{
continue
}
break
}
debugfRSet
(
"
\t
jhi: %d
\n
"
,
jhi
)
if
jhi
==
0
{
debugfRSet
(
"
\t
non-overlap left"
)
return
}
// [ilo+1:jhi-1] should be deleted
// [ilo] and [jhi-1] overlap with [r.lo,r.hi) - they shuold be deleted or shrinked.
if
S
.
rangev
[
ilo
]
.
lo
<
r
.
lo
{
// shrink left
S
.
rangev
=
append
(
S
.
rangev
[
:
ilo
],
append
([]
Range
{
Range
{
S
.
rangev
[
ilo
]
.
lo
,
r
.
lo
-
1
}},
S
.
rangev
[
ilo
+
1
:
]
...
)
...
)
ilo
++
debugfRSet
(
"
\t
shrink left
\t
-> %s
\n
"
,
S
)
}
if
r
.
hi_
<
S
.
rangev
[
jhi
-
1
]
.
hi_
{
// shrink right
S
.
rangev
=
append
(
S
.
rangev
[
:
jhi
-
1
],
append
([]
Range
{
Range
{
r
.
hi_
+
1
,
S
.
rangev
[
jhi
-
1
]
.
hi_
}},
S
.
rangev
[
jhi
:
]
...
)
...
)
jhi
--
debugfRSet
(
"
\t
shrink right
\t
-> %s
\n
"
,
S
)
}
if
(
jhi
-
ilo
)
>
1
{
S
.
rangev
=
append
(
S
.
rangev
[
:
ilo
],
S
.
rangev
[
jhi
:
]
...
)
debugfRSet
(
"
\t
delete S[%d:%d]
\t
-> %s
\n
"
,
ilo
,
jhi
,
S
)
}
// done
}
}
...
...
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