FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
co-cpp19/src/array19.lib/array19/DynamicSortedSet.h at develop · basicpp/co-cpp19 · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
basicpp
/
co-cpp19
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
14
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
co-cpp19
/
src
/
array19.lib
/
array19
/
DynamicSortedSet.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (35 loc) · 1.27 KB
Breadcrumbs
co-cpp19
/
src
/
array19.lib
/
array19
/
DynamicSortedSet.h
Copy path
File metadata and controls
45 lines (35 loc) · 1.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#
pragma
once
#
include
"
DynamicArrayOf.h
"
#
include
"
SliceOf.single.h
"
#
include
<
algorithm
>
#
include
<
stddef.h
>
//
size_t
namespace
array19
{
//
/ set of sorted of values
//
/ - useful for sets of ids
template
<
class
T
,
class
Less
= std::less<>>
struct
DynamicSortedSet
{
[[nodiscard]]
auto
isEmpty
()
const
noexcept
-> bool {
return
m.
isEmpty
(); }
[[nodiscard]]
auto
count
()
const
-> size_t {
return
m.
count
(); }
[[nodiscard]]
auto
begin
()
const
-> T
const
* {
return
m.
begin
(); }
[[nodiscard]]
auto
end
()
const
-> T
const
* {
return
m.
end
(); }
[[nodiscard]]
bool
has
(
const
T& v)
const
{
auto
[b, e] =
std::equal_range
(m.
begin
(), m.
end
(), v, Less{});
return
b != e;
}
operator
SliceOf<T
const
>()
const
{
return
SliceOf{
begin
(),
count
()}; }
void
add
(T
const
& v) {
auto
[b, e] =
std::equal_range
(m.
amendBegin
(), m.
amendEnd
(), v, Less{});
if
(b == e) {
m.
splice
(b,
0
,
array19::sliceOfSingle
(v));
}
}
void
remove
(T
const
& v) {
auto
[b, e] =
std::equal_range
(m.
amendBegin
(), m.
amendEnd
(), v, Less{});
if
(b != e) {
m.
remove
(b,
1
);
}
}
void
clear
() { m.
clear
(); }
private:
DynamicArrayOf<T> m;
};
}
//
namespace array19
Back
|
FazBrowse Home
|
New Git URL