33 const Name nstr (str);
54 char* tmp = &(
mem[idx]);
55 memused += int(strlen(str)) + 1;
58 *(
set.create(p_key)) = idx;
66 for (
int i = 0; i < p_set.
num(); ++i)
76 for (
int i = 0; i < p_set.
num(); ++i)
80 add(p_key[i], p_set[i]);
106 for (
int i = 0; i < n; ++i)
112 for (
int i = 0; i < n; ++i)
118 for(
int i = 0; i <
set.num(); i++)
151 for (
int i =
num() - 1; i >= 0; --i)
165 for(i = 0; i <
num(); i++)
167 const char* t = &
mem[
set[i]];
170 newlast += int(strlen(t)) + 1;
172 memcpy(
mem, newmem, static_cast<size_t>(newlast));
179 for (i = 0; i <
num(); i++)
186 unsigned int res = 37;
187 const char* sptr = str->
name;
192 res += (
unsigned int) (*sptr++);
207 memmax = (mmax < 1) ? (8 *
set.
max() + 1) : mmax;
218 #ifdef ENABLE_CONSISTENCY_CHECKS 224 for(i = 0; i <
num(); i++)
226 const char* t = &
mem[
set[i]];
231 if (strcmp(t,
operator[](
key(t))))
234 return set.isConsistent() &&
hashtab.isConsistent();
242 for(
int i = 0; i < nset.
num(); i++)
246 << 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.