ExtendFindEnum

Declared in lemon/unionfind.h, in the group Auxiliary Data Structures; the same class on the Doxygen site.

template< typename IM >
class ExtendFindEnum

A Extend-Find data structure implementation which is able to enumerate the components.

The class implements an Extend-Find data structure which is able to enumerate the components and the items in a component. The data structure is a simplification of the Union-Find structure, and it does not allow to merge two components.

Pre:

You need to add all the elements by the insert() method.

Public Types

typedef IM ItemIntMap

typedef ItemIntMap::Key Item

Public Functions

inline ExtendFindEnum( ItemIntMap & _index )

Constructor.

inline int insert( const Item & item )

Inserts the given element into a new component.

This method creates a new component consisting only of the given element.

inline void insert( const Item & item , int cls )

Inserts the given element into the given component.

This methods inserts the element item a into the cls class.

inline void clear()

Clears the union-find data structure.

Erase each item from the data structure.

inline int find( const Item & item ) const

Gives back the class of the item.

inline Item item( int cls ) const

Gives back a representant item of the component.

inline void erase( const Item & item )

Removes the given element from the structure.

Removes the element from its component and if the component becomes empty then removes that component from the component list.

Warning

It is an error to remove an element which is not in the structure.

inline void eraseClass( int cdx )

Removes the component of the given element from the structure.

Warning

It is an error to give an element which is not in the structure.

class ClassIt

LEMON style iterator for the classes.

ClassIt is a lemon style iterator for the components. It iterates on the ids of classes.

Public Functions

inline ClassIt( const ExtendFindEnum & ufe )

Constructor of the iterator

inline ClassIt(Invalid)

Constructor to get invalid iterator

inline ClassIt & operator++()

Increment operator.

It steps to the next representant item.

inline operator int() const

Conversion operator.

It converts the iterator to the current class id.

inline bool operator==( const ClassIt & i )

Equality operator

inline bool operator!=( const ClassIt & i )

Inequality operator

class ItemIt

LEMON style iterator for the items of a component.

ClassIt is a lemon style iterator for the components. It iterates on the items of a class. By example if you want to iterate on each items of each classes then you may write the next code.

for( ClassIt cit( ufe ) ; cit != INVALID ; ++cit )
{
 std::cout << "Class: ";
 for( ItemIt iit( ufe , cit ) ; iit != INVALID ; ++iit ) {
  std::cout << toString( iit ) << ' ' << std::endl;
  }
 std::cout << std::endl;
 }

Public Functions

inline ItemIt( const ExtendFindEnum & ufe , int cls )

Constructor of the iterator. The iterator iterates on the class of the item.

inline ItemIt(Invalid)

Constructor to get invalid iterator

inline ItemIt & operator++()

Increment operator.

It steps to the next item in the class.

inline operator const Item&() const

Conversion operator.

It converts the iterator to the current item.

inline bool operator==( const ItemIt & i )

Equality operator

inline bool operator!=( const ItemIt & i )

Inequality operator