UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
IDPartitionEnumerator Class Reference

Provides a possibility to enumerate all partitions on a given set of IDs. More...

#include <IDPartitionEnumerator.h>

Collaboration diagram for IDPartitionEnumerator:
Collaboration graph
[legend]

Public Member Functions

 IDPartitionEnumerator (vector< IDType > const &idSet)
 Creates a new IDPartitionEnumerator with the given IDs. More...
 
 IDPartitionEnumerator (unordered_set< IDType > const &idSet)
 Creates a new IDPartitionEnumerator with the given IDs. More...
 
 IDPartitionEnumerator (IDPartitionEnumerator &&oldEnum)
 Moves the data of the given enumerator to a new IDPartitionEnumerator. More...
 
virtual ~IDPartitionEnumerator ()
 Destroy this instance of the enumerator.
 
bool isValid () const
 Return whether this IDPartitionEnumerator is in a valid state or not. More...
 
bool ended () const
 Returns true, if all possible IDPartions were enumerated. More...
 
void reset ()
 Resets this enumerator to start the enumeration process from the first element.
 
size_t baseSetSize () const
 Returns the size of the set of element on which partitions are enumerated. More...
 
IDPartitionEnumeratoroperator++ ()
 Computes the next IDPartition in the enumeration. More...
 
IDPartition const & operator* () const
 Returns the last IDPartition which was computed. More...
 

Private Member Functions

 IDPartitionEnumerator ()
 Generates an enumerator with no IDs. More...
 
void throwIfNotValid () const
 Checks if this IDPartitionEnumerator is still valid and throws an InvalidStateException if it is not.
 

Private Attributes

size_t current
 Stores at which index of genPartitionsVec the current IDPartition is stored.
 
size_t lastNew
 Stores the index of the first element of genPartitionsVec which was not already used to create more coarse IDPartitions.
 
vector< IDPartition * > * genPartitionsVec
 Stores all enumerated IDPartitions, where the order of the elements is the sequence in which the IDPartitions were computed.
 
unordered_set< IDPartition
*, IDPartitionPointerHasher,
IDPartitionPointerEquality > * 
genPartitionsSet
 Stores all enumerated IDPartitions to avoid enumerating the same IDPartition multiple times.
 
bool valid
 Stores whether this IDPartitionEnumerator is still valid.
 

Detailed Description

Provides a possibility to enumerate all partitions on a given set of IDs.

Initialized with the ID set, it behaves like an iterator independent of any collection (although not satisfying all necessary properties of such). This enumerator can be moved, but cannot be duplicated!

Author
Jan Stückrath

Constructor & Destructor Documentation

IDPartitionEnumerator ( vector< IDType > const &  idSet)

Creates a new IDPartitionEnumerator with the given IDs.

Duplicate IDs in the given collection are ignored.

Parameters
idSeta collection of IDs
IDPartitionEnumerator ( unordered_set< IDType > const &  idSet)

Creates a new IDPartitionEnumerator with the given IDs.

Parameters
idSeta collection of IDs

Moves the data of the given enumerator to a new IDPartitionEnumerator.

The new IDPartitionEnumerator has the same state as the old enumerator and the old enumerator is invalidated. The old enumerator may now longer be used!

Parameters
oldEnuman rvalue reference to an IDPartitionEnumerator
IDPartitionEnumerator ( )
private

Generates an enumerator with no IDs.

This constructor can/should only be called internally.

Member Function Documentation

size_t baseSetSize ( ) const

Returns the size of the set of element on which partitions are enumerated.

Returns
the size of the set of element on which partitions are enumerated
bool ended ( ) const

Returns true, if all possible IDPartions were enumerated.

This will be the case as soon as the ++-operator was called and unable to create any further IDPartitions.

Returns
true, iff all possible IDPartions were enumerated
bool isValid ( ) const

Return whether this IDPartitionEnumerator is in a valid state or not.

Returns
true, iff this IDPartitionEnumerator is in a valid state
IDPartition const & operator* ( ) const

Returns the last IDPartition which was computed.

If the enumerator has ended, this operator will not report an error, but return the (very) last IDPartition computed.

Returns
the last IDPartition computed
IDPartitionEnumerator & operator++ ( )

Computes the next IDPartition in the enumeration.

If there are no more IDPartitions, this enumerator is marked to have ended, but does not report an error. If this enumerator has ended, this operator does nothing (including reporting an error!).

Returns
a reference to itself (after computing the next IDPartition)

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