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
41045c0b
Commit
41045c0b
authored
Sep 30, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
24930939
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
46 deletions
+34
-46
wcfs/internal/xbtree/blib/gen-rangemap
wcfs/internal/xbtree/blib/gen-rangemap
+0
-6
wcfs/internal/xbtree/blib/rangemap.go.in
wcfs/internal/xbtree/blib/rangemap.go.in
+2
-2
wcfs/internal/xbtree/blib/rangemap_test.go
wcfs/internal/xbtree/blib/rangemap_test.go
+16
-12
wcfs/internal/xbtree/blib/rangeset.go
wcfs/internal/xbtree/blib/rangeset.go
+2
-1
wcfs/internal/xbtree/blib/rangeset_test.go
wcfs/internal/xbtree/blib/rangeset_test.go
+10
-21
wcfs/internal/xbtree/blib/zrangemap_str.go
wcfs/internal/xbtree/blib/zrangemap_str.go
+2
-2
wcfs/internal/xbtree/blib/zrangemap_void.go
wcfs/internal/xbtree/blib/zrangemap_void.go
+2
-2
No files found.
wcfs/internal/xbtree/blib/gen-rangemap
View file @
41045c0b
...
@@ -25,19 +25,13 @@ TYPE=$1
...
@@ -25,19 +25,13 @@ TYPE=$1
VALUE
=
$2
VALUE
=
$2
out
=
$3
out
=
$3
kind
=
${
KIND
,,
}
# IO -> io
Value
=
${
VALUE
^
}
input
=
$(
dirname
$0
)
/rangemap.go.in
input
=
$(
dirname
$0
)
/rangemap.go.in
echo
"// Code generated by gen-rangemap
$TYPE
$VALUE
; DO NOT EDIT."
>
$out
echo
"// Code generated by gen-rangemap
$TYPE
$VALUE
; DO NOT EDIT."
>
$out
echo
>>
$out
echo
>>
$out
sed
\
sed
\
-e
"s/<kind>/
$kind
/g"
\
-e
"s/<KIND>/
$KIND
/g"
\
-e
"s/VALUE/
$VALUE
/g"
\
-e
"s/VALUE/
$VALUE
/g"
\
-e
"s/<Value>/
$Value
/g"
\
-e
"s/
\b
RangedMap
\b
/
${
TYPE
}
/g"
\
-e
"s/
\b
RangedMap
\b
/
${
TYPE
}
/g"
\
-e
"s/
\b
RangedMapEntry
\b
/
${
TYPE
}
Entry/g"
\
-e
"s/
\b
RangedMapEntry
\b
/
${
TYPE
}
Entry/g"
\
-e
"s/
\b
vInsert
\b
/vInsert_
${
TYPE
}
/g"
\
-e
"s/
\b
vInsert
\b
/vInsert_
${
TYPE
}
/g"
\
...
...
wcfs/internal/xbtree/blib/rangemap.go.in
View file @
41045c0b
...
@@ -116,8 +116,8 @@ func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
...
@@ -116,8 +116,8 @@ func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
defer
M
.
verify
()
defer
M
.
verify
()
//
clear
range
for
r
and
insert
new
entry
//
clear
range
for
r
and
insert
new
entry
//
TODO
optimize
for
s
et
case
(
just
merge
all
covered
entries
into
one
-
//
TODO
optimize
for
s
ame
-
value
/
set
case
(
just
merge
all
covered
//
-
see
commented
AddRange
vvv
)
//
entries
into
one
-
-
see
commented
AddRange
from
set
vvv
)
i
:=
M
.
delRange
(
r
)
i
:=
M
.
delRange
(
r
)
vInsert
(&
M
.
entryv
,
i
,
e
)
vInsert
(&
M
.
entryv
,
i
,
e
)
debugfRMap
(
"
\t
insert %s
\t
-> %s
\n
"
,
e
,
M
)
debugfRMap
(
"
\t
insert %s
\t
-> %s
\n
"
,
e
,
M
)
...
...
wcfs/internal/xbtree/blib/rangemap_test.go
View file @
41045c0b
...
@@ -26,10 +26,17 @@ import (
...
@@ -26,10 +26,17 @@ import (
"testing"
"testing"
)
)
func
TestRangedMap
(
t
*
testing
.
T
)
{
type
(
type
RangedMap
=
_RangedMap_str
RangedMap
=
_RangedMap_str
type
RangedMapEntry
=
_RangedMap_strEntry
RangedMapEntry
=
_RangedMap_strEntry
)
const
(
oo
=
KeyMax
noo
=
KeyMin
)
func
TestRangedMap
(
t
*
testing
.
T
)
{
type
testEntry
struct
{
type
testEntry
struct
{
A
*
RangedMap
A
*
RangedMap
B
RangedMapEntry
B
RangedMapEntry
...
@@ -138,7 +145,7 @@ func TestRangedMap(t *testing.T) {
...
@@ -138,7 +145,7 @@ func TestRangedMap(t *testing.T) {
r
:=
B
.
KeyRange
r
:=
B
.
KeyRange
v
:=
B
.
Value
v
:=
B
.
Value
assertMHasRange
(
t
,
A
,
r
,
tt
.
Has
)
assertM
ap
HasRange
(
t
,
A
,
r
,
tt
.
Has
)
Aset
:=
A
.
Clone
()
Aset
:=
A
.
Clone
()
Adel
:=
A
.
Clone
()
Adel
:=
A
.
Clone
()
Aset
.
SetRange
(
r
,
v
)
Aset
.
SetRange
(
r
,
v
)
...
@@ -154,8 +161,8 @@ func TestRangedMap(t *testing.T) {
...
@@ -154,8 +161,8 @@ func TestRangedMap(t *testing.T) {
}
}
assertMHasRange
(
t
,
Aset
,
r
,
true
)
assertM
ap
HasRange
(
t
,
Aset
,
r
,
true
)
assertMHasRange
(
t
,
Adel
,
r
,
false
)
assertM
ap
HasRange
(
t
,
Adel
,
r
,
false
)
verifyGet
(
t
,
A
)
verifyGet
(
t
,
A
)
verifyGet
(
t
,
Aset
)
verifyGet
(
t
,
Aset
)
...
@@ -163,8 +170,8 @@ func TestRangedMap(t *testing.T) {
...
@@ -163,8 +170,8 @@ func TestRangedMap(t *testing.T) {
}
}
}
}
// assertMHasRange asserts that RangeMap M.HasRange(r) == hasOK.
// assertM
ap
HasRange asserts that RangeMap M.HasRange(r) == hasOK.
func
assertM
HasRange
(
t
*
testing
.
T
,
M
*
_RangedMap_str
,
r
KeyRange
,
hasOK
bool
)
{
func
assertM
apHasRange
(
t
*
testing
.
T
,
M
*
RangedMap
,
r
KeyRange
,
hasOK
bool
)
{
t
.
Helper
()
t
.
Helper
()
has
:=
M
.
HasRange
(
r
)
has
:=
M
.
HasRange
(
r
)
if
!
(
has
==
hasOK
)
{
if
!
(
has
==
hasOK
)
{
...
@@ -173,10 +180,7 @@ func assertMHasRange(t *testing.T, M *_RangedMap_str, r KeyRange, hasOK bool) {
...
@@ -173,10 +180,7 @@ func assertMHasRange(t *testing.T, M *_RangedMap_str, r KeyRange, hasOK bool) {
}
}
// verifyGet verifies RangedMap.Get .
// verifyGet verifies RangedMap.Get .
func
verifyGet
(
t
*
testing
.
T
,
M
*
_RangedMap_str
)
{
func
verifyGet
(
t
*
testing
.
T
,
M
*
RangedMap
)
{
type
RangedMap
=
_RangedMap_str
type
RangedMapEntry
=
_RangedMap_strEntry
t
.
Helper
()
t
.
Helper
()
var
Mranges
[]
RangedMapEntry
var
Mranges
[]
RangedMapEntry
...
...
wcfs/internal/xbtree/blib/rangeset.go
View file @
41045c0b
...
@@ -22,6 +22,7 @@ package blib
...
@@ -22,6 +22,7 @@ package blib
//go:generate ./gen-rangemap _RangedMap_void void zrangemap_void.go
//go:generate ./gen-rangemap _RangedMap_void void zrangemap_void.go
// RangedKeySet is set of Keys with adjacent keys coalesced into Ranges.
// RangedKeySet is set of Keys with adjacent keys coalesced into Ranges.
//
//
// Zero value represents empty set.
// Zero value represents empty set.
...
@@ -81,7 +82,7 @@ func (A *RangedKeySet) Difference(B *RangedKeySet) *RangedKeySet {
...
@@ -81,7 +82,7 @@ func (A *RangedKeySet) Difference(B *RangedKeySet) *RangedKeySet {
return
D
return
D
}
}
//
XXX
Intersection
//
TODO
Intersection
func
(
A
*
RangedKeySet
)
UnionInplace
(
B
*
RangedKeySet
)
{
func
(
A
*
RangedKeySet
)
UnionInplace
(
B
*
RangedKeySet
)
{
A
.
verify
()
A
.
verify
()
...
...
wcfs/internal/xbtree/blib/rangeset_test.go
View file @
41045c0b
...
@@ -42,11 +42,6 @@ func TestRangedKeySetTypes(t *testing.T) {
...
@@ -42,11 +42,6 @@ func TestRangedKeySetTypes(t *testing.T) {
}
}
}
}
const
(
oo
=
KeyMax
noo
=
KeyMin
)
func
TestRangedKeySet
(
t
*
testing
.
T
)
{
func
TestRangedKeySet
(
t
*
testing
.
T
)
{
type
testEntry
struct
{
type
testEntry
struct
{
A
,
B
*
RangedKeySet
A
,
B
*
RangedKeySet
...
@@ -122,12 +117,6 @@ func TestRangedKeySet(t *testing.T) {
...
@@ -122,12 +117,6 @@ func TestRangedKeySet(t *testing.T) {
S
(
noo
,
oo
),
// U
S
(
noo
,
oo
),
// U
S
()),
// D
S
()),
// D
E
(
S
(
5
,
7
),
// A
S
(
3
,
5
),
// B
S
(
3
,
7
),
// U
S
(
5
,
7
)),
// D
// [1,3) [5,7) + insert [3,5) -> [1,7)
// [1,3) [5,7) + insert [3,5) -> [1,7)
E
(
E
(
S
(
1
,
3
,
5
,
7
),
// A
S
(
1
,
3
,
5
,
7
),
// A
...
@@ -158,22 +147,22 @@ func TestRangedKeySet(t *testing.T) {
...
@@ -158,22 +147,22 @@ func TestRangedKeySet(t *testing.T) {
}
}
// HasRange
// HasRange
assertS
HasRange
(
t
,
A
.
AllRanges
(),
A
,
true
)
assertS
etHasRanges
(
t
,
A
,
A
.
AllRanges
()
,
true
)
assertS
HasRange
(
t
,
B
.
AllRanges
(),
B
,
true
)
assertS
etHasRanges
(
t
,
B
,
B
.
AllRanges
()
,
true
)
assertS
HasRange
(
t
,
A
.
AllRanges
(),
U
,
true
)
assertS
etHasRanges
(
t
,
U
,
A
.
AllRanges
()
,
true
)
assertS
HasRange
(
t
,
B
.
AllRanges
(),
U
,
true
)
assertS
etHasRanges
(
t
,
U
,
B
.
AllRanges
()
,
true
)
Dab
:=
D
Dab
:=
D
Dba
:=
B
.
Difference
(
A
)
Dba
:=
B
.
Difference
(
A
)
assertS
HasRange
(
t
,
Dab
.
AllRanges
(),
A
,
true
)
assertS
etHasRanges
(
t
,
A
,
Dab
.
AllRanges
()
,
true
)
assertS
HasRange
(
t
,
Dab
.
AllRanges
(),
B
,
false
)
assertS
etHasRanges
(
t
,
B
,
Dab
.
AllRanges
()
,
false
)
assertS
HasRange
(
t
,
Dba
.
AllRanges
(),
B
,
true
)
assertS
etHasRanges
(
t
,
B
,
Dba
.
AllRanges
()
,
true
)
assertS
HasRange
(
t
,
Dba
.
AllRanges
(),
A
,
false
)
assertS
etHasRanges
(
t
,
A
,
Dba
.
AllRanges
()
,
false
)
}
}
}
}
// assertS
HasRange
asserts for all ranges from rangev that RangedSet S.HasRange(r) == hasOK.
// assertS
etHasRanges
asserts for all ranges from rangev that RangedSet S.HasRange(r) == hasOK.
func
assertS
HasRange
(
t
*
testing
.
T
,
rangev
[]
KeyRange
,
S
*
RangedKeySet
,
hasOK
bool
)
{
func
assertS
etHasRanges
(
t
*
testing
.
T
,
S
*
RangedKeySet
,
rangev
[]
KeyRange
,
hasOK
bool
)
{
t
.
Helper
()
t
.
Helper
()
for
_
,
r
:=
range
rangev
{
for
_
,
r
:=
range
rangev
{
has
:=
S
.
HasRange
(
r
)
has
:=
S
.
HasRange
(
r
)
...
...
wcfs/internal/xbtree/blib/zrangemap_str.go
View file @
41045c0b
...
@@ -118,8 +118,8 @@ func (M *_RangedMap_str) SetRange(r KeyRange, v string) {
...
@@ -118,8 +118,8 @@ func (M *_RangedMap_str) SetRange(r KeyRange, v string) {
defer
M
.
verify
()
defer
M
.
verify
()
// clear range for r and insert new entry
// clear range for r and insert new entry
// TODO optimize for s
et case (just merge all covered entries into one -
// TODO optimize for s
ame-value/set case (just merge all covered
//
- see commented AddRange
vvv)
//
entries into one - - see commented AddRange from set
vvv)
i
:=
M
.
delRange
(
r
)
i
:=
M
.
delRange
(
r
)
vInsert__RangedMap_str
(
&
M
.
entryv
,
i
,
e
)
vInsert__RangedMap_str
(
&
M
.
entryv
,
i
,
e
)
debugf_RangedMap_str
(
"
\t
insert %s
\t
-> %s
\n
"
,
e
,
M
)
debugf_RangedMap_str
(
"
\t
insert %s
\t
-> %s
\n
"
,
e
,
M
)
...
...
wcfs/internal/xbtree/blib/zrangemap_void.go
View file @
41045c0b
...
@@ -118,8 +118,8 @@ func (M *_RangedMap_void) SetRange(r KeyRange, v void) {
...
@@ -118,8 +118,8 @@ func (M *_RangedMap_void) SetRange(r KeyRange, v void) {
defer
M
.
verify
()
defer
M
.
verify
()
// clear range for r and insert new entry
// clear range for r and insert new entry
// TODO optimize for s
et case (just merge all covered entries into one -
// TODO optimize for s
ame-value/set case (just merge all covered
//
- see commented AddRange
vvv)
//
entries into one - - see commented AddRange from set
vvv)
i
:=
M
.
delRange
(
r
)
i
:=
M
.
delRange
(
r
)
vInsert__RangedMap_void
(
&
M
.
entryv
,
i
,
e
)
vInsert__RangedMap_void
(
&
M
.
entryv
,
i
,
e
)
debugf_RangedMap_void
(
"
\t
insert %s
\t
-> %s
\n
"
,
e
,
M
)
debugf_RangedMap_void
(
"
\t
insert %s
\t
-> %s
\n
"
,
e
,
M
)
...
...
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