Commit ccb401b1 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

add column_group helper

parent 1c6ac3b4
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -71,5 +71,21 @@ Value value_from_float(double v) {
  return std::to_string(v);
}

std::vector<std::pair<size_t, size_t>> column_group(const DataColumn& col) {
  std::vector<std::pair<size_t, size_t>> groups;

  for (size_t idx = 0; idx < col.data.size(); ) {
    auto begin = idx;
    auto end = idx;
    while (end < col.data.size() && col.data[end] == col.data[begin]) {
      end = idx++;
    }

    groups.emplace_back(begin, end);
  }

  return groups;
}

} // namespace plotfx
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ ReturnCode column_find(
    const std::string& column_name,
    const DataColumn** column);

std::vector<std::pair<size_t, size_t>> column_group(const DataColumn& col);

size_t series_len(const Series& s);

std::vector<double> series_to_float(const Series& s);