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
fb578714
Commit
fb578714
authored
May 13, 2016
by
Anton Bukov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15 from babelvit/linq-creators
Linq creators
parents
d121f345
8f8baff2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
32 deletions
+64
-32
.gitignore
.gitignore
+3
-2
CMakeLists.txt
benchmark/CMakeLists.txt
+1
-1
SpeedTest.cpp
benchmark/SpeedTest.cpp
+1
-1
benchmark
externals/benchmark
+1
-1
boolinq.h
include/boolinq/boolinq.h
+21
-26
CMakeLists.txt
test/CMakeLists.txt
+1
-1
IterRangeTest.cpp
test/IterRangeTest.cpp
+36
-0
No files found.
.gitignore
View file @
fb578714
...
...
@@ -4,4 +4,6 @@ ipch
*.opensdf
*.sdf
*.user
*.suo
\ No newline at end of file
*.suo
[Bb]uild*
nbproject
benchmark/CMakeLists.txt
View file @
fb578714
# Common variables.
SET
(
CMAKE_BUILD_TYPE
"Release"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=
c
++11"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=
gnu
++11"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wmissing-include-dirs -Wundef -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wdouble-promotion -Winit-self -Wvector-operation-performance -Wnoexcept -Weffc++ -Wstrict-null-sentinel"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Woverloaded-virtual -Wsign-promo"
)
...
...
benchmark/SpeedTest.cpp
View file @
fb578714
...
...
@@ -15,7 +15,7 @@ std::vector<int> vecCppIter (benchmarkVectorSize, 0);
int
main
(
int
argc
,
c
onst
c
har
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
// Preparing input benchmark data (the same data sets for all tests).
srand
(
0xDEADBEEF
);
...
...
benchmark
@
354b14d1
Subproject commit
0a1593b06f4c79edcd4cd150dc37c8a0446e2e4a
Subproject commit
354b14d1a0770da28f1725fa8409af3264de3a79
include/boolinq/boolinq.h
View file @
fb578714
...
...
@@ -757,48 +757,43 @@ namespace boolinq
return
from
<
T
>
(
array
,
array
+
N
);
}
// std::list, vector, dequeue
template
<
template
<
class
>
class
TV
,
typename
TT
>
auto
from
(
const
TV
<
TT
>
&
container
)
->
decltype
(
from
<
TT
>
(
std
::
begin
(
container
),
std
::
end
(
container
)))
{
return
from
<
TT
>
(
std
::
begin
(
container
),
std
::
end
(
container
));
}
// std::list, std::vector, std::dequeue
template
<
template
<
class
,
class
>
class
TV
,
typename
TT
,
typename
TU
>
auto
from
(
const
TV
<
TT
,
TU
>
&
container
)
->
LinqObj
<
Enumerator
<
TT
,
IteratorContainerPair
<
decltype
(
container
.
cbegin
()),
const
TV
<
TT
,
TU
>
>
>
>
auto
from
(
const
TV
<
TT
,
TU
>
&
container
)
->
decltype
(
from
<
TT
>
(
std
::
begin
(
container
),
std
::
end
(
container
)))
{
typedef
IteratorContainerPair
<
decltype
(
container
.
cbegin
()),
const
TV
<
TT
,
TU
>
>
DataType
;
return
Enumerator
<
TT
,
DataType
>
([](
DataType
&
pair
){
return
(
pair
.
first
==
pair
.
second
.
cend
())
?
throw
EnumeratorEndException
()
:
*
(
pair
.
first
++
);
},
DataType
(
container
,
[](
const
TV
<
TT
,
TU
>
&
cont
){
return
cont
.
cbegin
();}));
return
from
<
TT
>
(
std
::
begin
(
container
),
std
::
end
(
container
));
}
// std::set
template
<
template
<
class
,
class
,
class
>
class
TV
,
typename
TT
,
typename
TS
,
typename
TU
>
auto
from
(
const
TV
<
TT
,
TS
,
TU
>
&
container
)
->
LinqObj
<
Enumerator
<
TT
,
IteratorContainerPair
<
decltype
(
container
.
cbegin
()),
const
TV
<
TT
,
TS
,
TU
>
>
>
>
auto
from
(
const
TV
<
TT
,
TS
,
TU
>
&
container
)
->
decltype
(
from
<
TT
>
(
std
::
begin
(
container
),
std
::
end
(
container
)))
{
typedef
IteratorContainerPair
<
decltype
(
container
.
cbegin
()),
const
TV
<
TT
,
TS
,
TU
>
>
DataType
;
return
Enumerator
<
TT
,
DataType
>
([](
DataType
&
pair
){
return
(
pair
.
first
==
pair
.
second
.
cend
())
?
throw
EnumeratorEndException
()
:
*
(
pair
.
first
++
);
},
DataType
(
container
,
[](
const
TV
<
TT
,
TS
,
TU
>
&
cont
){
return
cont
.
cbegin
();}));
return
from
<
TT
>
(
std
::
begin
(
container
),
std
::
end
(
container
));
}
// std::map
template
<
template
<
class
,
class
,
class
,
class
>
class
TV
,
typename
TK
,
typename
TT
,
typename
TS
,
typename
TU
>
auto
from
(
const
TV
<
TK
,
TT
,
TS
,
TU
>
&
container
)
->
LinqObj
<
Enumerator
<
std
::
pair
<
TK
,
TT
>
,
IteratorContainerPair
<
decltype
(
container
.
cbegin
()),
const
TV
<
TK
,
TT
,
TS
,
TU
>
>
>
>
auto
from
(
const
TV
<
TK
,
TT
,
TS
,
TU
>
&
container
)
->
decltype
(
from
<
std
::
pair
<
TK
,
TT
>
>
(
std
::
begin
(
container
),
std
::
end
(
container
)))
{
typedef
IteratorContainerPair
<
decltype
(
container
.
cbegin
()),
const
TV
<
TK
,
TT
,
TS
,
TU
>
>
DataType
;
return
Enumerator
<
std
::
pair
<
TK
,
TT
>
,
DataType
>
([](
DataType
&
pair
){
return
(
pair
.
first
==
pair
.
second
.
cend
())
?
throw
EnumeratorEndException
()
:
*
(
pair
.
first
++
);
},
DataType
(
container
,
[](
const
TV
<
TK
,
TT
,
TS
,
TU
>
&
cont
){
return
cont
.
cbegin
();}));
return
from
<
std
::
pair
<
TK
,
TT
>
>
(
std
::
begin
(
container
),
std
::
end
(
container
));
}
// std::array
template
<
template
<
class
,
unsigned
>
class
TV
,
typename
TT
,
unsigned
TL
>
auto
from
(
const
TV
<
TT
,
TL
>
&
container
)
->
LinqObj
<
Enumerator
<
TT
,
IteratorContainerPair
<
decltype
(
container
.
cbegin
()),
const
TV
<
TT
,
TL
>
>
>
>
template
<
template
<
class
,
size_t
>
class
TV
,
typename
TT
,
size_t
TL
>
auto
from
(
const
TV
<
TT
,
TL
>
&
container
)
->
decltype
(
from
<
TT
>
(
std
::
begin
(
container
),
std
::
end
(
container
)))
{
typedef
IteratorContainerPair
<
decltype
(
container
.
cbegin
()),
const
TV
<
TT
,
TL
>
>
DataType
;
return
Enumerator
<
TT
,
DataType
>
([](
DataType
&
pair
){
return
(
pair
.
first
==
pair
.
second
.
cend
())
?
throw
EnumeratorEndException
()
:
*
(
pair
.
first
++
);
},
DataType
(
container
,
[](
const
TV
<
TT
,
TL
>
&
cont
){
return
cont
.
cbegin
();}));
return
from
<
TT
>
(
std
::
begin
(
container
),
std
::
end
(
container
));
}
template
<
typename
T
>
...
...
test/CMakeLists.txt
View file @
fb578714
# Common variables.
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=
c
++11"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=
gnu
++11"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wmissing-include-dirs -Wundef -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wdouble-promotion -Winit-self -Wvector-operation-performance -Wnoexcept -Weffc++ -Wstrict-null-sentinel"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Woverloaded-virtual -Wsign-promo"
)
...
...
test/IterRangeTest.cpp
View file @
fb578714
...
...
@@ -2,6 +2,9 @@
#include <deque>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <array>
#include <gtest/gtest.h>
#include "CommonTests.h"
...
...
@@ -60,6 +63,39 @@ TEST(IterRange, VectorInt)
CheckRangeEqArray
(
from
<
int
>
(
vec
.
cbegin
(),
vec
.
cend
()),
ans
);
}
TEST
(
IterRange
,
SetInt
)
{
std
::
set
<
int
>
set
=
{
1
,
2
,
3
,
4
,
5
};
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
CheckRangeEqSet
(
from
(
set
),
ans
);
CheckRangeEqSet
(
from
<
int
>
(
set
.
begin
(),
set
.
end
()),
ans
);
CheckRangeEqSet
(
from
<
int
>
(
set
.
cbegin
(),
set
.
cend
()),
ans
);
}
TEST
(
IterRange
,
MapInt
)
{
std
::
map
<
int
,
int
>
map
=
{{
5
,
1
},{
4
,
2
},{
3
,
3
},{
2
,
4
},{
1
,
5
}};
std
::
pair
<
int
,
int
>
ans
[]
=
{{
5
,
1
},{
4
,
2
},{
3
,
3
},{
2
,
4
},{
1
,
5
}};
CheckRangeEqArray
(
from
(
map
)
.
orderBy
([](
std
::
pair
<
int
,
int
>
p
){
return
p
.
second
;
}),
ans
);
CheckRangeEqArray
(
from
<
std
::
pair
<
int
,
int
>
>
(
map
.
begin
(),
map
.
end
())
.
orderBy
([](
std
::
pair
<
int
,
int
>
p
){
return
p
.
second
;
}),
ans
);
CheckRangeEqArray
(
from
<
std
::
pair
<
int
,
int
>
>
(
map
.
cbegin
(),
map
.
cend
())
.
orderBy
([](
std
::
pair
<
int
,
int
>
p
){
return
p
.
second
;
}),
ans
);
}
TEST
(
IterRange
,
StdArrayInt
)
{
std
::
array
<
int
,
5
>
arr
=
{
1
,
2
,
3
,
4
,
5
};
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
CheckRangeEqArray
(
from
(
arr
),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
arr
.
begin
(),
arr
.
end
()),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
arr
.
cbegin
(),
arr
.
cend
()),
ans
);
}
TEST
(
IterRange
,
ArrayInt
)
{
int
arr
[]
=
{
1
,
2
,
3
,
4
,
5
};
...
...
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