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
67cdec4f
Commit
67cdec4f
authored
Jun 29, 2019
by
Anton Bukov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update README
parent
d36208eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
88 deletions
+60
-88
README.md
README.md
+60
-88
No files found.
README.md
View file @
67cdec4f
# boolinq
2
.0
# boolinq
3
.0
[
![CI Status
](
https://travis-ci.org/k06a/boolinq.svg?branch=master
)
](https://travis-ci.org/k06a/boolinq)
[
![CI Status
](
https://travis-ci.org/k06a/boolinq.svg?branch=master
)
](https://travis-ci.org/k06a/boolinq)
[
![Coverage Status
](
https://coveralls.io/repos/github/k06a/boolinq/badge.svg?branch=master
)
](https://coveralls.io/github/k06a/boolinq?branch=master)
[
![Coverage Status
](
https://coveralls.io/repos/github/k06a/boolinq/badge.svg?branch=master
)
](https://coveralls.io/github/k06a/boolinq?branch=master)
C++ single-file header-only Ranges and
LINQ template library
Super tiny C++11 single-file header-only
LINQ template library
Just imagine LINQ support for STL/Qt collections :)
Just imagine
.NET Framework
LINQ support for STL/Qt collections :)
Get source code here:
**[boolinq.h](/include/boolinq/boolinq.h)**
Get source code here:
**[boolinq.h](/include/boolinq/boolinq.h)**
##
# How it looks like
?
##
Wanna demo
?
#### Example with integers
#### Example with integers
```
c
++
```
C
++
int src[] = {1,2,3,4,5,6,7,8};
int src[] = {1,2,3,4,5,6,7,8};
auto
dst
=
from
(
src
).
where
(
[](
int
a
)
{
return
a
%
2
==
1
;})
// 1,3,5,7
auto dst = from(src).where( [](int a)
{ return a % 2 == 1; })
// 1,3,5,7
.
select
([](
int
a
)
{
return
a
*
2
;})
// 2,6,10,14
.select([](int a)
{ return a * 2; })
// 2,6,10,14
.
where
(
[](
int
a
)
{
return
a
>
2
&&
a
<
12
;
})
// 6,10
.where( [](int a)
{ return a > 2 && a < 12;
}) // 6,10
.toStdVector();
.toStdVector();
// dst type: std::vector<int>
// dst type: std::vector<int>
...
@@ -26,15 +26,13 @@ auto dst = from(src).where( [](int a){return a%2 == 1;}) // 1,3,5,7
...
@@ -26,15 +26,13 @@ auto dst = from(src).where( [](int a){return a%2 == 1;}) // 1,3,5,7
#### Example with structs
#### Example with structs
```
c++
```
C++
struct
Man
struct Man {
{
std::string name;
std::string name;
int age;
int age;
};
};
Man
src
[]
=
Man src[] = {
{
{"Kevin",14},
{"Kevin",14},
{"Anton",18},
{"Anton",18},
{"Agata",17},
{"Agata",17},
...
@@ -42,9 +40,9 @@ Man src[] =
...
@@ -42,9 +40,9 @@ Man src[] =
{"Layer",15},
{"Layer",15},
};
};
auto
dst
=
from
(
src
).
where
(
[](
const
Man
&
man
)
{
return
man
.
age
<
18
;
})
auto dst = from(src).where( [](const Man & man)
{ return man.age < 18;
})
.
orderBy
([](
const
Man
&
man
)
{
return
man
.
age
;
})
.orderBy([](const Man & man)
{ return man.age;
})
.
select
(
[](
const
Man
&
man
)
{
return
man
.
name
;
})
.select( [](const Man & man)
{ return man.name;
})
.toStdVector();
.toStdVector();
// dst type: std::vector<std::string>
// dst type: std::vector<std::string>
...
@@ -53,16 +51,14 @@ auto dst = from(src).where( [](const Man & man){return man.age < 18;})
...
@@ -53,16 +51,14 @@ auto dst = from(src).where( [](const Man & man){return man.age < 18;})
#### Interesting example
#### Interesting example
```
c++
```
C++
struct
Message
struct Message {
{
std::string PhoneA;
std::string PhoneA;
std::string PhoneB;
std::string PhoneB;
std::string Text;
std::string Text;
};
};
Message
messages
[]
=
Message messages[] = {
{
{"Anton","Troll","Hello, friend!"},
{"Anton","Troll","Hello, friend!"},
{"Denis","Wride","OLOLO"},
{"Denis","Wride","OLOLO"},
{"Anton","Papay","WTF?"},
{"Anton","Papay","WTF?"},
...
@@ -71,83 +67,59 @@ Message messages[] =
...
@@ -71,83 +67,59 @@ Message messages[] =
};
};
int DenisUniqueContactCount =
int DenisUniqueContactCount =
from
(
messages
).
where
(
[](
const
Message
&
msg
)
{
return
msg
.
PhoneA
==
"Denis"
;
})
from(messages).where( [](const Message & msg)
{ return msg.PhoneA == "Denis";
})
.
distinct
([](
const
Message
&
msg
)
{
return
msg
.
PhoneB
;
})
.distinct([](const Message & msg)
{ return msg.PhoneB;
})
.count();
.count();
// DenisUniqueContactCount == 2
// DenisUniqueContactCount == 2
```
```
##
#
Containers supported?
## Containers supported?
-
C++: Native arrays, pairs of pointers
-
C++: Native arrays, pairs of pointers
-
STL: list, stack, queue, vector, deque, set, map, any compatible ....
-
STL: list, stack, queue, vector, deque, set, map, any compatible ....
-
Qt: QList, QVector, QSet, QMap.
-
Qt: QList, QVector, QSet, QMap.
### Operators supported?
## Operators supported?
#### Today:
#### Filters and reorders:
-
cast
<
T
>
()
-
`where(predicate)`
,
`where_i(predicate)`
-
`take(count)`
,
`takeWhile(predicate)`
,
`takeWhile_i(predicate)`
-
take(int)
-
`skip(count)`
,
`skipWhile(predicate)`
,
`skipWhile_i(predicate)`
-
takeWhile(int)
-
`orderBy()`
,
`orderBy(transform)`
-
takeWhile_i(int)
-
`distinct()`
,
`distinct(transform)`
-
skip(int)
-
`concat(linq)`
-
skipWhile(int)
-
`reverse()`
-
skipWhile_i(int)
-
`cast<T>()`
-
concat(range)
-
where(lambda)
#### Transformers:
-
where_i(lambda)
-
select(lambda)
-
`select(transform)`
,
`select_i(transform)`
-
select_i(lambda)
-
`groupBy(transform)`
-
reverse()
-
`selectMany(transfom)`
-
orderBy()
-
orderBy(lambda)
#### Aggregators:
-
distinct()
-
`all()`
,
`all(predicate)`
-
distinct(lambda)
-
`any()`
,
`any(lambda)`
-
groupBy(lambda)
-
`sum()`
,
`sum<T>()`
,
`sum(lambda)`
-
selectMany(lambda)
-
`avg()`
,
`avg<T>()`
,
`avg(lambda)`
-
`min()`
,
`min(lambda)`
-
for_each(lambda)
-
`max()`
,
`max(lambda)`
-
for_each_i(lambda)
-
`count()`
,
`count(value)`
,
`count(predicate)`
-
all()
-
`contains(value)`
-
all(lambda)
-
`elementAt(index)`
-
any()
-
`toStdSet()`
,
`toStdList()`
,
`toStdDeque()`
,
`toStdVector()`
-
any(lambda)
-
sum()
#### Bits and Bytes:
-
sum(lambda)
-
avg()
-
`bytes<T>(ByteDirection?)`
-
avg(lambda)
-
`unbytes<T>(ByteDirection?)`
-
min()
-
`bits(BitsDirection?, BytesDirection?)`
-
min(lambda)
-
`unbits<T = unsigned char>(BitsDirection?, BytesDirection?)`
-
max()
-
max(lambda)
#### Coming soon:
-
count()
-
contains(value)
-
elementAt(int)
-
toStdSet()
-
toStdList()
-
toStdDeque()
-
toStdVector()
#### Custom:
-
bytes()
-
bytes
<
ByteOrder
>
()
-
unbytes
<
T
>
()
-
unbytes
<
T,ByteOrder
>
()
-
bits()
-
bits
<
BitOrder
>
()
-
bits
<
BitOrder,ByteOrder
>
()
-
unbits()
-
unbits
<
BitOrder
>
()
-
unbits
<
T
>
()
-
unbits
<
T,BitOrder
>
()
-
unbits
<
T,BitOrder,ByteOrder
>
()
#### May be will be:
-
gz()
-
gz()
-
ungz()
-
ungz()
...
...
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