Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kučera Petr RNDr. Ph.D.
PCCompile
Commits
5cbd8e5a
Commit
5cbd8e5a
authored
Jan 24, 2022
by
Kučera Petr RNDr. Ph.D.
Browse files
vector_set class header
parent
3ec629bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/vector_set.h
0 → 100644
View file @
5cbd8e5a
/*
* Project SUBool
* Petr Kucera, 2022
*/
/**@file vector_set.h
* Set representation based on a sorted vector.
*/
#ifndef __VECTOR_SET_H
#define __VECTOR_SET_H
#include <vector>
namespace
SUBol
{
// API based on std library, so that it can be used in templates wherever
// std::set can be used.
template
<
class
Key
,
class
Compare
=
std
::
less
<
Key
>,
class
Allocator
=
std
::
allocator
<
Key
>>
class
VectorSet
{
public:
using
key_type
=
Key
;
using
value_type
=
Key
;
using
vector_type
=
std
::
vector
<
Key
,
Allocator
>
;
using
size_type
=
typename
vector_type
::
size_type
;
using
difference_type
=
typename
vector_type
::
difference_type
;
using
key_compare
=
Compare
;
using
value_compare
=
Compare
;
using
allocator_type
=
Allocator
;
using
reference
=
value_type
&
;
using
const_reference
=
const
value_type
&
;
using
pointer
=
typename
std
::
allocator_traits
<
Allocator
>::
pointer
;
using
const_pointer
=
typename
std
::
allocator_traits
<
Allocator
>::
const_pointer
;
using
iterator
=
typename
vector_type
::
iterator
;
using
const_iterator
=
typename
vector_type
::
const_iterator
;
using
reverse_iterator
=
typename
vector_type
::
reverse_iterator
;
using
const_reverse_iterator
=
typename
vector_type
::
const_reverse_iterator
;
public:
VectorSet
();
explicit
VectorSet
(
const
Compare
&
comp
,
const
Allocator
&
alloc
=
Allocator
());
explicit
VectorSet
(
const
Allocator
&
alloc
);
template
<
class
InputIt
>
VectorSet
(
InputIt
first
,
InputIt
last
,
const
Compare
&
comp
=
Compare
(),
const
Allocator
&
alloc
=
Allocator
());
template
<
class
InputIt
>
VectorSet
(
InputIt
first
,
InputIt
last
,
const
Allocator
&
alloc
)
:
VectorSet
(
first
,
last
,
Compare
(),
alloc
)
{
}
VectorSet
(
const
VectorSet
&
other
);
VectorSet
(
const
VectorSet
&
other
,
const
Allocator
&
alloc
);
VectorSet
(
VectorSet
&&
other
);
VectorSet
(
VectorSet
&&
other
,
const
Allocator
&
alloc
);
VectorSet
(
std
::
initializer_list
<
value_type
>
init
,
const
Compare
&
comp
=
Compare
(),
const
Allocator
&
alloc
=
Allocator
());
VectorSet
(
std
::
initializer_list
<
value_type
>
init
,
const
Allocator
&
alloc
)
:
VectorSet
(
init
,
Compare
(),
alloc
)
{
}
~
VectorSet
()
=
default
;
iterator
begin
()
noexcept
;
const_iterator
begin
()
const
noexcept
;
const_iterator
cbegin
()
const
noexcept
;
iterator
end
()
noexcept
;
const_iterator
end
()
const
noexcept
;
const_iterator
cend
()
const
noexcept
;
reverse_iterator
rbegin
()
noexcept
;
const_reverse_iterator
rbegin
()
const
noexcept
;
const_reverse_iterator
crbegin
()
const
noexcept
;
reverse_iterator
rend
()
noexcept
;
const_reverse_iterator
rend
()
const
noexcept
;
const_reverse_iterator
crend
()
const
noexcept
;
bool
empty
()
const
noexcept
;
size_type
size
()
const
noexcept
;
size_type
max_size
()
const
noexcept
;
void
clear
()
noexcept
;
std
::
pair
<
iterator
,
bool
>
insert
(
const
value_type
&
value
);
std
::
pair
<
iterator
,
bool
>
insert
(
value_type
&&
value
);
iterator
insert
(
const_iterator
hint
,
const
value_type
&
value
);
iterator
insert
(
const_iterator
hint
,
value_type
&&
value
);
template
<
class
InputIt
>
void
insert
(
InputIt
first
,
InputIt
last
);
void
insert
(
std
::
initializer_list
<
value_type
>
ilist
);
template
<
class
...
Args
>
std
::
pair
<
iterator
,
bool
>
emplace
(
Args
&&
...
args
);
template
<
class
...
Args
>
iterator
emplace_hint
(
const_iterator
hint
,
Args
&&
...
args
);
iterator
erase
(
iterator
pos
);
iterator
erase
(
const_iterator
pos
);
iterator
erase
(
const_iterator
first
,
const_iterator
last
);
size_type
erase
(
const
Key
&
key
);
void
swap
(
VectorSet
&
other
);
// void swap( set& other ) noexcept(/* see below */); C++17, if it makes
// sense, maybe the noexcept specification should be the same as for
// vector.
size_type
count
(
const
Key
&
key
)
const
;
template
<
class
K
>
size_type
count
(
const
K
&
x
)
const
;
iterator
find
(
const
Key
&
key
);
const_iterator
find
(
const
Key
&
key
)
const
;
template
<
class
K
>
iterator
find
(
const
K
&
x
);
template
<
class
K
>
const_iterator
find
(
const
K
&
x
)
const
;
bool
contains
(
const
Key
&
key
)
const
;
template
<
class
K
>
bool
contains
(
const
K
&
x
)
const
;
std
::
pair
<
iterator
,
iterator
>
equal_range
(
const
Key
&
key
);
std
::
pair
<
const_iterator
,
const_iterator
>
equal_range
(
const
Key
&
key
)
const
;
template
<
class
K
>
std
::
pair
<
iterator
,
iterator
>
equal_range
(
const
K
&
x
);
template
<
class
K
>
std
::
pair
<
const_iterator
,
const_iterator
>
equal_range
(
const
K
&
x
)
const
;
iterator
lower_bound
(
const
Key
&
key
);
const_iterator
lower_bound
(
const
Key
&
key
)
const
;
template
<
class
K
>
iterator
lower_bound
(
const
K
&
x
);
template
<
class
K
>
const_iterator
lower_bound
(
const
K
&
x
)
const
;
iterator
upper_bound
(
const
Key
&
key
);
const_iterator
upper_bound
(
const
Key
&
key
)
const
;
template
<
class
K
>
iterator
upper_bound
(
const
K
&
x
);
template
<
class
K
>
const_iterator
upper_bound
(
const
K
&
x
)
const
;
key_compare
key_comp
()
const
;
value_compare
value_comp
()
const
;
};
}
// namespace SUBol
#endif
Write
Preview
Supports
Markdown
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