UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
IDPartitionEnumerator.h
1 /***************************************************************************
2  * Copyright (C) 2014 by Jan Stückrath <jan.stueckrath@uni-due.de> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
18  ***************************************************************************/
19 
20 #ifndef IDPARTITIONENUMERATOR_H_
21 #define IDPARTITIONENUMERATOR_H_
22 
23 #include "IDPartition.h"
24 #include "InvalidStateException.h"
25 
26 namespace uncover {
27  namespace basic_types {
28 
33 
40  inline size_t operator()(const IDPartition* s) const;
41 
42  };
43 
48 
56  bool operator() (const IDPartition* x, const IDPartition* y) const;
57 
58  };
59 
67 
68  public:
69 
75  IDPartitionEnumerator(vector<IDType> const& idSet);
76 
81  IDPartitionEnumerator(unordered_set<IDType> const& idSet);
82 
90 
94  virtual ~IDPartitionEnumerator();
95 
100  bool isValid() const;
101 
107  bool ended() const;
108 
112  void reset();
113 
118  size_t baseSetSize() const;
119 
127 
133  IDPartition const& operator*() const;
134 
135  private:
136 
141 
146  void throwIfNotValid() const;
147 
151  size_t current;
152 
157  size_t lastNew;
158 
163  vector<IDPartition*>* genPartitionsVec;
164 
168  unordered_set<IDPartition*, IDPartitionPointerHasher, IDPartitionPointerEquality>* genPartitionsSet;
169 
173  bool valid;
174 
175  };
176 
177  } /* namespace basic_types */
178 } /* namespace uncover */
179 
180 #endif /* IDPARTITIONENUMERATOR_H_ */
IDPartitionEnumerator()
Generates an enumerator with no IDs.
Definition: IDPartitionEnumerator.cpp:60
bool valid
Stores whether this IDPartitionEnumerator is still valid.
Definition: IDPartitionEnumerator.h:173
A hasher for pointers to IDPartions.
Definition: IDPartitionEnumerator.h:32
unordered_set< IDPartition *, IDPartitionPointerHasher, IDPartitionPointerEquality > * genPartitionsSet
Stores all enumerated IDPartitions to avoid enumerating the same IDPartition multiple times...
Definition: IDPartitionEnumerator.h:168
bool operator()(const IDPartition *x, const IDPartition *y) const
Checks if the given IDPartitions pointed to are equal.
Definition: IDPartitionEnumerator.cpp:46
Provides a possibility to enumerate all partitions on a given set of IDs.
Definition: IDPartitionEnumerator.h:66
size_t baseSetSize() const
Returns the size of the set of element on which partitions are enumerated.
Definition: IDPartitionEnumerator.cpp:130
size_t operator()(const IDPartition *s) const
Takes a pointer to an IDPartition and returns a hash value.
Definition: IDPartitionEnumerator.cpp:29
An equality checker for pointers to IDPartitions.
Definition: IDPartitionEnumerator.h:47
bool ended() const
Returns true, if all possible IDPartions were enumerated.
Definition: IDPartitionEnumerator.cpp:141
void throwIfNotValid() const
Checks if this IDPartitionEnumerator is still valid and throws an InvalidStateException if it is not...
Definition: IDPartitionEnumerator.cpp:134
void reset()
Resets this enumerator to start the enumeration process from the first element.
Definition: IDPartitionEnumerator.cpp:146
virtual ~IDPartitionEnumerator()
Destroy this instance of the enumerator.
Definition: IDPartitionEnumerator.cpp:109
IDPartition const & operator*() const
Returns the last IDPartition which was computed.
Definition: IDPartitionEnumerator.cpp:194
size_t lastNew
Stores the index of the first element of genPartitionsVec which was not already used to create more c...
Definition: IDPartitionEnumerator.h:157
size_t current
Stores at which index of genPartitionsVec the current IDPartition is stored.
Definition: IDPartitionEnumerator.h:151
unordered_set< SubIDPartition > IDPartition
An IDPartition is a set of sets of IDs (which is effectively a set of equivalence classes)...
Definition: IDPartition.h:37
IDPartitionEnumerator & operator++()
Computes the next IDPartition in the enumeration.
Definition: IDPartitionEnumerator.cpp:151
vector< IDPartition * > * genPartitionsVec
Stores all enumerated IDPartitions, where the order of the elements is the sequence in which the IDPa...
Definition: IDPartitionEnumerator.h:163
bool isValid() const
Return whether this IDPartitionEnumerator is in a valid state or not.
Definition: IDPartitionEnumerator.cpp:126