Regina Calculation Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
regina::NBoolSet Class Reference

A set of booleans. More...

#include <utilities/nbooleans.h>

Public Member Functions

 NBoolSet ()
 Creates a new empty set. More...
 
 NBoolSet (bool member)
 Creates a set containing a single member as given. More...
 
 NBoolSet (const NBoolSet &cloneMe)
 Creates a set equal to the given set. More...
 
 NBoolSet (bool insertTrue, bool insertFalse)
 Creates a set specifying whether true and/or false should be a member. More...
 
bool hasTrue () const
 Determines if true is a member of this set. More...
 
bool hasFalse () const
 Determines if false is a member of this set. More...
 
bool contains (bool value) const
 Determines if the given boolean is a member of this set. More...
 
void insertTrue ()
 Inserts true into this set if it is not already present. More...
 
void insertFalse ()
 Inserts false into this set if it is not already present. More...
 
void removeTrue ()
 Removes true from this set if it is present. More...
 
void removeFalse ()
 Removes false from this set if it is present. More...
 
void empty ()
 Removes all elements from this set. More...
 
void fill ()
 Places both true and false into this set if they are not already present. More...
 
bool operator== (const NBoolSet &other) const
 Determines if this set is equal to the given set. More...
 
bool operator!= (const NBoolSet &other) const
 Determines if this set is not equal to the given set. More...
 
bool operator< (const NBoolSet &other) const
 Determines if this set is a proper subset of the given set. More...
 
bool operator> (const NBoolSet &other) const
 Determines if this set is a proper superset of the given set. More...
 
bool operator<= (const NBoolSet &other) const
 Determines if this set is a subset of (possibly equal to) the given set. More...
 
bool operator>= (const NBoolSet &other) const
 Determines if this set is a superset of (possibly equal to) the given set. More...
 
NBoolSetoperator= (const NBoolSet &cloneMe)
 Sets this set to be identical to the given set. More...
 
NBoolSetoperator= (bool member)
 Sets this set to the single member set containing the given element. More...
 
NBoolSetoperator|= (const NBoolSet &other)
 Sets this set to be the union of this and the given set. More...
 
NBoolSetoperator&= (const NBoolSet &other)
 Sets this set to be the intersection of this and the given set. More...
 
NBoolSetoperator^= (const NBoolSet &other)
 Sets this set to be the symmetric difference of this and the given set. More...
 
NBoolSet operator| (const NBoolSet &other) const
 Returns the union of this set with the given set. More...
 
NBoolSet operator& (const NBoolSet &other) const
 Returns the intersection of this set with the given set. More...
 
NBoolSet operator^ (const NBoolSet &other) const
 Returns the symmetric difference of this set and the given set. More...
 
NBoolSet operator~ () const
 Returns the complement of this set. More...
 
unsigned char getByteCode () const
 Returns the byte code representing this boolean set. More...
 
void setByteCode (unsigned char code)
 Sets this boolean set to that represented by the given byte code. More...
 

Static Public Member Functions

static NBoolSet fromByteCode (unsigned char code)
 Creates a boolean set from the given byte code. More...
 

Static Public Attributes

static const NBoolSet sNone
 The empty set. More...
 
static const NBoolSet sTrue
 The set containing only true. More...
 
static const NBoolSet sFalse
 The set containing only false. More...
 
static const NBoolSet sBoth
 The set containing both true and false. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const NBoolSet &set)
 Writes the given boolean set to the given output stream. More...
 

Detailed Description

A set of booleans.

Note that there are only four possible such sets. NBoolSet objects are small enough to pass about by value instead of by reference.

Constructor & Destructor Documentation

regina::NBoolSet::NBoolSet ( )
inline

Creates a new empty set.

regina::NBoolSet::NBoolSet ( bool  member)
inline

Creates a set containing a single member as given.

Parameters
memberthe single element to include in this set.
regina::NBoolSet::NBoolSet ( const NBoolSet cloneMe)
inline

Creates a set equal to the given set.

Parameters
cloneMethe set upon which we will base the new set.
regina::NBoolSet::NBoolSet ( bool  insertTrue,
bool  insertFalse 
)
inline

Creates a set specifying whether true and/or false should be a member.

Parameters
insertTrueshould the new set include the element true?
insertFalseshould the new set include the element false?

Member Function Documentation

bool regina::NBoolSet::contains ( bool  value) const
inline

Determines if the given boolean is a member of this set.

Parameters
valuethe boolean to search for in this set.
Returns
true if and only if the given boolean is a member of this set.
void regina::NBoolSet::empty ( )
inline

Removes all elements from this set.

void regina::NBoolSet::fill ( )
inline

Places both true and false into this set if they are not already present.

NBoolSet regina::NBoolSet::fromByteCode ( unsigned char  code)
inlinestatic

Creates a boolean set from the given byte code.

See getByteCode() for more information on byte codes.

Precondition
code is 0, 1, 2 or 3.
Parameters
codethe byte code from which the new set will be created.
unsigned char regina::NBoolSet::getByteCode ( ) const
inline

Returns the byte code representing this boolean set.

The byte code is sufficient to reconstruct the set and is thus a useful means for passing boolean sets to and from the engine.

The lowest order bit of the byte code is 1 if and only if true is in the set. The next lowest order bit is 1 if and only if false is in the set. All other bits are 0. Thus sets NBoolSet::sNone, NBoolSet::sTrue, NBoolSet::sFalse and NBoolSet::sBoth have byte codes 0, 1, 2 and 3 respectively.

Returns
the byte code representing this set.
bool regina::NBoolSet::hasFalse ( ) const
inline

Determines if false is a member of this set.

Returns
true if and only if false is a member of this set.
bool regina::NBoolSet::hasTrue ( ) const
inline

Determines if true is a member of this set.

Returns
true if and only if true is a member of this set.
void regina::NBoolSet::insertFalse ( )
inline

Inserts false into this set if it is not already present.

void regina::NBoolSet::insertTrue ( )
inline

Inserts true into this set if it is not already present.

bool regina::NBoolSet::operator!= ( const NBoolSet other) const
inline

Determines if this set is not equal to the given set.

Parameters
otherthe set to compare with this.
Returns
true if and only if this and the given set are not equal.
NBoolSet regina::NBoolSet::operator& ( const NBoolSet other) const
inline

Returns the intersection of this set with the given set.

The result is a set containing precisely the elements that belong to both original sets. This set is not changed.

Parameters
otherthe set to intersect with this set.
Returns
the intersection of this and the given set.
NBoolSet & regina::NBoolSet::operator&= ( const NBoolSet other)
inline

Sets this set to be the intersection of this and the given set.

The result is a set containing precisely the elements that belong to both original sets. Note that this set will be modified.

Parameters
otherthe set to intersect with this set.
Returns
a reference to this set.
bool regina::NBoolSet::operator< ( const NBoolSet other) const
inline

Determines if this set is a proper subset of the given set.

Parameters
otherthe set to compare with this.
Returns
true if and only if this is a proper subset of the given set.
bool regina::NBoolSet::operator<= ( const NBoolSet other) const
inline

Determines if this set is a subset of (possibly equal to) the given set.

Parameters
otherthe set to compare with this.
Returns
true if and only if this is a subset of the given set.
NBoolSet & regina::NBoolSet::operator= ( const NBoolSet cloneMe)
inline

Sets this set to be identical to the given set.

Parameters
cloneMethe set whose value this set will take.
Returns
a reference to this set.
NBoolSet & regina::NBoolSet::operator= ( bool  member)
inline

Sets this set to the single member set containing the given element.

Parameters
memberthe single element to include in this set.
Returns
a reference to this set.
bool regina::NBoolSet::operator== ( const NBoolSet other) const
inline

Determines if this set is equal to the given set.

Parameters
otherthe set to compare with this.
Returns
true if and only if this and the given set are equal.
bool regina::NBoolSet::operator> ( const NBoolSet other) const
inline

Determines if this set is a proper superset of the given set.

Parameters
otherthe set to compare with this.
Returns
true if and only if this is a proper superset of the given set.
bool regina::NBoolSet::operator>= ( const NBoolSet other) const
inline

Determines if this set is a superset of (possibly equal to) the given set.

Parameters
otherthe set to compare with this.
Returns
true if and only if this is a superset of the given set.
NBoolSet regina::NBoolSet::operator^ ( const NBoolSet other) const
inline

Returns the symmetric difference of this set and the given set.

The result is a set containing precisely the elements that belong to one but not both of the original sets. This set is not changed.

Parameters
otherthe set whose symmetric difference with this set is to be found.
Returns
the symmetric difference of this and the given set.
NBoolSet & regina::NBoolSet::operator^= ( const NBoolSet other)
inline

Sets this set to be the symmetric difference of this and the given set.

The result is a set containing precisely the elements that belong to one but not both of the original sets. Note that this set will be modified.

Parameters
otherthe set whose symmetric difference with this set is to be found.
Returns
a reference to this set.
NBoolSet regina::NBoolSet::operator| ( const NBoolSet other) const
inline

Returns the union of this set with the given set.

The result is a set containing precisely the elements that belong to either of the original sets. This set is not changed.

Parameters
otherthe set to union with this set.
Returns
the union of this and the given set.
NBoolSet & regina::NBoolSet::operator|= ( const NBoolSet other)
inline

Sets this set to be the union of this and the given set.

The result is a set containing precisely the elements that belong to either of the original sets. Note that this set will be modified.

Parameters
otherthe set to union with this set.
Returns
a reference to this set.
NBoolSet regina::NBoolSet::operator~ ( ) const
inline

Returns the complement of this set.

The result is a set containing precisely the elements that this set does not contain. This set is not changed.

Returns
the complement of this set.
void regina::NBoolSet::removeFalse ( )
inline

Removes false from this set if it is present.

void regina::NBoolSet::removeTrue ( )
inline

Removes true from this set if it is present.

void regina::NBoolSet::setByteCode ( unsigned char  code)
inline

Sets this boolean set to that represented by the given byte code.

See getByteCode() for more information on byte codes.

Precondition
code is 0, 1, 2 or 3.
Parameters
codethe byte code that will determine the new value of this set.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const NBoolSet set 
)
friend

Writes the given boolean set to the given output stream.

The set will be written in the form { true, false }, { true }, { false } or { }.

Parameters
outthe output stream to which to write.
setthe boolean set to write.
Returns
a reference to out.

Member Data Documentation

const NBoolSet regina::NBoolSet::sBoth
static

The set containing both true and false.

const NBoolSet regina::NBoolSet::sFalse
static

The set containing only false.

const NBoolSet regina::NBoolSet::sNone
static

The empty set.

const NBoolSet regina::NBoolSet::sTrue
static

The set containing only true.


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

Copyright © 1999-2013, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).