Prerequisits

#include <Bitset.h>
using namespace polymake; 

Introduction

class Bitset : public GenericSet<Bitset, int>;

A special class optimized for representation of a constrained range of non-negative integer numbers. Its implementation is based on the GMP integer numbers. You should consider to use it instead of the more general Set<int> if all these criteria hold:

— the element range stays constant during the lifetime of the set

— the element range is small (magnitude of tens), or the fill grade (number of elements divided thru the element upper bound) is expected to be considerably high (>= 0.5)

— the number of random access operations (testing/addition/removal of single elements) prevails significantly over the number of sequential visits via iterators

Note that unlike std::bitset, the element range is not hard encoded in the Bitset object, but can be dynamically changed any time.

Bitset is one of the few top-level classes in the Polymake Template Library that does not make use of reference counted smart pointers. It's difficult to say why. You should keep this in mind if you want to copy or return Bitset objects by value.

Construction

Bitset();
Create an empty set.
explicit Bitset (int n);
Create an empty set, anticipating it will eventually contain elements in the range [0..n]. This is just an optimization hint for the internal memory housekeeping, and by no means a constraint for the elements to be added later to the set.
template <typename Iterator> Bitset (Iterator src, Iterator src_end); template <typename Iterator> Bitset (Iterator src, end_sensitive);
Create a set, initialize the elements from a data sequence.
The only purpose of the dummy argument end_sensitive is to signal that the first argument src has to be treated as an end-sensitive iterator. A template constructor with a single argument would shadow all other constructors away!
template <typename OtherSet> Bitset (const GenericSet<OtherSet, int>&);
Create a set as a copy of another set of integers.
template <typename OtherSet, typename OtherElementType> explicit Bitset (const GenericSet<OtherSet, OtherElementType>&);
Copying with element conversion is also possible, but requires an explicit constructor call.
template <int n> explicit Bitset (const int (&a)[n]);
Create a set, copying the elements from a built-in array.

Modification

template <typename OtherSet> Bitset::operator= (const GenericSet<OtherSet, int>&);
Assign elements from another set.
void std::swap(Bitset&, Bitset&);
Swap the contents of two sets in a most efficient way.
void Bitset::clear();
Make the set empty.
void Bitset::reserve (int n);
Give a hint that elements from range [0..n] are expected to be added later. Additional memory is allocated if needed. As in the constructor case, it is only a hint, not a restriction.

Operations

Bitset implements the Reversible Container STL interface. Futhermore, all set-theoretic operations and input/output operators are applicable to Bitset objects. Some of them have specializations optimized for Bitset, as far as GMP supports them, but this should be transparent to the user.

For the sake of interchangeability with Set<int> following methods are defined:

bool Bitset::contains(int x);
Check whether x belongs to the set.
Bitset::iterator Bitset::insert (int x); Bitset::iterator Bitset::insert (const Bitset::iterator&, int x);
The same as Bitset::operator+= (int) . The optional iterator argument is introduced solely for the sake of compatibility with other set classes and is ignored. Return an iterator pointing to the added element.
void Bitset::push_back (int x); void Bitset::push_front (int x);
The same as Bitset::operator+= (int) . x need not even to be in fact the greatest/least element, since the operation works directly with the corresponding bit of the internal representation.
void Bitset::erase (int x); void Bitset::erase (const Bitset::iterator& where);
The same as Bitset::operator-= (int) . The iterator where points to the element to be removed.
void Bitset::pop_front(); void Bitset::pop_back();
Remove the first/last element.