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
7829c494
Commit
7829c494
authored
Sep 27, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1c847f19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
11 deletions
+40
-11
wcfs/internal/xbtree/blib/rangemap.go.in
wcfs/internal/xbtree/blib/rangemap.go.in
+40
-11
No files found.
wcfs/internal/xbtree/blib/rangemap.go.in
View file @
7829c494
...
@@ -44,6 +44,13 @@ type RangeMapEntry struct {
...
@@ -44,6 +44,13 @@ type RangeMapEntry struct {
Value
VALUE
Value
VALUE
}
}
//
Get
returns
value
associated
with
key
k
.
func
(
M
*
RangedMap
)
Get
(
k
Key
)
VALUE
{
v
,
_
:=
M
.
Get_
(
k
)
return
v
}
//
Set
changes
M
to
map
key
k
to
value
v
.
//
Set
changes
M
to
map
key
k
to
value
v
.
func
(
M
*
RangedMap
)
Set
(
k
Key
,
v
VALUE
)
{
func
(
M
*
RangedMap
)
Set
(
k
Key
,
v
VALUE
)
{
M
.
SetRange
(
KeyRange
{
Lo
:
k
,
Hi_
:
k
},
v
)
M
.
SetRange
(
KeyRange
{
Lo
:
k
,
Hi_
:
k
},
v
)
...
@@ -60,17 +67,39 @@ func (M *RangedMap) Has(k Key) bool {
...
@@ -60,17 +67,39 @@ func (M *RangedMap) Has(k Key) bool {
return
ok
return
ok
}
}
//
Get
returns
value
associated
with
key
k
.
func
(
M
*
RangedMap
)
Get
(
k
Key
)
VALUE
{
v
,
_
:=
M
.
Get_
(
k
)
return
v
}
//
Get_
is
comma
-
ok
version
of
Get
.
//
Get_
is
comma
-
ok
version
of
Get
.
func
(
M
*
RangedMap
)
Get_
(
k
Key
)
(
VALUE
,
bool
)
{
func
(
M
*
RangedMap
)
Get_
(
k
Key
)
(
v
VALUE
,
ok
bool
)
{
panic
(
"TODO"
)
//
XXX
if
traceRangeMap
{
fmt
.
Printf
(
"
\n\n
Get_:
\n
"
)
fmt
.
Printf
(
" M: %s
\n
"
,
M
)
fmt
.
Printf
(
" k: %s
\n
"
,
k
)
defer
func
()
{
fmt
.
Printf
(
"->·: %v, %t
\n
"
,
v
,
ok
)
}()
}
M
.
verify
()
//
find
first
ilo
:
k
<
[
ilo
].
hi
l
:=
len
(
M
.
entryv
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
return
k
<=
M
.
entryv
[
i
].
Hi_
})
debugfRMap
(
"
\t
ilo: %d
\n
"
,
ilo
)
if
ilo
==
l
{
//
not
found
return
}
e
:=
M
.
entryv
[
ilo
]
if
!(e.Lo <= k) { // not found
return
}
//
found
return
e
.
value
,
true
}
}
...
@@ -246,9 +275,9 @@ func (M *RangedMap) HasRange(r KeyRange) (yes bool) {
...
@@ -246,9 +275,9 @@ func (M *RangedMap) HasRange(r KeyRange) (yes bool) {
M
.
verify
()
M
.
verify
()
//
find
first
ilo
:
r
.
lo
<
[
ilo
].
hi
//
find
first
ilo
:
r
.
lo
<
[
ilo
].
hi
l
:=
len
(
M
.
range
v
)
l
:=
len
(
M
.
entry
v
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
return
r
.
Lo
<=
M
.
range
v
[
i
].
Hi_
return
r
.
Lo
<=
M
.
entry
v
[
i
].
Hi_
})
})
debugfRMap
(
"
\t
ilo: %d
\n
"
,
ilo
)
debugfRMap
(
"
\t
ilo: %d
\n
"
,
ilo
)
...
@@ -257,7 +286,7 @@ func (M *RangedMap) HasRange(r KeyRange) (yes bool) {
...
@@ -257,7 +286,7 @@ func (M *RangedMap) HasRange(r KeyRange) (yes bool) {
}
}
//
all
keys
from
r
are
in
M
if
r
∈
[
ilo
]
XXX
not
in
case
of
different
values
//
all
keys
from
r
are
in
M
if
r
∈
[
ilo
]
XXX
not
in
case
of
different
values
return
(
M
.
rangev
[
ilo
].
Lo
<=
r
.
Lo
&&
r
.
Hi_
<=
M
.
range
v
[
ilo
].
Hi_
)
return
(
M
.
entryv
[
ilo
].
Lo
<=
r
.
Lo
&&
r
.
Hi_
<=
M
.
entry
v
[
ilo
].
Hi_
)
}
}
...
...
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