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

#include <attr_key.h>

Public Types

using value_type = int64_t
using SymmetryT = Symmetry

Public Member Functions

constexpr AttrKey ()
 Default constructor: values are uninitialized.
template<typename... Ints, typename = std::enable_if_t<(sizeof...(Ints) == n && (std::is_integral_v<Ints> && ...))>>
constexpr AttrKey (const Ints... ids)
template<ElementType... element_types, typename = std::enable_if_t<(sizeof...(element_types) == n)>>
constexpr AttrKey (const ElementId< element_types >... ids)
constexpr AttrKey (std::array< value_type, n > ids)
constexpr AttrKey (const AttrKey &)=default
constexpr AttrKeyoperator= (const AttrKey &)=default
constexpr value_type operator[] (const int dim) const
 Element access.
constexpr value_typeoperator[] (const int dim)
constexpr const value_typebegin () const
 Element iteration.
constexpr const value_typeend () const
template<int dim>
AttrKey< n - 1, NoSymmetryRemoveElement () const
template<int dim, typename NewSymmetry>
AttrKey< n+1, NewSymmetry > AddElement (const value_type elem) const

Static Public Member Functions

static constexpr AttrKey Canonicalize (AttrKey< n, NoSymmetry > key)
 Canonicalizes a non-canonical key, i.e., enforces the symmetries.
static absl::StatusOr< AttrKeyFromRange (absl::Span< const int64_t > range)
 Creates a key from a range of n elements.
static constexpr int size ()

Friends

template<int other_n, typename OtherSymmetry>
class AttrKey
constexpr bool operator== (const AttrKey &l, const AttrKey &r)
constexpr bool operator< (const AttrKey &l, const AttrKey &r)
constexpr bool operator<= (const AttrKey &l, const AttrKey &r)
constexpr bool operator> (const AttrKey &l, const AttrKey &r)
constexpr bool operator>= (const AttrKey &l, const AttrKey &r)
template<typename H>
AbslHashValue (H h, const AttrKey &a)
template<typename Sink>
void AbslStringify (Sink &sink, const AttrKey &key)
 AttrKey is printable for logging and tests.

Detailed Description

template<int n, typename Symmetry = NoSymmetry>
class operations_research::math_opt::AttrKey< n, Symmetry >

An attribute key for an attribute keyed on n elements. AttrKey is a value type.

Definition at line 39 of file attr_key.h.

Member Typedef Documentation

◆ SymmetryT

template<int n, typename Symmetry = NoSymmetry>
using operations_research::math_opt::AttrKey< n, Symmetry >::SymmetryT = Symmetry

Definition at line 42 of file attr_key.h.

◆ value_type

template<int n, typename Symmetry = NoSymmetry>
using operations_research::math_opt::AttrKey< n, Symmetry >::value_type = int64_t

Definition at line 41 of file attr_key.h.

Constructor & Destructor Documentation

◆ AttrKey() [1/5]

template<int n, typename Symmetry = NoSymmetry>
operations_research::math_opt::AttrKey< n, Symmetry >::AttrKey ( )
inlineconstexpr

Default constructor: values are uninitialized.

Definition at line 45 of file attr_key.h.

◆ AttrKey() [2/5]

template<int n, typename Symmetry = NoSymmetry>
template<typename... Ints, typename = std::enable_if_t<(sizeof...(Ints) == n && (std::is_integral_v<Ints> && ...))>>
operations_research::math_opt::AttrKey< n, Symmetry >::AttrKey ( const Ints... ids)
inlineexplicitconstexpr

Definition at line 50 of file attr_key.h.

◆ AttrKey() [3/5]

template<int n, typename Symmetry = NoSymmetry>
template<ElementType... element_types, typename = std::enable_if_t<(sizeof...(element_types) == n)>>
operations_research::math_opt::AttrKey< n, Symmetry >::AttrKey ( const ElementId< element_types >... ids)
inlineexplicitconstexpr

Definition at line 58 of file attr_key.h.

◆ AttrKey() [4/5]

template<int n, typename Symmetry = NoSymmetry>
operations_research::math_opt::AttrKey< n, Symmetry >::AttrKey ( std::array< value_type, n > ids)
inlineconstexpr

Definition at line 61 of file attr_key.h.

◆ AttrKey() [5/5]

template<int n, typename Symmetry = NoSymmetry>
operations_research::math_opt::AttrKey< n, Symmetry >::AttrKey ( const AttrKey< n, Symmetry > & )
constexprdefault

Member Function Documentation

◆ AddElement()

template<int n, typename Symmetry = NoSymmetry>
template<int dim, typename NewSymmetry>
AttrKey< n+1, NewSymmetry > operations_research::math_opt::AttrKey< n, Symmetry >::AddElement ( const value_type elem) const
inline

Adds element elem at dimension dim and returns the result. The result must respect NewSymmetry (we DCHECK this).

Definition at line 188 of file attr_key.h.

◆ begin()

template<int n, typename Symmetry = NoSymmetry>
const value_type * operations_research::math_opt::AttrKey< n, Symmetry >::begin ( ) const
inlineconstexpr

Element iteration.

Definition at line 102 of file attr_key.h.

◆ Canonicalize()

template<int n, typename Symmetry = NoSymmetry>
constexpr AttrKey operations_research::math_opt::AttrKey< n, Symmetry >::Canonicalize ( AttrKey< n, NoSymmetry > key)
inlinestaticconstexpr

Canonicalizes a non-canonical key, i.e., enforces the symmetries.

Definition at line 67 of file attr_key.h.

◆ end()

template<int n, typename Symmetry = NoSymmetry>
const value_type * operations_research::math_opt::AttrKey< n, Symmetry >::end ( ) const
inlineconstexpr

Definition at line 103 of file attr_key.h.

◆ FromRange()

template<int n, typename Symmetry = NoSymmetry>
absl::StatusOr< AttrKey > operations_research::math_opt::AttrKey< n, Symmetry >::FromRange ( absl::Span< const int64_t > range)
inlinestatic

Creates a key from a range of n elements.

Definition at line 72 of file attr_key.h.

◆ operator=()

template<int n, typename Symmetry = NoSymmetry>
AttrKey & operations_research::math_opt::AttrKey< n, Symmetry >::operator= ( const AttrKey< n, Symmetry > & )
constexprdefault

◆ operator[]() [1/2]

template<int n, typename Symmetry = NoSymmetry>
value_type & operations_research::math_opt::AttrKey< n, Symmetry >::operator[] ( const int dim)
inlineconstexpr

Definition at line 95 of file attr_key.h.

◆ operator[]() [2/2]

template<int n, typename Symmetry = NoSymmetry>
value_type operations_research::math_opt::AttrKey< n, Symmetry >::operator[] ( const int dim) const
inlineconstexpr

Element access.

Definition at line 90 of file attr_key.h.

◆ RemoveElement()

template<int n, typename Symmetry = NoSymmetry>
template<int dim>
AttrKey< n - 1, NoSymmetry > operations_research::math_opt::AttrKey< n, Symmetry >::RemoveElement ( ) const
inline

Removes the element at dimension dim from the key and returns a key with only remaining dimensions.

Definition at line 172 of file attr_key.h.

◆ size()

template<int n, typename Symmetry = NoSymmetry>
constexpr int operations_research::math_opt::AttrKey< n, Symmetry >::size ( )
inlinestaticconstexpr

Definition at line 87 of file attr_key.h.

◆ AttrKey

template<int n, typename Symmetry = NoSymmetry>
template<int other_n, typename OtherSymmetry>
friend class AttrKey
friend

Definition at line 207 of file attr_key.h.

◆ AbslHashValue

template<int n, typename Symmetry = NoSymmetry>
template<typename H>
H AbslHashValue ( H h,
const AttrKey< n, Symmetry > & a )
friend

Definition at line 157 of file attr_key.h.

◆ AbslStringify

template<int n, typename Symmetry = NoSymmetry>
template<typename Sink>
void AbslStringify ( Sink & sink,
const AttrKey< n, Symmetry > & key )
friend

AttrKey is printable for logging and tests.

Definition at line 163 of file attr_key.h.

◆ operator<

template<int n, typename Symmetry = NoSymmetry>
bool operator< ( const AttrKey< n, Symmetry > & l,
const AttrKey< n, Symmetry > & r )
friend

This is much faster than using the default generated operator<.

Definition at line 122 of file attr_key.h.

◆ operator<=

template<int n, typename Symmetry = NoSymmetry>
bool operator<= ( const AttrKey< n, Symmetry > & l,
const AttrKey< n, Symmetry > & r )
friend

This is much faster than using the default generated operator<.

Definition at line 135 of file attr_key.h.

◆ operator==

template<int n, typename Symmetry = NoSymmetry>
bool operator== ( const AttrKey< n, Symmetry > & l,
const AttrKey< n, Symmetry > & r )
friend

AttrKey is comparable (ordering is lexicographic) and hashable.

Todo
(b/365998156): post C++ 20, replace by spaceship operator (with all comparison operators below). Do NOT use the default generated operator (see below).

This is much faster than using the default generated operator==.

Definition at line 112 of file attr_key.h.

◆ operator>

template<int n, typename Symmetry = NoSymmetry>
bool operator> ( const AttrKey< n, Symmetry > & l,
const AttrKey< n, Symmetry > & r )
friend

Definition at line 148 of file attr_key.h.

◆ operator>=

template<int n, typename Symmetry = NoSymmetry>
bool operator>= ( const AttrKey< n, Symmetry > & l,
const AttrKey< n, Symmetry > & r )
friend

Definition at line 152 of file attr_key.h.


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