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
4c57cd2b
Commit
4c57cd2b
authored
Sep 27, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a6bac322
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
2 deletions
+47
-2
wcfs/internal/xbtree/blib/rangeset.go
wcfs/internal/xbtree/blib/rangeset.go
+47
-2
No files found.
wcfs/internal/xbtree/blib/rangeset.go
View file @
4c57cd2b
...
...
@@ -26,15 +26,47 @@ package blib
//
// Zero value represents empty set.
type
RangedKeySet
struct
{
m
_RangedMap_void
// XXX naming
m
_RangedMap_void
// XXX naming
}
// void is used as value type for RangedMap to be used as set.
type
void
struct
{}
func
(
_
void
)
String
()
string
{
return
""
}
// Add adds key k to the set.
func
(
S
*
RangedKeySet
)
Add
(
k
Key
)
{
S
.
AddRange
(
KeyRange
{
Lo
:
k
,
Hi_
:
k
})
}
// Del removes key k from the set.
func
(
S
*
RangedKeySet
)
Del
(
k
Key
)
{
S
.
DelRange
(
KeyRange
{
Lo
:
k
,
Hi_
:
k
})
}
// Has returns whether key k belongs to the set.
func
(
S
*
RangedKeySet
)
Has
(
k
Key
)
bool
{
return
S
.
HasRange
(
KeyRange
{
Lo
:
k
,
Hi_
:
k
})
}
// AddRange adds range r to the set.
func
(
S
*
RangedKeySet
)
AddRange
(
r
KeyRange
)
{
S
.
m
.
SetRange
(
r
,
void
{})
}
// DelRange removes range r from the set.
func
(
S
*
RangedKeySet
)
DelRange
(
r
KeyRange
)
{
S
.
m
.
DelRange
(
r
)
}
// HasRange returns whether all keys from range r belong to the set.
func
(
S
*
RangedKeySet
)
HasRange
(
r
KeyRange
)
(
yes
bool
)
{
return
S
.
m
.
HasRange
(
r
)
}
// Union returns RangedKeySet(A.keys | B.keys).
func
(
A
*
RangedKeySet
)
Union
(
B
*
RangedKeySet
)
*
RangedKeySet
{
U
:=
A
.
Clone
()
...
...
@@ -75,3 +107,16 @@ func (A *RangedKeySet) DifferenceInplace(B *RangedKeySet) {
A
.
DelRange
(
r
)
}
}
// Clone
// Empty
// Equal
// Clear
// AllRanges
// String
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