dlvhex  2.5.0
OrderedSet< T, H > Class Template Reference

Implementation of an ordered set based on boost::unordered_map. More...

#include <include/dlvhex2/Set.h>

Inheritance diagram for OrderedSet< T, H >:
Collaboration diagram for OrderedSet< T, H >:

Public Member Functions

 OrderedSet ()
 Constructor.
void insert (T el)
 Inserts a new element.
void erase (T el)
 Removes an element.
long getInsertionIndex (T el)
 Get the insertion index of an element.
int compare (T el1, T el2)
 Compares two elements according to their insertion index.
void resize (int s)
 No operation; kept for backwards compatibility.

Private Member Functions

void renumber ()
 Renumbers the elements but keeps their order; useful after elements have been deleted.

Private Attributes

DynamicVector< T, long > os
 Internal sorage.
long c
 Next element to insert.

Detailed Description

template<typename T, typename H>
class OrderedSet< T, H >

Implementation of an ordered set based on boost::unordered_map.

Definition at line 567 of file Set.h.


Constructor & Destructor Documentation

template<typename T, typename H>
OrderedSet< T, H >::OrderedSet ( ) [inline]

Constructor.

Definition at line 597 of file Set.h.


Member Function Documentation

template<typename T, typename H>
int OrderedSet< T, H >::compare ( el1,
el2 
) [inline]

Compares two elements according to their insertion index.

Parameters:
el1First element to be compared.
el2Second element to be compared.
Returns:
-1 if el1 was inserted before el2, 1 if el1 was inserted after el2, 0 otherwise.

Definition at line 629 of file Set.h.

template<typename T, typename H>
void OrderedSet< T, H >::erase ( el) [inline]

Removes an element.

Parameters:
elElement to remove.

Definition at line 611 of file Set.h.

Referenced by CDNLSolver::clearFact().

template<typename T, typename H>
long OrderedSet< T, H >::getInsertionIndex ( el) [inline]

Get the insertion index of an element.

The larger the insertion index, the later the element was added.

Parameters:
elElement whose insertion index shall be retrieved.
Returns:
Insertion index of el.

Definition at line 620 of file Set.h.

Referenced by OrderedSet< IDAddress, SimpleHashIDAddress >::compare(), and CDNLSolver::getAssignmentOrderIndex().

template<typename T, typename H>
void OrderedSet< T, H >::insert ( el) [inline]

Inserts a new element.

Parameters:
elElement to insert.

Definition at line 602 of file Set.h.

Referenced by CDNLSolver::setFact().

template<typename T, typename H>
void OrderedSet< T, H >::renumber ( ) [inline, private]

Renumbers the elements but keeps their order; useful after elements have been deleted.

Definition at line 576 of file Set.h.

Referenced by OrderedSet< IDAddress, SimpleHashIDAddress >::insert().

template<typename T, typename H>
void OrderedSet< T, H >::resize ( int  s) [inline]

No operation; kept for backwards compatibility.

Definition at line 636 of file Set.h.

Referenced by CDNLSolver::resizeVectors().


Field Documentation

template<typename T, typename H>
long OrderedSet< T, H >::c [private]

The documentation for this class was generated from the following file: