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
3b7b69e6
Commit
3b7b69e6
authored
Sep 30, 2021
by
Kirill Smelkov
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X fixes for empty set/range
parent
6342560d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
6 deletions
+40
-6
wcfs/internal/xbtree/blib/rangemap.go.in
wcfs/internal/xbtree/blib/rangemap.go.in
+11
-1
wcfs/internal/xbtree/blib/rangemap_test.go
wcfs/internal/xbtree/blib/rangemap_test.go
+7
-3
wcfs/internal/xbtree/blib/zrangemap_str.go
wcfs/internal/xbtree/blib/zrangemap_str.go
+11
-1
wcfs/internal/xbtree/blib/zrangemap_void.go
wcfs/internal/xbtree/blib/zrangemap_void.go
+11
-1
No files found.
wcfs/internal/xbtree/blib/rangemap.go.in
View file @
3b7b69e6
...
@@ -116,7 +116,7 @@ func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
...
@@ -116,7 +116,7 @@ func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
defer
M
.
verify
()
defer
M
.
verify
()
if
r
.
Empty
()
{
if
r
.
Empty
()
{
return
//
XXX
or
panic
?
return
}
}
//
clear
range
for
r
and
insert
new
entry
//
clear
range
for
r
and
insert
new
entry
...
@@ -235,11 +235,17 @@ func (M *RangedMap) DelRange(r KeyRange) {
...
@@ -235,11 +235,17 @@ func (M *RangedMap) DelRange(r KeyRange) {
M
.
verify
()
M
.
verify
()
defer
M
.
verify
()
defer
M
.
verify
()
if
r
.
Empty
()
{
return
}
M
.
delRange
(
r
)
M
.
delRange
(
r
)
}
}
//
delRange
deletes
range
r
from
the
map
and
returns
.
entryv
index
where
r
//
delRange
deletes
range
r
from
the
map
and
returns
.
entryv
index
where
r
//
should
be
inserted
/
appended
if
needed
.
//
should
be
inserted
/
appended
if
needed
.
//
//
r
must
be
!empty.
func
(
M
*
RangedMap
)
delRange
(
r
KeyRange
)
(
i
int
)
{
func
(
M
*
RangedMap
)
delRange
(
r
KeyRange
)
(
i
int
)
{
//
find
first
ilo
:
r
.
Lo
<
[
ilo
].
hi
//
find
first
ilo
:
r
.
Lo
<
[
ilo
].
hi
l
:=
len
(
M
.
entryv
)
l
:=
len
(
M
.
entryv
)
...
@@ -315,6 +321,10 @@ func (M *RangedMap) HasRange(r KeyRange) (yes bool) {
...
@@ -315,6 +321,10 @@ func (M *RangedMap) HasRange(r KeyRange) (yes bool) {
M
.
verify
()
M
.
verify
()
if
r
.
Empty
()
{
return
true
}
//
find
first
ilo
:
r
.
lo
<
[
ilo
].
hi
//
find
first
ilo
:
r
.
lo
<
[
ilo
].
hi
l
:=
len
(
M
.
entryv
)
l
:=
len
(
M
.
entryv
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
...
...
wcfs/internal/xbtree/blib/rangemap_test.go
View file @
3b7b69e6
...
@@ -101,7 +101,7 @@ func TestRangedMap(t *testing.T) {
...
@@ -101,7 +101,7 @@ func TestRangedMap(t *testing.T) {
X
(
0
,
0
,
x
),
// X
X
(
0
,
0
,
x
),
// X
M
(),
// Set
M
(),
// Set
M
(),
// Del
M
(),
// Del
n
),
// Has
y
),
// Has
// empty vs !empty
// empty vs !empty
E
(
E
(
...
@@ -117,7 +117,7 @@ func TestRangedMap(t *testing.T) {
...
@@ -117,7 +117,7 @@ func TestRangedMap(t *testing.T) {
X
(
0
,
0
,
x
),
// X
X
(
0
,
0
,
x
),
// X
M
(
1
,
2
,
a
),
// Set
M
(
1
,
2
,
a
),
// Set
M
(
1
,
2
,
a
),
// Del
M
(
1
,
2
,
a
),
// Del
y
),
// Has
XXX ok
y
),
// Has
// basic change
// basic change
E
(
E
(
...
@@ -226,7 +226,11 @@ func TestRangedMap(t *testing.T) {
...
@@ -226,7 +226,11 @@ func TestRangedMap(t *testing.T) {
}
}
assertMapHasRange
(
t
,
Mset
,
r
,
true
)
assertMapHasRange
(
t
,
Mset
,
r
,
true
)
assertMapHasRange
(
t
,
Mdel
,
r
,
false
)
rInMdel
:=
false
if
r
.
Empty
()
{
rInMdel
=
true
}
assertMapHasRange
(
t
,
Mdel
,
r
,
rInMdel
)
verifyGet
(
t
,
M
)
verifyGet
(
t
,
M
)
verifyGet
(
t
,
Mset
)
verifyGet
(
t
,
Mset
)
...
...
wcfs/internal/xbtree/blib/zrangemap_str.go
View file @
3b7b69e6
...
@@ -118,7 +118,7 @@ func (M *_RangedMap_str) SetRange(r KeyRange, v string) {
...
@@ -118,7 +118,7 @@ func (M *_RangedMap_str) SetRange(r KeyRange, v string) {
defer
M
.
verify
()
defer
M
.
verify
()
if
r
.
Empty
()
{
if
r
.
Empty
()
{
return
// XXX or panic?
return
}
}
// clear range for r and insert new entry
// clear range for r and insert new entry
...
@@ -237,11 +237,17 @@ func (M *_RangedMap_str) DelRange(r KeyRange) {
...
@@ -237,11 +237,17 @@ func (M *_RangedMap_str) DelRange(r KeyRange) {
M
.
verify
()
M
.
verify
()
defer
M
.
verify
()
defer
M
.
verify
()
if
r
.
Empty
()
{
return
}
M
.
delRange
(
r
)
M
.
delRange
(
r
)
}
}
// delRange deletes range r from the map and returns .entryv index where r
// delRange deletes range r from the map and returns .entryv index where r
// should be inserted/appended if needed.
// should be inserted/appended if needed.
//
// r must be !empty.
func
(
M
*
_RangedMap_str
)
delRange
(
r
KeyRange
)
(
i
int
)
{
func
(
M
*
_RangedMap_str
)
delRange
(
r
KeyRange
)
(
i
int
)
{
// find first ilo: r.Lo < [ilo].hi
// find first ilo: r.Lo < [ilo].hi
l
:=
len
(
M
.
entryv
)
l
:=
len
(
M
.
entryv
)
...
@@ -317,6 +323,10 @@ func (M *_RangedMap_str) HasRange(r KeyRange) (yes bool) {
...
@@ -317,6 +323,10 @@ func (M *_RangedMap_str) HasRange(r KeyRange) (yes bool) {
M
.
verify
()
M
.
verify
()
if
r
.
Empty
()
{
return
true
}
// find first ilo: r.lo < [ilo].hi
// find first ilo: r.lo < [ilo].hi
l
:=
len
(
M
.
entryv
)
l
:=
len
(
M
.
entryv
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
...
...
wcfs/internal/xbtree/blib/zrangemap_void.go
View file @
3b7b69e6
...
@@ -118,7 +118,7 @@ func (M *_RangedMap_void) SetRange(r KeyRange, v void) {
...
@@ -118,7 +118,7 @@ func (M *_RangedMap_void) SetRange(r KeyRange, v void) {
defer
M
.
verify
()
defer
M
.
verify
()
if
r
.
Empty
()
{
if
r
.
Empty
()
{
return
// XXX or panic?
return
}
}
// clear range for r and insert new entry
// clear range for r and insert new entry
...
@@ -237,11 +237,17 @@ func (M *_RangedMap_void) DelRange(r KeyRange) {
...
@@ -237,11 +237,17 @@ func (M *_RangedMap_void) DelRange(r KeyRange) {
M
.
verify
()
M
.
verify
()
defer
M
.
verify
()
defer
M
.
verify
()
if
r
.
Empty
()
{
return
}
M
.
delRange
(
r
)
M
.
delRange
(
r
)
}
}
// delRange deletes range r from the map and returns .entryv index where r
// delRange deletes range r from the map and returns .entryv index where r
// should be inserted/appended if needed.
// should be inserted/appended if needed.
//
// r must be !empty.
func
(
M
*
_RangedMap_void
)
delRange
(
r
KeyRange
)
(
i
int
)
{
func
(
M
*
_RangedMap_void
)
delRange
(
r
KeyRange
)
(
i
int
)
{
// find first ilo: r.Lo < [ilo].hi
// find first ilo: r.Lo < [ilo].hi
l
:=
len
(
M
.
entryv
)
l
:=
len
(
M
.
entryv
)
...
@@ -317,6 +323,10 @@ func (M *_RangedMap_void) HasRange(r KeyRange) (yes bool) {
...
@@ -317,6 +323,10 @@ func (M *_RangedMap_void) HasRange(r KeyRange) (yes bool) {
M
.
verify
()
M
.
verify
()
if
r
.
Empty
()
{
return
true
}
// find first ilo: r.lo < [ilo].hi
// find first ilo: r.lo < [ilo].hi
l
:=
len
(
M
.
entryv
)
l
:=
len
(
M
.
entryv
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
...
...
Kirill Smelkov
@kirr
mentioned in commit
b7c560c5
·
Oct 27, 2021
mentioned in commit
b7c560c5
mentioned in commit b7c560c5fd08d93518d3d20ec0633fcbdcd1dc16
Toggle commit list
Kirill Smelkov
@kirr
mentioned in commit
1f2cd49d
·
Oct 28, 2021
mentioned in commit
1f2cd49d
mentioned in commit 1f2cd49d230d897a9e006987d0d3a26df4987a31
Toggle commit list
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