17 #ifndef VAR_NAMES_GUARD
18 #define VAR_NAMES_GUARD
24 #include <unordered_map>
50 bool addVar(
const string& name);
63 size_t getIndex(
const string& name)
const;
66 bool contains(
const string& name)
const;
74 const string&
getName(
size_t index)
const;
95 void print(FILE* file)
const;
103 static bool compareNames(
const string* a,
const string* b);
The purpose of this file is to provide a definition of a hash map whenever possible.
This class offers an input interface which is more convenient and for some purposes more efficient th...
Defines the variables of a polynomial ring and facilities IO involving them.
bool addVar(const string &name)
Adds the variable and returns true if name is not already a variable.
size_t getVarCount() const
Returns the current number of variables.
const string & getName(size_t index) const
The returned reference can become invalid next time addVar is called.
static bool compareNames(const string *a, const string *b)
void swap(VarNames &names)
void projectVar(size_t index)
bool operator!=(const VarNames &names) const
void swapVariables(size_t a, size_t b)
Swaps the variables with indexes a and b.
bool namesAreDefault() const
Returns true if the names are x1, x2 and so on.
static const size_t invalidIndex
Returns a fixed variable offset that is always invalid.
void clear()
Resets the number of variables to zero.
void print(FILE *file) const
vector< const string * > _indexToName
bool operator<(const VarNames &names) const
This also depends on the order of the names.
unordered_map< string, size_t > VarNameMap
size_t getIndex(const string &name) const
Returns VarNames::invalidIndex() if name is not known.
VarNames & operator=(const VarNames &names)
void toString(string &str) const
void addVarSyntaxCheckUnique(const Scanner &in, const string &name)
As addvar, except it reports a syntax error if name is already a variable.
bool empty() const
Returns true if the number of variables is zero.
bool operator==(const VarNames &names) const
bool contains(const string &name) const
Returns true if name is the name of a variable.