14#ifndef OR_TOOLS_UTIL_FLAT_MATRIX_H_
15#define OR_TOOLS_UTIL_FLAT_MATRIX_H_
26#include "absl/types/span.h"
38 array_(num_rows_ * num_cols_) {}
42 array_(num_rows_ * num_cols_, elem) {}
48 return absl::Span<T>(array_.data() +
row * num_cols_, num_cols_);
51 return {array_.data() +
row * num_cols_, num_cols_};
57 return absl::MakeConstSpan(array_);
69 absl::Span<const T>
operator*()
const {
return {ptr_, row_size_}; }
76 const size_t row_size_;
93 std::vector<T> array_;
100 : ptr_(ptr), row_(
row), row_size_(row_size) {}
113 return std::tie(ptr_, row_, row_size_) !=
114 std::tie(rhs.ptr_, rhs.row_, rhs.row_size_);
absl::Span< const T > operator*() const
ConstRowsIterator & operator++()
bool operator!=(const ConstRowsIterator &rhs) const
ConstRowsIterator(const T *ptr, size_t row, size_t row_size)
Implementation of the templates.
NOTE(user): T=bool is not yet supported (the [] operator doesn't work).
FlatMatrix(size_t num_rows, size_t num_cols)
FlatMatrix(size_t num_rows, size_t num_cols, const T &elem)
absl::Span< const T > all_elements() const
absl::Span< T > operator[](size_t row)
absl::Span< T > all_elements()
All the elements of the FlatMatrix.
absl::Span< const T > operator[](size_t row) const
In SWIG mode, we don't want anything besides these top-level includes.
absl::Span< const T > value_type
ConstRowsIterator const_iterator
ConstRowsIterator end() const
ConstRowsIterator begin() const