Collection of utility functions for management of vectors.
More...
#include <OpenMS/DATASTRUCTURES/ListUtils.h>
|
| template<> |
| std::vector< String > | create (const std::vector< String > &s) |
| | create specialization for String since we do not need to cast here
|
| |
|
| template<typename T > |
| static std::vector< T > | create (const String &str, const char splitter=',') |
| | Returns a list that is created by splitting the given comma-separated string.
|
| |
| template<typename T > |
| static std::vector< T > | create (const std::vector< String > &s) |
| | Converts a vector of strings to a vector of the target type T.
|
| |
| template<typename T > |
| static std::vector< String > | toStringList (const std::vector< T > &s) |
| | Converts a vector of T's to a vector of Strings.
|
| |
| template<typename T , typename E > |
| static bool | contains (const std::vector< T > &container, const E &elem) |
| | Checks whether the element elem is contained in the given container.
|
| |
| static bool | contains (const std::vector< double > &container, const double &elem, double tolerance=0.00001) |
| | Checks whether the element elem is contained in the given container of floating point numbers.
|
| |
| static bool | contains (const std::vector< String > &container, String elem, const CASE case_sensitive) |
| | Checks whether the String elem is contained in the given container (potentially case insensitive)
|
| |
| template<typename T > |
| static String | concatenate (const std::vector< T > &container, const String &glue="") |
| | Concatenates all elements of the container and puts the glue string between elements.
|
| |
| template<typename T > |
| static String | concatenate (const T &container, const String &glue="") |
| | Concatenates all elements of the container and puts the glue string between elements.
|
| |
| template<typename T , typename E > |
| static Int | getIndex (const std::vector< T > &container, const E &elem) |
| | Get the index of the first occurrence of an element in the vector (or -1 if not found)
|
| |
Collection of utility functions for management of vectors.
◆ CASE
| Enumerator |
|---|
| SENSITIVE | |
| INSENSITIVE | |
◆ concatenate() [1/2]
template<typename T >
| static String concatenate |
( |
const std::vector< T > & |
container, |
|
|
const String & |
glue = "" |
|
) |
| |
|
inlinestatic |
Concatenates all elements of the container and puts the glue string between elements.
- Parameters
-
| [in] | container | The container to concatenate; |
| [in] | glue | The string to add in between elements. |
Referenced by NucleicAcidSearchEngine::generateLFQInput_().
◆ concatenate() [2/2]
template<typename T >
| static String concatenate |
( |
const T & |
container, |
|
|
const String & |
glue = "" |
|
) |
| |
|
inlinestatic |
Concatenates all elements of the container and puts the glue string between elements.
- Parameters
-
| [in] | container | The container to concatenate; must have begin() and end() iterator. |
| [in] | glue | The string to add in between elements. |
◆ contains() [1/3]
| static bool contains |
( |
const std::vector< double > & |
container, |
|
|
const double & |
elem, |
|
|
double |
tolerance = 0.00001 |
|
) |
| |
|
inlinestatic |
Checks whether the element elem is contained in the given container of floating point numbers.
- Parameters
-
| [in] | container | The container of doubles to check. |
| [in] | elem | The element to check whether it is in the container or not. |
| [in] | tolerance | The allowed tolerance for the double. |
- Returns
- True if
elem is contained in container, false otherwise.
◆ contains() [2/3]
| static bool contains |
( |
const std::vector< String > & |
container, |
|
|
String |
elem, |
|
|
const CASE |
case_sensitive |
|
) |
| |
|
inlinestatic |
Checks whether the String elem is contained in the given container (potentially case insensitive)
- Parameters
-
| [in] | container | The container of String to check. |
| [in] | elem | The element to check whether it is in the container or not. |
| [in] | case_sensitive | Do the comparison case sensitive or insensitive |
- Returns
- True if
elem is contained in container, false otherwise.
References OpenMS::Math::contains(), and String::toLower().
◆ contains() [3/3]
template<typename T , typename E >
| static bool contains |
( |
const std::vector< T > & |
container, |
|
|
const E & |
elem |
|
) |
| |
|
inlinestatic |
Checks whether the element elem is contained in the given container.
- Parameters
-
| [in] | container | The container to check. |
| [in] | elem | The element to check whether it is in the container or not. |
- Returns
- True if
elem is contained in container, false otherwise.
Referenced by HasActivationMethod< SpectrumType >::operator()().
◆ create() [1/3]
template<typename T >
| std::vector< T > create |
( |
const std::vector< String > & |
s | ) |
|
|
inlinestatic |
Converts a vector of strings to a vector of the target type T.
- Note
- The strings are trimmed before conversion.
-
The values get converted by boost::lexical_cast so a valid conversion from String to T needs to be available.
- Parameters
-
| [in] | s | The vector of strings that should be converted. |
- Returns
- A vector containing the elements of input vector converted into type T.
References String::trim().
◆ create() [2/3]
template<>
| std::vector< String > create |
( |
const std::vector< String > & |
s | ) |
|
|
inline |
create specialization for String since we do not need to cast here
◆ create() [3/3]
template<typename T >
| static std::vector< T > create |
( |
const String & |
str, |
|
|
const char |
splitter = ',' |
|
) |
| |
|
inlinestatic |
Returns a list that is created by splitting the given comma-separated string.
- Note
- If converted to vector<String> the strings are not trimmed.
-
The values get converted by boost::lexical_cast so a valid conversion from String to T needs to be available.
- Parameters
-
| [in] | str | The string that should be split and converted to a list. |
| [in] | splitter | The separator to look for in str |
- Returns
- A vector containing the elements of the string converted into type T.
References String::split().
◆ getIndex()
template<typename T , typename E >
| static Int getIndex |
( |
const std::vector< T > & |
container, |
|
|
const E & |
elem |
|
) |
| |
|
inlinestatic |
Get the index of the first occurrence of an element in the vector (or -1 if not found)
◆ toStringList()
template<typename T >
| static std::vector< String > toStringList |
( |
const std::vector< T > & |
s | ) |
|
|
inlinestatic |
Converts a vector of T's to a vector of Strings.
- Parameters
-
| [in] | s | The vector of T's that should be converted. |
- Returns
- A vector containing the elements of input vector converted into Strings.