Scippy

SoPlex

Sequential object-oriented simPlex

NameSet Class Reference

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. 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 70 of file nameset.h.

Constructor & Destructor Documentation

◆ NameSet() [1/2]

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 216 of file nameset.cpp.

References DataSet< DATA >::max(), NameSet::mem, NameSet::memmax, NameSet::memused, NameSet::set, and soplex::spx_alloc().

◆ ~NameSet()

~NameSet ( )

destructor.

Definition at line 228 of file nameset.cpp.

References NameSet::mem, and soplex::spx_free().

◆ NameSet() [2/2]

NameSet ( const NameSet old)
private

copy constructor.

Member Function Documentation

◆ add() [1/4]

void add ( const char *  str)

Definition at line 34 of file nameset.cpp.

References NameSet::add().

Referenced by NameSet::add().

◆ add() [2/4]

void add ( const NameSet set)

Definition at line 75 of file nameset.cpp.

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

◆ add() [3/4]

◆ add() [4/4]

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

adds all names in set to NameSet.

Definition at line 86 of file nameset.cpp.

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

◆ clear()

void clear ( )

removes all names from NameSet.

Definition at line 146 of file nameset.cpp.

References DataSet< DATA >::clear(), NameSet::hashtab, NameSet::memused, and NameSet::set.

◆ has() [1/3]

bool has ( const char *  str) const

does NameSet has a name str?

Definition at line 255 of file nameset.h.

References NameSet::hashtab.

◆ has() [2/3]

bool has ( const DataKey pkey) const

does NameSet has a name with DataKey pkey?

Definition at line 262 of file nameset.h.

References DataSet< DATA >::has(), and NameSet::set.

◆ has() [3/3]

bool has ( int  pnum) const

does NameSet has a name with number pnum?

Definition at line 249 of file nameset.h.

References DataSet< DATA >::has(), and NameSet::set.

Referenced by NameSet::isConsistent(), and NameSet::remove().

◆ isConsistent()

◆ key() [1/2]

DataKey key ( const char *  str) const

returns DataKey of name str in NameSet.

Definition at line 221 of file nameset.h.

References NameSet::hashtab.

◆ key() [2/2]

DataKey key ( int  pnum) const

returns DataKey of the pnum 'th name in NameSet.

Definition at line 215 of file nameset.h.

References DataSet< DATA >::key(), and NameSet::set.

Referenced by NameSet::isConsistent(), NameSet::memPack(), NameSet::memRemax(), soplex::operator<<(), and NameSet::remove().

◆ max()

int max ( ) const

returns maximum nr. of names that fit into NameSet.

Definition at line 191 of file nameset.h.

References DataSet< DATA >::max(), and NameSet::set.

Referenced by NameSet::add().

◆ memMax()

int memMax ( ) const

returns maximum length of string memory.

Definition at line 203 of file nameset.h.

References NameSet::memmax.

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

◆ memPack()

◆ memRemax()

void memRemax ( int  newmax = 0)

◆ memSize()

int memSize ( ) const

returns used length of string memory.

Definition at line 209 of file nameset.h.

References NameSet::memused.

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

◆ num()

int num ( ) const

returns nr. of names in NameSet.

Definition at line 185 of file nameset.h.

References DataSet< DATA >::num(), and NameSet::set.

Referenced by NameSet::add(), NameSet::isConsistent(), NameSet::memPack(), NameSet::memRemax(), and soplex::operator<<().

◆ number() [1/2]

int number ( const char *  str) const

returns number of name str in NameSet.

Definition at line 235 of file nameset.h.

References NameSet::hashtab, and NameSet::number().

◆ number() [2/2]

int number ( const DataKey pkey) const

returns number of name with DataKey pkey in NameSet.

Definition at line 229 of file nameset.h.

References DataSet< DATA >::number(), and NameSet::set.

Referenced by NameSet::number().

◆ operator=()

NameSet & operator= ( const NameSet rhs)
private

assignment operator.

◆ operator[]() [1/2]

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

returns name for DataKey pkey of NameSet.

Definition at line 179 of file nameset.h.

References NameSet::mem, and NameSet::set.

◆ operator[]() [2/2]

const char * operator[] ( int  pnum) const

returns num 'th name of NameSet.

Definition at line 173 of file nameset.h.

References NameSet::mem, and NameSet::set.

◆ reMax()

void reMax ( int  newmax = 0)

resets max() to newmax.

Definition at line 153 of file nameset.cpp.

References NameSet::hashtab, DataSet< DATA >::reMax(), and NameSet::set.

Referenced by NameSet::add().

◆ remove() [1/6]

void remove ( const char *  str)

removes name str from NameSet.

Definition at line 97 of file nameset.cpp.

References NameSet::hashtab, DataSet< DATA >::remove(), and NameSet::set.

◆ remove() [2/6]

void remove ( const DataKey key)

removes name with DataKey key from NameSet.

Definition at line 110 of file nameset.cpp.

References NameSet::has(), NameSet::hashtab, NameSet::mem, DataSet< DATA >::remove(), and NameSet::set.

Referenced by NameSet::remove().

◆ remove() [3/6]

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

removes n names with DataKeys keys from NameSet.

Definition at line 118 of file nameset.cpp.

References NameSet::remove().

◆ remove() [4/6]

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

removes n names with numbers nums from NameSet.

Definition at line 124 of file nameset.cpp.

References NameSet::remove().

◆ remove() [5/6]

void remove ( int  dstat[])

remove all entries where dstat is less than zero.

Definition at line 130 of file nameset.cpp.

References NameSet::hashtab, NameSet::isConsistent(), NameSet::mem, DataSet< DATA >::num(), DataSet< DATA >::remove(), and NameSet::set.

◆ remove() [6/6]

void remove ( int  pnum)

removes pnum 'th name from NameSet.

Definition at line 290 of file nameset.h.

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

◆ size()

int size ( ) const

returns maximum DataKey::idx used in NameSet.

Definition at line 197 of file nameset.h.

References NameSet::set, and DataSet< DATA >::size().

Referenced by NameSet::add().

Member Data Documentation

◆ factor

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 335 of file nameset.h.

Referenced by NameSet::add().

◆ hashtab

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 164 of file nameset.h.

Referenced by NameSet::add(), NameSet::clear(), NameSet::has(), NameSet::isConsistent(), NameSet::key(), NameSet::memPack(), NameSet::memRemax(), NameSet::number(), NameSet::reMax(), and NameSet::remove().

◆ mem

◆ memFactor

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 343 of file nameset.h.

Referenced by NameSet::add().

◆ memmax

int memmax
private

size of string memory

Definition at line 158 of file nameset.h.

Referenced by NameSet::isConsistent(), NameSet::memMax(), NameSet::memRemax(), and NameSet::NameSet().

◆ memused

int memused
private

size of used string memory

Definition at line 159 of file nameset.h.

Referenced by NameSet::add(), NameSet::clear(), NameSet::isConsistent(), NameSet::memPack(), NameSet::memSize(), and NameSet::NameSet().

◆ set