ABA_NONDUPLPOOL< BaseType, CoType > Class Template Reference

class ABA_NONDUPLPOOL provides an ABA_STANDARDPOOL with the additional feature that the same constraint is at most stored once in the pool. For constraints and variables inserted in this pool the virtual member functions name(), hashKey(), and equal() of the base class ABA_CONVAR have to be defined More...

#include <nonduplpool.h>

Inheritance diagram for ABA_NONDUPLPOOL< BaseType, CoType >:

ABA_STANDARDPOOL< BaseType, CoType > ABA_POOL< BaseType, CoType > ABA_ABACUSROOT List of all members.

Public Member Functions

 ABA_NONDUPLPOOL (ABA_MASTER *master, int size, bool autoRealloc=false)
virtual ~ABA_NONDUPLPOOL ()
 The destructor.
virtual ABA_POOLSLOT< BaseType,
CoType > * 
insert (BaseType *cv)
 Before the function insert() tries to insert a constraint/variable in the pool, it checks if the constraint/variable is already contained in the pool. If the constraint/variable cv is contained in the pool, it is deleted.
virtual ABA_POOLSLOT< BaseType,
CoType > * 
present (BaseType *cv)
virtual void increase (int size)
void statistics (int &nDuplications, int &nCollisions) const
 Determines the number of constraints that have not been inserted into the pool, because an equivalent was already present.

Private Member Functions

virtual int softDeleteConVar (ABA_POOLSLOT< BaseType, CoType > *slot)
 Has to be redefined because the slot has to be removed from the hash table if the constraint/variable can be deleted.
virtual void hardDeleteConVar (ABA_POOLSLOT< BaseType, CoType > *slot)
 ABA_NONDUPLPOOL (const ABA_NONDUPLPOOL &rhs)
const ABA_NONDUPLPOOLoperator= (const ABA_NONDUPLPOOL &rhs)

Private Attributes

ABA_HASH< unsigned, ABA_POOLSLOT<
BaseType, CoType > * > 
hash_
int nDuplications_

Detailed Description

template<class BaseType, class CoType>
class ABA_NONDUPLPOOL< BaseType, CoType >

class ABA_NONDUPLPOOL provides an ABA_STANDARDPOOL with the additional feature that the same constraint is at most stored once in the pool. For constraints and variables inserted in this pool the virtual member functions name(), hashKey(), and equal() of the base class ABA_CONVAR have to be defined

Parameters:
hash_ A hash table for a fast access to the pool slot storing a constraint/variable.
nDuplications_ The number of insertions of constraints/variables that were rejected since the constraint/variable is stored already in the pool.

Definition at line 52 of file nonduplpool.h.


Constructor & Destructor Documentation

template<class BaseType, class CoType>
ABA_NONDUPLPOOL< BaseType, CoType >::ABA_NONDUPLPOOL ( ABA_MASTER master,
int  size,
bool  autoRealloc = false 
)

The constructor for an empty pool.

Parameters:
master A pointer to the corresponding master of the optimization.
size The maximal number of items which can be inserted in the pool without reallocation.
autoRealloc If this argument is true an automatic reallocation is performed if the pool is full.

template<class BaseType, class CoType>
virtual ABA_NONDUPLPOOL< BaseType, CoType >::~ABA_NONDUPLPOOL (  )  [virtual]

The destructor.

template<class BaseType, class CoType>
ABA_NONDUPLPOOL< BaseType, CoType >::ABA_NONDUPLPOOL ( const ABA_NONDUPLPOOL< BaseType, CoType > &  rhs  )  [private]


Member Function Documentation

template<class BaseType, class CoType>
virtual ABA_POOLSLOT<BaseType, CoType>* ABA_NONDUPLPOOL< BaseType, CoType >::insert ( BaseType *  cv  )  [virtual]

Before the function insert() tries to insert a constraint/variable in the pool, it checks if the constraint/variable is already contained in the pool. If the constraint/variable cv is contained in the pool, it is deleted.

Returns:
A pointer to the pool slot where the item has been inserted, or a pointer to the pool slot if the item is already contained in the pool, or 0 if the insertion failed.
Parameters:
cv The constraint/variable being inserted.

Reimplemented from ABA_STANDARDPOOL< BaseType, CoType >.

template<class BaseType, class CoType>
virtual ABA_POOLSLOT<BaseType, CoType>* ABA_NONDUPLPOOL< BaseType, CoType >::present ( BaseType *  cv  )  [virtual]

Checks if a constraint/variables is already contained in the pool.

Returns:
A pointer to the pool slot storing a constraint/variable that is equivalent to cv according to the function ABA_CONVAR::equal(). If there is no such constraint/variable 0 is returned.
Parameters:
cv A pointer to a constraint/variable for which it should be checked if an equivalent item is already contained in the pool.

template<class BaseType, class CoType>
virtual void ABA_NONDUPLPOOL< BaseType, CoType >::increase ( int  size  )  [virtual]

Enlarges the pool to store.

To avoid fatal errors we do not allow decreasing the size of the pool. This function redefines the virtual function of the base class ABA_STANDARDPOOL because we have to reallocate the hash table.

Parameters:
size The new size of the pool.

Reimplemented from ABA_STANDARDPOOL< BaseType, CoType >.

template<class BaseType, class CoType>
void ABA_NONDUPLPOOL< BaseType, CoType >::statistics ( int &  nDuplications,
int &  nCollisions 
) const

Determines the number of constraints that have not been inserted into the pool, because an equivalent was already present.

Also the number of collisions in the hash table is computed. If this number is high, it might indicate that your hash function is not chosen very well.

Parameters:
nDuplications The number of constraints that have not been inserted into the pool because an equivalent one was already present.
nCollisions The number of collisions in the hash table.

template<class BaseType, class CoType>
virtual int ABA_NONDUPLPOOL< BaseType, CoType >::softDeleteConVar ( ABA_POOLSLOT< BaseType, CoType > *  slot  )  [private, virtual]

Has to be redefined because the slot has to be removed from the hash table if the constraint/variable can be deleted.

Returns:
0 If the constraint/variable could be deleted.

1 otherwise.

Parameters:
slot A pointer to the pool slot from wich the constraint/variable should be deleted.

Reimplemented from ABA_POOL< BaseType, CoType >.

template<class BaseType, class CoType>
virtual void ABA_NONDUPLPOOL< BaseType, CoType >::hardDeleteConVar ( ABA_POOLSLOT< BaseType, CoType > *  slot  )  [private, virtual]

Has to be redefined because the pool slot has to be removed from the hash table.

Parameters:
slot A pointer to the pool slot from wich the constraint/variable should be deleted.

Reimplemented from ABA_POOL< BaseType, CoType >.

template<class BaseType, class CoType>
const ABA_NONDUPLPOOL& ABA_NONDUPLPOOL< BaseType, CoType >::operator= ( const ABA_NONDUPLPOOL< BaseType, CoType > &  rhs  )  [private]


Member Data Documentation

template<class BaseType, class CoType>
ABA_HASH<unsigned, ABA_POOLSLOT<BaseType, CoType>*> ABA_NONDUPLPOOL< BaseType, CoType >::hash_ [private]

Definition at line 142 of file nonduplpool.h.

template<class BaseType, class CoType>
int ABA_NONDUPLPOOL< BaseType, CoType >::nDuplications_ [private]

Definition at line 143 of file nonduplpool.h.


The documentation for this class was generated from the following file:
Generated on Tue Aug 14 18:09:58 2007 for ABACUS by  doxygen 1.5.1