9#include <initializer_list> 
   19  static const long zero = 31; 
 
   26  static inline uint64_t 
to_set(
long pos) {
 
   29    return 1ul << (uint64_t) pos;
 
   51  BitSet(std::initializer_list<int> l) {
 
   71    return __builtin_popcountl(
set);
 
   75  inline bool get(
long pos)
 const {
 
   95  inline operator bool()
 const {
 
  122    uint64_t mask = (1ul << (uint64_t) (
zero + 1)) - 1ul;
 
  141  for (
long i = 1; i < 32; ++i) {
 
  142    if (bs.
get(i)) os << i << 
"+";
 
  143    if (bs.
get(-i)) os << i << 
"-";
 
  159    throw std::runtime_error(
"Err");
 
  162  while (str[pos] != 
'}') {
 
  164    while (isdigit(str[pos])) {
 
  165      d = d * 10 + str[pos] - 
'0';
 
  170    else if (str[pos] != 
'+')
 
  171      throw std::runtime_error(
"Err");
 
Set using bitfield.
Definition: bitset.h:18
std::istream & operator>>(std::istream &is, BitSet &bs)
Read a bit set.
Definition: bitset.h:155
bool operator>=(BitSet a) const
True if .
Definition: bitset.h:105
BitSet(std::initializer_list< int > l)
Initialize a set based on a list of numbers.
Definition: bitset.h:51
uint64_t set
The bitfield of this set.
Definition: bitset.h:33
BitSet operator^(BitSet a) const
Definition: bitset.h:90
static uint64_t to_set(long pos)
Turn number into corresponding element of set.
Definition: bitset.h:26
BitSet operator|(BitSet a) const
Union with another set.
Definition: bitset.h:85
BitSet & flip(long pos)
Flipping an element.
Definition: bitset.h:64
static const long zero
negative zero start at 31 (1<<31).
Definition: bitset.h:19
BitSet operator&(BitSet a) const
Intersection with another set.
Definition: bitset.h:80
bool get(long pos) const
Return whether a number is in the set.
Definition: bitset.h:75
BitSet()
Default to empty set.
Definition: bitset.h:36
bool operator<=(BitSet a) const
True if .
Definition: bitset.h:100
long size() const
The number of elements currently stored in the set.
Definition: bitset.h:70
std::ostream & operator<<(std::ostream &os, const BitSet &bs)
Print a bit set.
Definition: bitset.h:139
BitSet operator!() const
Negate all elements in the set, not a set operation.
Definition: bitset.h:119
BitSet(uint64_t s)
Initialize a set based on an unsigned bitfield.
Definition: bitset.h:39