Scippy

SoPlex

Sequential object-oriented simPlex

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. More...

#include <nameset.h>

Classes

class  Name
 Handles of names in a NameSet.Class Name provides the handles (i.e., char*s) of names in a NameSet. More...
 

Public Member Functions

Inquiry
const char * operator[] (int pnum) const
 returns num 'th name of NameSet. More...
 
const char * operator[] (const DataKey &pkey) const
 returns name for DataKey pkey of NameSet. More...
 
int num () const
 returns nr. of names in NameSet. More...
 
int max () const
 returns maximum nr. of names that fit into NameSet. More...
 
int size () const
 returns maximum DataKey::idx used in NameSet. More...
 
int memMax () const
 returns maximum length of string memory. More...
 
int memSize () const
 returns used length of string memory. More...
 
DataKey key (int pnum) const
 returns DataKey of the pnum 'th name in NameSet. More...
 
DataKey key (const char *str) const
 returns DataKey of name str in NameSet. More...
 
int number (const DataKey &pkey) const
 returns number of name with DataKey pkey in NameSet. More...
 
int number (const char *str) const
 returns number of name str in NameSet. More...
 
bool has (int pnum) const
 does NameSet has a name with number pnum? More...
 
bool has (const char *str) const
 does NameSet has a name str? More...
 
bool has (const DataKey &pkey) const
 does NameSet has a name with DataKey pkey? More...
 
Extension
void add (const char *str)
 
void add (DataKey &key, const char *str)
 adds name str to NameSet. More...
 
void add (const NameSet &set)
 
void add (DataKey key[], const NameSet &nset)
 adds all names in set to NameSet. More...
 
Shrinking
void remove (const DataKey &key)
 removes name with DataKey key from NameSet. More...
 
void remove (int pnum)
 removes pnum 'th name from NameSet. More...
 
void remove (const char *str)
 removes name str from NameSet. More...
 
void remove (const DataKey keys[], int n)
 removes n names with DataKeys keys from NameSet. More...
 
void remove (const int nums[], int n)
 removes n names with numbers nums from NameSet. More...
 
void remove (int dstat[])
 remove all entries where dstat is less than zero. More...
 
void clear ()
 removes all names from NameSet. More...
 
Memory Control
void reMax (int newmax=0)
 resets max() to newmax. More...
 
void memRemax (int newmax=0)
 resets memMax() to newmax. More...
 
void memPack ()
 garbage collection. More...
 
Miscellaneous
bool isConsistent () const
 consistency check. More...
 
Constructors / Destructors
 NameSet (int max=10000, int mmax=-1, Real fac=2, Real memFac=2)
 default constructor. More...
 
 ~NameSet ()
 destructor. More...
 

Public Attributes

Control Parameters
Real factor
 memory extension factor for entries. More...
 
Real memFactor
 memory extension factor for names. More...
 

Private Member Functions

Blocked
 NameSet (const NameSet &old)
 copy constructor. More...
 
NameSetoperator= (const NameSet &rhs)
 assignment operator. More...
 

Private Attributes

Data
DataSet< int > set
 name set. More...
 
char * mem
 string memory More...
 
int memmax
 size of string memory More...
 
int memused
 size of used string memory More...
 
DataHashTable< Name, DataKeyhashtab
 hashtable for names More...
 

Detailed Description

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.

Warning
Since the keys the NameSet uses to reference the strings are generated internally, it is extremly important that the calls to DataSet from within NameSet are synchronous to any calls outside to DataSet, such as in row or column adding.

Definition at line 61 of file nameset.h.

Constructor & Destructor Documentation

NameSet ( int  max = 10000,
int  mmax = -1,
Real  fac = 2,
Real  memFac = 2 
)
explicit

default constructor.

Parameters
maxstart value for max()
mmaxstart value for memMax()
facstart value for factor
memFacstart value for memFactor

Definition at line 247 of file nameset.cpp.

References NameSet::max(), NameSet::mem, NameSet::memmax, NameSet::memused, and soplex::spx_alloc().

Referenced by soplex::NameSetNameHashFunction().

NameSet ( const NameSet old)
private

copy constructor.

Member Function Documentation

void add ( const NameSet set)

Definition at line 64 of file nameset.cpp.

References NameSet::add(), NameSet::hashtab, and NameSet::num().

void add ( DataKey  key[],
const NameSet nset 
)

adds all names in set to NameSet.

Definition at line 74 of file nameset.cpp.

References NameSet::add(), NameSet::hashtab, and NameSet::num().

void clear ( )

removes all names from NameSet.

Definition at line 131 of file nameset.cpp.

References NameSet::hashtab, and NameSet::memused.

Referenced by SPxLPBase< R >::readLPF(), SPxLPBase< R >::readMPS(), and NameSet::remove().

bool has ( const char *  str) const

does NameSet has a name str?

Definition at line 237 of file nameset.h.

References DataHashTable< HashItem, Info >::has().

bool has ( const DataKey pkey) const

does NameSet has a name with DataKey pkey?

Definition at line 244 of file nameset.h.

References NameSet::add(), and NameSet::key().

bool isConsistent ( ) const
DataKey key ( int  pnum) const
DataKey key ( const char *  str) const

returns DataKey of name str in NameSet.

Definition at line 204 of file nameset.h.

References DataHashTable< HashItem, Info >::get().

int max ( ) const

returns maximum nr. of names that fit into NameSet.

Definition at line 174 of file nameset.h.

Referenced by NameSet::add(), NameSet::NameSet(), and soplex::NameSetNameHashFunction().

int memMax ( ) const

returns maximum length of string memory.

Definition at line 186 of file nameset.h.

References NameSet::memmax.

Referenced by NameSet::add(), NameSet::memPack(), and soplex::NameSetNameHashFunction().

void memRemax ( int  newmax = 0)
int memSize ( ) const

returns used length of string memory.

Definition at line 192 of file nameset.h.

References NameSet::memused.

Referenced by NameSet::add(), NameSet::memPack(), NameSet::memRemax(), and soplex::NameSetNameHashFunction().

int num ( ) const
int number ( const char *  str) const

returns number of name str in NameSet.

Definition at line 218 of file nameset.h.

References DataHashTable< HashItem, Info >::get(), DataHashTable< HashItem, Info >::has(), and NameSet::number().

NameSet& operator= ( const NameSet rhs)
private

assignment operator.

Referenced by soplex::NameSetNameHashFunction().

const char* operator[] ( int  pnum) const

returns num 'th name of NameSet.

Definition at line 156 of file nameset.h.

const char* operator[] ( const DataKey pkey) const

returns name for DataKey pkey of NameSet.

Definition at line 162 of file nameset.h.

void reMax ( int  newmax = 0)
void remove ( const DataKey key)

removes name with DataKey key from NameSet.

Definition at line 96 of file nameset.cpp.

References NameSet::has(), NameSet::hashtab, and NameSet::mem.

void remove ( int  pnum)

removes pnum 'th name from NameSet.

Definition at line 272 of file nameset.h.

References NameSet::clear(), NameSet::key(), NameSet::memPack(), NameSet::memRemax(), and NameSet::reMax().

void remove ( const char *  str)

removes name str from NameSet.

Definition at line 84 of file nameset.cpp.

References NameSet::hashtab.

void remove ( const DataKey  keys[],
int  n 
)

removes n names with DataKeys keys from NameSet.

Definition at line 104 of file nameset.cpp.

void remove ( const int  nums[],
int  n 
)

removes n names with numbers nums from NameSet.

Definition at line 110 of file nameset.cpp.

void remove ( int  dstat[])

remove all entries where dstat is less than zero.

Definition at line 116 of file nameset.cpp.

References NameSet::hashtab, NameSet::isConsistent(), and NameSet::mem.

int size ( ) const

returns maximum DataKey::idx used in NameSet.

Definition at line 180 of file nameset.h.

Referenced by NameSet::add(), and soplex::NameSetNameHashFunction().

Member Data Documentation

Real factor

memory extension factor for entries.

When more than max() names are added to a NameSet, it is automatically resized to fit the additional names. Parameter factor is the factor by which the element memory is extended to do so.

Definition at line 317 of file nameset.h.

Referenced by NameSet::add(), and soplex::NameSetNameHashFunction().

DataHashTable< Name, DataKey > hashtab
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 147 of file nameset.h.

Referenced by NameSet::add(), NameSet::clear(), NameSet::isConsistent(), NameSet::memPack(), NameSet::memRemax(), soplex::NameSetNameHashFunction(), NameSet::reMax(), and NameSet::remove().

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.

Definition at line 325 of file nameset.h.

Referenced by NameSet::add(), and soplex::NameSetNameHashFunction().

int memmax
private
int memused
private
DataSet< int > set
private

name set.

Definition at line 139 of file nameset.h.

Referenced by soplex::NameSetNameHashFunction().