Frobby 0.10.0
Loading...
Searching...
No Matches
VarNames Class Reference

#include <VarNames.h>

Public Member Functions

 VarNames (size_t varCount)
 VarNames (const VarNames &names)
bool addVar (const string &name)
void addVarSyntaxCheckUnique (const Scanner &in, const string &name)
bool operator< (const VarNames &names) const
size_t getIndex (const string &name) const
bool contains (const string &name) const
bool namesAreDefault () const
const string & getName (size_t index) const
size_t getVarCount () const
void clear ()
bool empty () const
VarNames & operator= (const VarNames &names)
bool operator== (const VarNames &names) const
bool operator!= (const VarNames &names) const
void swapVariables (size_t a, size_t b)
void projectVar (size_t index)
void toString (string &str) const
void print (FILE *file) const
void swap (VarNames &names)

Static Public Attributes

static const size_t invalidIndex = static_cast<size_t>(-1)

Detailed Description

Defines the variables of a polynomial ring and facilities IO involving them.

Todo
Rename to Ring or a similar name.
Todo
make this class immutable and make a VarNamesBuilder.
Todo
make copies share the same memory and use reference counting to deallocate the shared memory.
Todo
make equality check for the same memory and thus return true very quickly if that is the case.

Member Function Documentation

◆ addVar()

bool VarNames::addVar ( const string & name)

Adds the variable and returns true if name is not already a variable. Otherwise it returns false without adding the variable (again).

◆ addVarSyntaxCheckUnique()

void VarNames::addVarSyntaxCheckUnique ( const Scanner & in,
const string & name )

As addvar, except it reports a syntax error if name is already a variable.

Todo
Move this somewhere more appropriate.

◆ clear()

void VarNames::clear ( )

Resets the number of variables to zero.

◆ contains()

bool VarNames::contains ( const string & name) const

Returns true if name is the name of a variable.

◆ empty()

bool VarNames::empty ( ) const

Returns true if the number of variables is zero.

◆ getIndex()

size_t VarNames::getIndex ( const string & name) const

Returns VarNames::invalidIndex() if name is not known.

◆ getName()

const string & VarNames::getName ( size_t index) const

The returned reference can become invalid next time addVar is called.

◆ getVarCount()

size_t VarNames::getVarCount ( ) const
inline

Returns the current number of variables.

◆ namesAreDefault()

bool VarNames::namesAreDefault ( ) const

Returns true if the names are x1, x2 and so on.

◆ operator<()

bool VarNames::operator< ( const VarNames & names) const

This also depends on the order of the names.

◆ swapVariables()

void VarNames::swapVariables ( size_t a,
size_t b )

Swaps the variables with indexes a and b.

Member Data Documentation

◆ invalidIndex

const size_t VarNames::invalidIndex = static_cast<size_t>(-1)
static

Returns a fixed variable offset that is always invalid.


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