IterableBoolMap

Declared in lemon/maps.h, in the group Graph Maps; the same class on the Doxygen site.

template< typename GR , typename K >
class IterableBoolMap : protected Type< GR , K >

Dynamic iterable bool map.

This class provides a special graph map type which can store a bool value for graph items (Node, Arc or Edge). For both true and false values it is possible to iterate on the keys mapped to the value.

This type is a reference map, so it can be modified with the subscript operator.

See also

CrossRefMap

Template Parameters:
  • GR – The graph type.

  • K – The key type of the map (GR::Node, GR::Arc or GR::Edge).

Public Types

typedef True ReferenceMapTag

Indicates that the map is reference map.

typedef K Key

The key type.

typedef bool Value

The value type.

typedef const Value & ConstReference

The const reference type.

Public Functions

inline explicit IterableBoolMap( const Graph & graph , bool def = false )

Constructor of the map with a default value.

inline bool operator[]( const Key & key ) const

Const subscript operator of the map.

inline Reference operator[]( const Key & key )

Subscript operator of the map.

inline void set( const Key & key , bool value )

Set operation of the map.

inline void setAll( bool value )

Set all items.

Set all items in the map.

Note

Constant time operation.

inline int trueNum() const

Returns the number of the keys mapped to true.

inline int falseNum() const

Returns the number of the keys mapped to false.

inline LemonRangeWrapper1< TrueIt , IterableBoolMap > trueKeys()

STL style iterator for the keys mapped to true.

This is an STL style wrapper for TrueIt. It can be used in range-based for loops, STL algorithms, etc.

inline LemonRangeWrapper1< FalseIt , IterableBoolMap > falseKeys()

STL style iterator for the keys mapped to false.

This is an STL style wrapper for FalseIt. It can be used in range-based for loops, STL algorithms, etc.

inline LemonRangeWrapper2< ItemIt , IterableBoolMap , bool > items( bool value )

STL style iterator for the keys mapped to a given value.

This is an STL style wrapper for ItemIt. It can be used in range-based for loops, STL algorithms, etc.

Protected Functions

inline virtual void add( const Key & key )
inline virtual void add( const std::vector< Key > & keys )
inline virtual void erase( const Key & key )
inline virtual void erase( const std::vector< Key > & keys )
inline virtual void build()
inline virtual void clear()
class Reference

Reference to the value of the map.

This class is similar to the bool type. It can be converted to bool and it provides the same operators.

Public Functions

Reference( const Reference & ) = default
inline Reference & operator=( const Reference & value )
inline operator bool() const
inline Reference & operator=( bool value )
inline Reference & operator&=( bool value )
inline Reference & operator|=( bool value )
inline Reference & operator^=( bool value )
class TrueIt : public Key

Iterator for the keys mapped to true. It works like a graph item iterator, it can be converted to the key type of the map, incremented with ++ operator, and if the iterator leaves the last valid key, it will be equal to INVALID.

Public Types

typedef Key Parent

Public Functions

inline explicit TrueIt( const IterableBoolMap & map )

Creates an iterator. It iterates on the keys mapped to true.

Parameters:

map – The IterableBoolMap.

inline TrueIt(Invalid)

Invalid constructor & conversion.

This constructor initializes the iterator to be invalid.

See also

Invalid for more details.

inline TrueIt & operator++()

Increment operator.

class FalseIt : public Key

Iterator for the keys mapped to false. It works like a graph item iterator, it can be converted to the key type of the map, incremented with ++ operator, and if the iterator leaves the last valid key, it will be equal to INVALID.

Public Types

typedef Key Parent

Public Functions

inline explicit FalseIt( const IterableBoolMap & map )

Creates an iterator. It iterates on the keys mapped to false.

Parameters:

map – The IterableBoolMap.

inline FalseIt(Invalid)

Invalid constructor & conversion.

This constructor initializes the iterator to be invalid.

See also

Invalid for more details.

inline FalseIt & operator++()

Increment operator.

class ItemIt : public Key

Iterator for the keys mapped to a given value. It works like a graph item iterator, it can be converted to the key type of the map, incremented with ++ operator, and if the iterator leaves the last valid key, it will be equal to INVALID.

Public Types

typedef Key Parent

Public Functions

inline ItemIt( const IterableBoolMap & map , bool value )

Creates an iterator with a value. It iterates on the keys mapped to the given value.

Parameters:
inline ItemIt(Invalid)

Invalid constructor & conversion.

This constructor initializes the iterator to be invalid.

See also

Invalid for more details.

inline ItemIt & operator++()

Increment operator.