tables::column::starts_with,ends_with

1)

column<bool>
column<std::string_view>::starts_with(const std::string_view sv) const

2)

column<bool>
column<std::string_view>::starts_with(const column<std::string_view>& other) const

3)

column<bool>
column<std::string_view>::ends_with(const std::string_view sv) const

4)

column<bool>
column<std::string_view>::ends_with(const column<std::string_view>& other) const

  1. Returns column-of-bools indicating if string starts with given prefix.

  2. Returns column-of-bools indicating if string starts with given prefixes.

  3. Returns column-of-bools indicating if string ends with given suffix.

  4. Returns column-of-bools indicating if string ends with given suffixes.

Complexity

Linear

Example

Code

#include <cpptables/table.hh>

using namespace tables;
using namespace std;

void column_starts_ends_with()
{
  using sv_column = column<std::string_view>;
  const sv_column xs({ 
    "foo bar",
    "foo abc def",
    "hello world",
    "foo abc def"
  });


  cout << xs.starts_with("foo") << "\n";
  cout << xs.starts_with( sv_column({"foo","bar", "foo", "hello"}) ) << "\n";

  cout << xs.ends_with("bar") << "\n";
  cout << xs.ends_with( sv_column({"bar","bar", "world", "foo"}) ) << "\n";
}

Output

1 1 0 1
1 0 0 0
1 0 0 0
1 0 1 0