| OpenMS 2.5.0

Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
ListUtils Class Reference
Datastructures

Collection of utility functions for management of vectors. More...

`#include <OpenMS/DATASTRUCTURES/ListUtils.h>`

## Classes

struct | DoubleTolerancePredicate_
| Predicate to check double equality with a given tolerance. More...

## Public Types

enum | CASE { SENSITIVE, INSENSITIVE }

## Public Member Functions

template<>
std::vector< String > | create (const std::vector< String > &s)
| create specialization for String since we do not need to cast here More...

## Static Public Member Functions

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. More...
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. More...
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. More...
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. More...
static bool | contains (const std::vector< String > &container, String elem, const CASE cs)
| Checks whether the String `elem` is contained in the given container (potentially case insensitive) More...
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. More...
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. More...
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) More...

## Detailed Description

Collection of utility functions for management of vectors.

## Member Enumeration Documentation

## ◆ CASE

enum CASE

strong

Enumerator
SENSITIVE |
INSENSITIVE |

## Member Function Documentation

## ◆ concatenate() [1/2]

static String concatenate | ( | const std::vector< T > & | container,
|  | const String & | glue = `""`
| ) |  |

inline static

Concatenates all elements of the `container` and puts the `glue` string between elements.

Parameters

  container | The container to concatenate;
  glue | The string to add in between elements.

Referenced by UTILProteomicsLFQ::align_(), and NucleicAcidSearchEngine::generateLFQInput_().

## ◆ concatenate() [2/2]

static String concatenate | ( | const T & | container,
|  | const String & | glue = `""`
| ) |  |

inline static

Concatenates all elements of the `container` and puts the `glue` string between elements.

Parameters

  container | The container <T> to concatenate; must have begin() and end() iterator.
  glue | The string to add in between elements.

## ◆ contains() [1/3]

static bool contains | ( | const std::vector< T > & | container,
|  | const E & | elem
| ) |  |

inline static

Checks whether the element `elem` is contained in the given container.

Parameters

  container | The container to check.
  elem | The element to check whether it is in the container or not.

Returns
  True if `elem` is contained in `container`, false otherwise.

References seqan::find().

Referenced by HasActivationMethod< SpectrumType >::operator()().

## ◆ contains() [2/3]

static bool contains | ( | const std::vector< double > & | container,
|  | const double & | elem,
|  | double | tolerance = `0.00001`
| ) |  |

inline static

Checks whether the element `elem` is contained in the given container of floating point numbers.

Parameters

  container | The container of doubles to check.
  elem | The element to check whether it is in the container or not.
  tolerance | The allowed tolerance for the double.

Returns
  True if `elem` is contained in `container`, false otherwise.

## ◆ contains() [3/3]

static bool contains | ( | const std::vector< String > & | container,
|  | String | elem,
|  | const CASE | cs
| ) |  |

inline static

Checks whether the String `elem` is contained in the given container (potentially case insensitive)

Parameters

  container | The container of String to check.
  elem | The element to check whether it is in the container or not.
  case_sensitive | Do the comparison case sensitive or insensitive

Returns
  True if `elem` is contained in `container`, false otherwise.

References String::toLower().

## ◆ create() [1/3]

static std::vector<T> create | ( | const String & | str,
|  | const char | splitter = `','`
| ) |  |

inline static

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

  str | The string that should be split and converted to a list.

Returns
  A vector containing the elements of the string converted into type T.

References String::split().

## ◆ create() [2/3]

std::vector< T > create | ( | const std::vector< String > & | s | ) |

inline static

Converts a vector of strings to a vector of the target type T.

Note
  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

  s | The vector of strings that should be converted.

Returns
  A vector containing the elements of input vector converted into type T.

References OpenMS::Constants::c, and String::trim().

## ◆ create() [3/3]

std::vector<String> create | ( | const std::vector< String > & | s | ) |

inline

create specialization for String since we do not need to cast here

## ◆ getIndex()

static Int getIndex | ( | const std::vector< T > & | container,
|  | const E & | elem
| ) |  |

inline static

Get the index of the first occurrence of an element in the vector (or -1 if not found)

References seqan::find().