Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::AttrMap< ValueType > Class Template Reference

#include <derived_data.h>

Public Member Functions

template<typename AttrT>
ValueType< AllAttrs::GetIndex< AttrT >()> & operator[] (AttrT a)
template<typename AttrT>
const ValueType< AllAttrs::GetIndex< AttrT >()> & operator[] (AttrT a) const
template<typename Fn>
void ForEachAttrValue (Fn &&fn)

Detailed Description

template<template< int i > typename ValueType>
class operations_research::math_opt::AttrMap< ValueType >

A map of attribute to ValueType<i>, where i is the index of the attribute type. See AttrMapTest for example usage.

Note
this is formally a map (it maps attributes to values), but internally uses dense storage.

Definition at line 147 of file derived_data.h.

Member Function Documentation

◆ ForEachAttrValue()

template<template< int i > typename ValueType>
template<typename Fn>
void operations_research::math_opt::AttrMap< ValueType >::ForEachAttrValue ( Fn && fn)
inline

Applies fn on each value for each attribute type. fn must have a overload set of operator() that accepts a ValueType<i> for i in 0..AllAttrs::kSize. This cannot be an iterator because value types are not homogeneous.

Definition at line 168 of file derived_data.h.

◆ operator[]() [1/2]

template<template< int i > typename ValueType>
template<typename AttrT>
ValueType< AllAttrs::GetIndex< AttrT >()> & operations_research::math_opt::AttrMap< ValueType >::operator[] ( AttrT a)
inline
Todo
(b/365997645): post C++ 23, prefer std::to_underlying(a).

Definition at line 150 of file derived_data.h.

◆ operator[]() [2/2]

template<template< int i > typename ValueType>
template<typename AttrT>
const ValueType< AllAttrs::GetIndex< AttrT >()> & operations_research::math_opt::AttrMap< ValueType >::operator[] ( AttrT a) const
inline

The const_cast is fine because non-const operator[] does not mutate anything and we're casting the return type back to const.

Definition at line 157 of file derived_data.h.


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