SoPlex
|
Set of strings. More...
#include <nameset.h>
Classes | |
class | Name |
Handles of names in a NameSet. More... |
Public Member Functions | |
Inquiry | |
const char * | operator[] (int pnum) const |
returns num 'th name of NameSet. | |
const char * | operator[] (const DataKey &pkey) const |
returns name for DataKey pkey of NameSet. | |
int | num () const |
returns nr. of names in NameSet. | |
int | max () const |
returns maximum nr. of names that fit into NameSet. | |
int | size () const |
returns maximum DataKey::idx used in NameSet. | |
int | memMax () const |
returns maximum length of string memory. | |
int | memSize () const |
returns used length of string memory. | |
DataKey | key (int pnum) const |
returns DataKey of the pnum 'th name in NameSet. | |
DataKey | key (const char *str) const |
returns DataKey of name str in NameSet. | |
int | number (const DataKey &pkey) const |
returns number of name with DataKey pkey in NameSet. | |
int | number (const char *str) const |
returns number of name str in NameSet. | |
bool | has (int pnum) const |
does NameSet has a name with number pnum ? | |
bool | has (const char *str) const |
does NameSet has a name str ? | |
bool | has (const DataKey &pkey) const |
does NameSet has a name with DataKey pkey ? | |
Extension | |
void | add (const char *str) |
void | add (DataKey &key, const char *str) |
adds name str to NameSet. | |
void | add (const NameSet &set) |
void | add (DataKey key[], const NameSet &nset) |
adds all names in set to NameSet. | |
Shrinking | |
void | remove (const DataKey &key) |
removes name with DataKey key from NameSet. | |
void | remove (int pnum) |
removes pnum 'th name from NameSet. | |
void | remove (const char *str) |
removes name str from NameSet. | |
void | remove (const DataKey keys[], int n) |
removes n names with DataKeys keys from NameSet. | |
void | remove (const int nums[], int n) |
removes n names with numbers nums from NameSet. | |
void | remove (int dstat[]) |
remove all entries where dstat is less than zero. | |
void | clear () |
removes all names from NameSet. | |
Memory Control | |
void | reMax (int newmax=0) |
resets max() to newmax . | |
void | memRemax (int newmax=0) |
resets memMax() to newmax . | |
void | memPack () |
garbage collection. | |
Miscellaneous | |
bool | isConsistent () const |
consistency check. | |
Constructors / Destructors | |
NameSet (int max=10000, int mmax=-1, Real fac=2, Real memFac=2) | |
default constructor. | |
~NameSet () | |
destructor. |
Public Attributes | |
Control Parameters | |
Real | factor |
memory extension factor for entries. | |
Real | memFactor |
memory extension factor for names. |
Private Member Functions | |
Blocked | |
NameSet (const NameSet &old) | |
copy constructor. | |
NameSet & | operator= (const NameSet &rhs) |
assignment operator. |
Private Attributes | |
Data | |
DataSet< int > | set |
name set. | |
char * | mem |
string memory | |
int | memmax |
size of string memory | |
int | memused |
size of used string memory | |
DataHashTable< Name, DataKey > | hashtab |
hashtable for names |
Set of strings.
Class NameSet implements a symbol or name table. It allows to store or remove names (i.e., char*
), but does not provide means for manipulating stored names.
Names in a NameSet may be accessed via numbers from 0 through num()-1 and via DataKeys. See DataSet for a description of these concepts.
At a time a NameSet can hold a maximum of max() entries. This can be reset with method reMax(). If more than max() names are added to a NameSet, it adjusts itself automatically to the required size. This implies, that references to names within a NameSet may become invalid if the NameSet is expanded.
All names (i.e., the actual char strings) in a NameSet are stored in one continuous memory block of size memMax(). At one time memSize() bytes of it are used for actually saving names; the remaining memory is free to hold additional names. memRemax() can be used to reset memMax() but not lower than to memSize(). Method memPack() performs a garbage collection to gain free memory resulting from removed names.
default constructor.
max | start value for max() |
mmax | start value for memMax() |
fac | start value for factor |
memFac | start value for memFactor |
Definition at line 216 of file nameset.cpp.
References factor, hashtab, max(), mem, memFactor, memmax, memused, soplex::NameSetNameHashFunction(), set, and soplex::spx_alloc().
Referenced by add(), add(), NameSet(), and operator=().
~NameSet | ( | ) |
void add | ( | const char * | str | ) |
void add | ( | const NameSet & | set | ) |
void add | ( | DataKey & | key, |
const char * | str ) |
adds name str
to NameSet.
Definition at line 40 of file nameset.cpp.
References factor, hashtab, max(), mem, memFactor, memMax(), memPack(), memRemax(), memSize(), memused, reMax(), set, size(), SOPLEX_HASHTABLE_FILLFACTOR, SPX_MAXSTRLEN, and soplex::spxSnprintf().
void clear | ( | ) |
bool has | ( | const char * | str | ) | const |
bool has | ( | const DataKey & | pkey | ) | const |
bool has | ( | int | pnum | ) | const |
bool isConsistent | ( | ) | const |
DataKey key | ( | const char * | str | ) | const |
DataKey key | ( | int | pnum | ) | const |
returns DataKey of the pnum
'th name in NameSet.
Definition at line 215 of file nameset.h.
References set.
Referenced by isConsistent(), memPack(), memRemax(), soplex::operator<<(), and remove().
int max | ( | ) | const |
int memMax | ( | ) | const |
void memPack | ( | ) |
garbage collection.
Definition at line 170 of file nameset.cpp.
References hashtab, key(), mem, memMax(), memSize(), memused, num(), set, soplex::spx_alloc(), soplex::spx_free(), SPX_MAXSTRLEN, and soplex::spxSnprintf().
Referenced by add().
void memRemax | ( | int | newmax = 0 | ) |
int memSize | ( | ) | const |
int num | ( | ) | const |
returns nr. of names in NameSet.
Definition at line 185 of file nameset.h.
References set.
Referenced by add(), add(), isConsistent(), memPack(), memRemax(), and soplex::operator<<().
int number | ( | const char * | str | ) | const |
int number | ( | const DataKey & | pkey | ) | const |
const char * operator[] | ( | const DataKey & | pkey | ) | const |
const char * operator[] | ( | int | pnum | ) | const |
void reMax | ( | int | newmax = 0 | ) |
void remove | ( | const char * | str | ) |
removes name str
from NameSet.
Definition at line 97 of file nameset.cpp.
void remove | ( | const DataKey & | key | ) |
void remove | ( | const DataKey | keys[], |
int | n ) |
removes n
names with DataKeys keys
from NameSet.
Definition at line 118 of file nameset.cpp.
References remove().
void remove | ( | const int | nums[], |
int | n ) |
removes n
names with numbers nums
from NameSet.
Definition at line 124 of file nameset.cpp.
References remove().
void remove | ( | int | dstat[] | ) |
remove all entries where dstat
is less than zero.
Definition at line 130 of file nameset.cpp.
References hashtab, isConsistent(), mem, and set.
void remove | ( | int | pnum | ) |
int size | ( | ) | const |
Real factor |
|
private |
hashtable for names
Every name in a NameSet is assigned a DataKey by which it can be accessed (see NameSet::operator[]()). See DataKey for a more detailed description of the concept of Keys.
Definition at line 164 of file nameset.h.
Referenced by add(), add(), add(), clear(), has(), isConsistent(), key(), memPack(), memRemax(), NameSet(), number(), reMax(), remove(), remove(), and remove().
|
private |
string memory
Definition at line 157 of file nameset.h.
Referenced by add(), isConsistent(), memPack(), memRemax(), NameSet(), operator[](), operator[](), remove(), remove(), and ~NameSet().
Real memFactor |
memory extension factor for names.
When the names added to a NameSet do no longer fit into the name memory (i.e. the memory for saving the strings), it is automatically resized to fit the additional names. Parameter memFactor
is the factor by which this memory is extended to do so.
|
private |
size of string memory
Definition at line 158 of file nameset.h.
Referenced by isConsistent(), memMax(), memRemax(), and NameSet().
|
private |