Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
890117f2
Commit
890117f2
authored
Jan 31, 2018
by
Ronan
Browse files
feat(Utils): add a algorithm file to centralize generic algorithm
parent
a64dc54e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
include/CMakeLists.txt
include/CMakeLists.txt
+1
-0
include/linphone/utils/algorithm.h
include/linphone/utils/algorithm.h
+65
-0
No files found.
include/CMakeLists.txt
View file @
890117f2
...
...
@@ -98,6 +98,7 @@ set(ENUMS_HEADER_FILES
)
set
(
UTILS_HEADER_FILES
algorithm.h
enum-generator.h
enum-mask.h
fs.h
...
...
include/linphone/utils/algorithm.h
0 → 100644
View file @
890117f2
/*
* algorithm.h
* Copyright (C) 2010-2018 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _L_ALGORITHM_H_
#define _L_ALGORITHM_H_
#include <algorithm>
#include "general.h"
// =============================================================================
// NOTE: Maybe use https://github.com/ericniebler/range-v3 one day?
LINPHONE_BEGIN_NAMESPACE
template
<
typename
T
,
typename
Value
>
inline
typename
T
::
const_iterator
find
(
const
T
&
container
,
const
Value
&
value
)
{
return
std
::
find
(
container
.
cbegin
(),
container
.
cend
(),
value
);
}
template
<
typename
T
,
typename
Value
>
inline
typename
T
::
iterator
find
(
T
&
container
,
const
Value
&
value
)
{
return
std
::
find
(
container
.
begin
(),
container
.
end
(),
value
);
}
template
<
typename
T
,
typename
Predicate
>
inline
typename
T
::
const_iterator
findIf
(
const
T
&
container
,
Predicate
predicate
)
{
return
std
::
find_if
(
container
.
cbegin
(),
container
.
cend
(),
predicate
);
}
template
<
typename
T
,
typename
Predicate
>
inline
typename
T
::
iterator
findIf
(
T
&
container
,
Predicate
predicate
)
{
return
std
::
find_if
(
container
.
begin
(),
container
.
end
(),
predicate
);
}
template
<
typename
T
,
typename
Value
>
inline
bool
removeFirst
(
T
&
container
,
const
Value
&
value
)
{
auto
it
=
find
(
container
,
value
);
if
(
it
!=
container
.
end
())
{
container
.
erase
(
it
);
return
true
;
}
return
false
;
}
LINPHONE_END_NAMESPACE
#endif // ifndef _L_ALGORITHM_H_
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