mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
m::GospersHack Struct Reference

Enumerate all subsets of size k based on superset of size n. More...

#include <ADT.hpp>

Collaboration diagram for m::GospersHack:
[legend]

Public Member Functions

GospersHackoperator++ ()
 Advance to the next subset.
 
 operator bool () const
 Returns false iff all subsets have been enumerated.
 
SmallBitset operator* () const
 Returns the current subset.
 

Static Public Member Functions

static GospersHack enumerate_all (uint64_t k, uint64_t n)
 Create an instance of GospersHack that enumerates all subsets of size k of a set of n elements.
 
static GospersHack enumerate_from (SmallBitset set, uint64_t n)
 Create an instance of GospersHack that enumerates all remaining subsets of a set of n elements, starting at subset set.
 

Private Member Functions

 GospersHack ()
 

Private Attributes

SmallBitset set_
 
uint64_t limit_
 

Detailed Description

Enumerate all subsets of size k based on superset of size n.

See http://programmingforinsomniacs.blogspot.com/2018/03/gospers-hack-explained.html.

Definition at line 829 of file ADT.hpp.

Constructor & Destructor Documentation

◆ GospersHack()

m::GospersHack::GospersHack ( )
inlineprivate

Definition at line 835 of file ADT.hpp.

Member Function Documentation

◆ enumerate_all()

static GospersHack m::GospersHack::enumerate_all ( uint64_t  k,
uint64_t  n 
)
inlinestatic

Create an instance of GospersHack that enumerates all subsets of size k of a set of n elements.

Definition at line 839 of file ADT.hpp.

References m::SmallBitset::All(), limit_, M_insist, and set_.

Referenced by DPsize::operator()(), DPsizeOpt::operator()(), and DPsizeSub::operator()().

◆ enumerate_from()

static GospersHack m::GospersHack::enumerate_from ( SmallBitset  set,
uint64_t  n 
)
inlinestatic

Create an instance of GospersHack that enumerates all remaining subsets of a set of n elements, starting at subset set.

Definition at line 849 of file ADT.hpp.

References limit_, M_insist, and set_.

Referenced by DPsizeOpt::operator()().

◆ operator bool()

m::GospersHack::operator bool ( ) const
inline

Returns false iff all subsets have been enumerated.

Definition at line 878 of file ADT.hpp.

References limit_, and set_.

◆ operator*()

SmallBitset m::GospersHack::operator* ( ) const
inline

Returns the current subset.

Definition at line 881 of file ADT.hpp.

References set_.

◆ operator++()

GospersHack & m::GospersHack::operator++ ( )
inline

Advance to the next subset.

Definition at line 859 of file ADT.hpp.

References set_.

Field Documentation

◆ limit_

uint64_t m::GospersHack::limit_
private

Definition at line 833 of file ADT.hpp.

Referenced by enumerate_all(), enumerate_from(), and operator bool().

◆ set_

SmallBitset m::GospersHack::set_
private

Definition at line 832 of file ADT.hpp.

Referenced by enumerate_all(), enumerate_from(), operator bool(), operator*(), and operator++().


The documentation for this struct was generated from the following file: