56 char* tmp = &(
mem[idx]);
57 memused += int(strlen(str)) + 1;
60 *(
set.create(p_key)) = idx;
68 for(
int i = 0; i < p_set.
num(); ++i)
79 for(
int i = 0; i < p_set.
num(); ++i)
84 add(p_key[i], p_set[i]);
111 for(
int i = 0; i < n; ++i)
117 for(
int i = 0; i < n; ++i)
123 for(
int i = 0; i <
set.num(); i++)
157 for(
int i =
num() - 1; i >= 0; --i)
171 for(i = 0; i <
num(); i++)
173 const char* t = &
mem[
set[i]];
176 newlast += int(strlen(t)) + 1;
179 memcpy(
mem, newmem, static_cast<size_t>(newlast));
186 for(i = 0; i <
num(); i++)
193 unsigned int res = 37;
194 const char* sptr = str->
name;
199 res += (
unsigned int)(*sptr++);
215 memmax = (mmax < 1) ? (8 *
set.
max() + 1) : mmax;
226 #ifdef ENABLE_CONSISTENCY_CHECKS 233 for(i = 0; i <
num(); i++)
235 const char* t = &
mem[
set[i]];
240 if(strcmp(t,
operator[](
key(t))))
244 return set.isConsistent() &&
hashtab.isConsistent();
252 for(
int i = 0; i < nset.
num(); i++)
256 << nset.
key(i).
idx <<
"= " static int NameSetNameHashFunction(const NameSet::Name *str)
returns the hash value of the name.
int memSize() const
returns used length of string memory.
const char * name
pointer to the name string.
int num() const
returns nr. of names in NameSet.
Memory allocation routines.
DataHashTable< Name, DataKey > hashtab
hashtable for names
void reMax(int newmax=0)
resets max() to newmax.
#define HASHTABLE_FILLFACTOR
Entry identifier class for items of a DataSet.Every item in a DataSet is assigned a DataKey by which ...
static const char deflt
default zero string.
int memmax
size of string memory
Handles of names in a NameSet.Class Name provides the handles (i.e., char*s) of names in a NameSet...
NameSet(int max=10000, int mmax=-1, Real fac=2, Real memFac=2)
default constructor.
void spx_alloc(T &p, int n=1)
Allocate memory.
DataSet< int > set
name set.
std::ostream & operator<<(std::ostream &s, const VectorBase< R > &vec)
Output operator.
int spxSnprintf(char *t, size_t len, const char *s,...)
safe version of snprintf
int info
user information to store values -1, 0, +1
Real factor
memory extension factor for entries.
DataKey key(int pnum) const
returns DataKey of the pnum 'th name in NameSet.
void add(const char *str)
void clear()
removes all names from NameSet.
Debugging, floating point type and parameter definitions.
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
void spx_realloc(T &p, int n)
Change amount of allocated memory.
Everything should be within this namespace.
int memused
size of used string memory
void memRemax(int newmax=0)
resets memMax() to newmax.
void memPack()
garbage collection.
Real memFactor
memory extension factor for names.
bool isConsistent() const
consistency check.
#define MSGinconsistent(name)
int max() const
returns maximum nr. of names that fit into NameSet.
int size() const
returns maximum DataKey::idx used in NameSet.
void remove(const DataKey &key)
removes name with DataKey key from NameSet.
int idx
(locally) unique key index
void spx_free(T &p)
Release memory.
bool has(int pnum) const
does NameSet has a name with number pnum?
int memMax() const
returns maximum length of string memory.