107 for (
int i = 0; i < card; ++i) {
120 template<
typename ContainerType>
187 for (i = t - 1;
m_index[i] == i + n - t; --i) {
197 for (++
m_index[i]; i < t - 1; ++i) {
225 std::function<
void(
const T&)> funcNotIn)
const {
237 template<
typename ContainerType>
239 std::function<
void(ContainerType&, T)> func)
const {
241 [&](
const T& nonmember) { func(
complement, nonmember); });
246 getSubsetAndComplement<List<T>>(subset,
complement,
251 bool testForAll(std::function<
bool(
const T&)> predicate)
const {
261 void print(std::ostream& os,
string delim =
" ")
const {
265 for (
int i = 1; i <
size(); ++i) {
270 os <<
"<<invalid subset>>";
Declaration and implementation of Array class and Array algorithms.
Declaration and implementation of ArrayBuffer class.
Basic declarations, included by all source files.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
void push(E e)
Puts a new element in the buffer.
INDEX size() const
Returns number of elements in the buffer.
The parameterized class Array implements dynamic arrays of type E.
void init()
Reinitializes the array to an array with empty index set.
INDEX size() const
Returns the size (number of elements) of the array.
Doubly linked lists (maintaining the length of the list).
iterator pushBack(const E &x)
Adds element x at the end of the list.
Enumerator for k-subsets of a given type.
void begin(int low, int high)
Initializes the SubsetEnumerator to enumerate subsets of cardinalities from low to high.
void print(std::ostream &os, string delim=" ") const
Prints subset to output stream os using delimiter delim.
int size() const
Returns the cardinality of the subset.
void forEachMemberAndNonmember(std::function< void(const T &)> funcIn, std::function< void(const T &)> funcNotIn) const
Calls funcIn for each subset member and funcNotIn for each other element of the set.
SubsetEnumerator(const ContainerType &set)
Constructor.
bool valid() const
Checks if the current subset is valid. If not, the subset is either not initialized or all subsets ha...
void begin()
Initializes the SubsetEnumerator to enumerate all subsets.
void begin(int card)
Initializes the SubsetEnumerator to enumerate subsets of given cardinality.
int numberOfMembersAndNonmembers() const
Returns the cardinality of the (super-)set. This is the maximum size that can be used for a subset.
void array(Array< T > &array) const
Obtains an array of the subset members.
T operator[](int i) const
Gets a member of subset by index (starting from 0).
void getSubsetAndComplement(ContainerType &subset, ContainerType &complement, std::function< void(ContainerType &, T)> func) const
Obtains a container of the subset members and a container of the other elements of the set.
void list(List< T > &subset) const
Obtains (appends) a list of the subset members.
bool testForAll(std::function< bool(const T &)> predicate) const
Tests predicate for all subset members.
void forEachMember(std::function< void(const T &)> func) const
Calls func for each member in the subset.
void next()
Obtains the next subset if possible. The result should be checked using the valid() method.
void initSubset(int card)
ArrayBuffer< T > m_subset
void list(List< T > &subset, List< T > &complement) const
Obtains (appends) a list of the subset members and a list of the other elements of the set.
bool hasMember(const T &element) const
Checks in O(subset cardinality) whether element is a member of the subset.
void complement(Graph &G, bool directed=false, bool allowSelfLoops=false)
Computes the complement of G.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.