Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
util_intops::IndexListView< ValueT, IndexT > Class Template Reference

#include <views.h>

Classes

struct  IndexListViewIterator

Public Types

using value_type = const ValueT
using index_type = const IndexT
using value_iterator = typename absl::Span<value_type>::iterator
using index_iterator = typename absl::Span<index_type>::iterator

Public Member Functions

 IndexListView ()=default
template<typename ValueRangeT, typename IndexRangeT>
 IndexListView (const ValueRangeT *values, const IndexRangeT *indices)
auto size () const
bool empty () const
decltype(auto) operator[] (index_type index) const
IndexListViewIterator begin () const
IndexListViewIterator end () const
absl::Span< value_typebase () const

Detailed Description

template<typename ValueT, typename IndexT>
class util_intops::IndexListView< ValueT, IndexT >

View exposing only the elements of a container that are indexed by a list of indices. Looping over this view is equivalent to:

for (decltype(auto) index : indices) { your_code(container[index]); }

Definition at line 136 of file views.h.

Member Typedef Documentation

◆ index_iterator

template<typename ValueT, typename IndexT>
using util_intops::IndexListView< ValueT, IndexT >::index_iterator = typename absl::Span<index_type>::iterator

Definition at line 141 of file views.h.

◆ index_type

template<typename ValueT, typename IndexT>
using util_intops::IndexListView< ValueT, IndexT >::index_type = const IndexT

Definition at line 139 of file views.h.

◆ value_iterator

template<typename ValueT, typename IndexT>
using util_intops::IndexListView< ValueT, IndexT >::value_iterator = typename absl::Span<value_type>::iterator

Definition at line 140 of file views.h.

◆ value_type

template<typename ValueT, typename IndexT>
using util_intops::IndexListView< ValueT, IndexT >::value_type = const ValueT

Definition at line 138 of file views.h.

Constructor & Destructor Documentation

◆ IndexListView() [1/2]

template<typename ValueT, typename IndexT>
util_intops::IndexListView< ValueT, IndexT >::IndexListView ( )
default

◆ IndexListView() [2/2]

template<typename ValueT, typename IndexT>
template<typename ValueRangeT, typename IndexRangeT>
util_intops::IndexListView< ValueT, IndexT >::IndexListView ( const ValueRangeT * values,
const IndexRangeT * indices )
inline

Definition at line 167 of file views.h.

Member Function Documentation

◆ base()

template<typename ValueT, typename IndexT>
absl::Span< value_type > util_intops::IndexListView< ValueT, IndexT >::base ( ) const
inline

Definition at line 185 of file views.h.

◆ begin()

template<typename ValueT, typename IndexT>
IndexListViewIterator util_intops::IndexListView< ValueT, IndexT >::begin ( ) const
inline

Definition at line 179 of file views.h.

◆ empty()

template<typename ValueT, typename IndexT>
bool util_intops::IndexListView< ValueT, IndexT >::empty ( ) const
inline

Definition at line 172 of file views.h.

◆ end()

template<typename ValueT, typename IndexT>
IndexListViewIterator util_intops::IndexListView< ValueT, IndexT >::end ( ) const
inline

Definition at line 182 of file views.h.

◆ operator[]()

template<typename ValueT, typename IndexT>
decltype(auto) util_intops::IndexListView< ValueT, IndexT >::operator[] ( index_type index) const
inline
Note
uses indices of the original container, not the filtered one
Todo
(user): we could check that index is in indices_, but that's is O(n).

Definition at line 175 of file views.h.

◆ size()

template<typename ValueT, typename IndexT>
auto util_intops::IndexListView< ValueT, IndexT >::size ( ) const
inline

Definition at line 171 of file views.h.


The documentation for this class was generated from the following file: