Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
boolinq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
boolinq
Commits
3087b44d
Commit
3087b44d
authored
May 25, 2016
by
Anton Bukov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19 from k06a/feature/some-refactorings
Refactor some export methods
parents
8e85b80f
0b0add10
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
33 deletions
+26
-33
boolinq.h
include/boolinq/boolinq.h
+26
-33
No files found.
include/boolinq/boolinq.h
View file @
3087b44d
...
...
@@ -589,56 +589,49 @@ namespace boolinq
// Export methods
std
::
vector
<
T
>
toVector
()
const
{
std
::
vector
<
T
>
vec
;
private
:
template
<
typename
C
,
typename
TFunc
>
C
exportToContainer
(
TFunc
func
)
const
{
C
container
;
try
{
auto
en
=
_enumerator
;
for
(;;)
vec
.
push_back
(
en
.
nextObject
());
func
(
container
,
en
.
nextObject
());
}
catch
(
EnumeratorEndException
&
)
{}
return
vec
;
return
container
;
}
std
::
set
<
T
>
toSet
()
const
public
:
std
::
vector
<
T
>
toVector
()
const
{
std
::
set
<
T
>
res
;
try
{
auto
en
=
_enumerator
;
for
(;;)
res
.
insert
(
en
.
nextObject
());
}
catch
(
EnumeratorEndException
&
)
{}
return
res
;
return
exportToContainer
<
std
::
vector
<
T
>
>
([](
std
::
vector
<
T
>
&
container
,
const
T
&
value
){
container
.
push_back
(
value
);
});
}
std
::
list
<
T
>
toList
()
const
{
std
::
list
<
T
>
res
;
try
{
auto
en
=
_enumerator
;
for
(;;)
res
.
push_back
(
en
.
nextObject
());
}
catch
(
EnumeratorEndException
&
)
{}
return
res
;
return
exportToContainer
<
std
::
list
<
T
>
>
([](
std
::
list
<
T
>
&
container
,
const
T
&
value
){
container
.
push_back
(
value
);
});
}
std
::
deque
<
T
>
toDeque
()
const
{
std
::
deque
<
T
>
res
;
try
{
auto
en
=
_enumerator
;
for
(;;)
res
.
push_back
(
en
.
nextObject
());
}
catch
(
EnumeratorEndException
&
)
{}
return
res
;
return
exportToContainer
<
std
::
deque
<
T
>
>
([](
std
::
deque
<
T
>
&
container
,
const
T
&
value
){
container
.
push_back
(
value
);
});
}
std
::
set
<
T
>
toSet
()
const
{
return
exportToContainer
<
std
::
set
<
T
>
>
([](
std
::
set
<
T
>
&
container
,
const
T
&
value
){
container
.
insert
(
value
);
});
}
// Custom methods
...
...
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