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