decompiler  1.0.0
Public Types | Public Member Functions | Private Attributes | List of all members
partmap< _linetype, _valuetype > Class Template Reference

A map from a linear space to value objects. More...

#include <partmap.hh>

Public Types

typedef std::map< _linetype, _valuetype > maptype
 Defining the map from split points to value objects.
 
typedef maptype::iterator iterator
 A partmap iterator is an iterator into the map.
 
typedef maptype::const_iterator const_iterator
 A constant iterator.
 

Public Member Functions

_valuetype & getValue (const _linetype &pnt)
 Get the value object at a point. More...
 
const _valuetype & getValue (const _linetype &pnt) const
 Get the value object at a point. More...
 
const _valuetype & bounds (const _linetype &pnt, _linetype &before, _linetype &after, int &valid) const
 Get the value object for a given point and return the range over which the value object applies. More...
 
_valuetype & split (const _linetype &pnt)
 Introduce a new split point. More...
 
const _valuetype & defaultValue (void) const
 Get the default value object.
 
_valuetype & defaultValue (void)
 Get the default value object.
 
_valuetype & clearRange (const _linetype &pnt1, const _linetype &pnt2)
 Clear a range of split points. More...
 
const_iterator begin (void) const
 Beginning of split points.
 
const_iterator end (void) const
 End of split points.
 
iterator begin (void)
 Beginning of split points.
 
iterator end (void)
 End of split points.
 
const_iterator begin (const _linetype &pnt) const
 Get first split point after given point.
 
iterator begin (const _linetype &pnt)
 Get first split point after given point.
 
void clear (void)
 Clear all split points.
 
bool empty (void) const
 Return true if there are no split points.
 

Private Attributes

maptype database
 Map from linear split points to the value objects.
 
_valuetype defaultvalue
 The value object before the first split point.
 

Detailed Description

template<typename _linetype, typename _valuetype>
class partmap< _linetype, _valuetype >

A map from a linear space to value objects.

The partmap is a template class taking:

Let R be the linear space with an ordering, and let { a_i } be a finite set of points in R. The a_i partition R into a finite number of disjoint sets { x : x < a_0 }, { x : x>=a_0 && x < a_1 }, ... { x : x>=a_i && x < a_i+1 }, ... { x : x>=a_n }

A partmap maps elements of this partition to _valuetype objects A _valuetype is then associated with any element x in R by looking up the value associated with the partition element containing x.

The map is defined by starting with a default value object that applies to the whole linear space. Then split points are introduced, one at a time, in the linear space. At each split point, the associated value object is split into two objects. At any point the value object describing some part of the linear space can be changed.

Member Function Documentation

template<typename _linetype, typename _valuetype >
const _valuetype & partmap< _linetype, _valuetype >::bounds ( const _linetype &  pnt,
_linetype &  before,
_linetype &  after,
int &  valid 
) const

Get the value object for a given point and return the range over which the value object applies.

Pass back a before and after point defining the maximal range over which the value applies. An additional validity code is passed back describing which of the bounding points apply:

  • 0 if both bounds apply
  • 1 if there is no lower bound
  • 2 if there is no upper bound,
  • 3 if there is neither a lower or upper bound
    Parameters
    pntis the given point around which to compute the range
    beforeis a reference to the passed back lower bound
    afteris a reference to the passed back upper bound
    validis a reference to the passed back validity code
    Returns
    the corresponding value object

References partmap< _linetype, _valuetype >::begin(), partmap< _linetype, _valuetype >::database, partmap< _linetype, _valuetype >::defaultvalue, partmap< _linetype, _valuetype >::defaultValue(), partmap< _linetype, _valuetype >::end(), partmap< _linetype, _valuetype >::getValue(), and partmap< _linetype, _valuetype >::split().

Referenced by partmap< _linetype, _valuetype >::clearRange().

template<typename _linetype, typename _valuetype >
_valuetype & partmap< _linetype, _valuetype >::clearRange ( const _linetype &  pnt1,
const _linetype &  pnt2 
)

Clear a range of split points.

Split points are introduced at the two boundary points of the given range, and all split points in between are removed. The value object that was initially present at the left-most boundary point becomes the value (as a copy) for the whole range.

Parameters
pnt1is the left-most boundary point of the range
pnt2is the right-most boundary point
Returns
the value object assigned to the range

References partmap< _linetype, _valuetype >::begin(), partmap< _linetype, _valuetype >::bounds(), partmap< _linetype, _valuetype >::database, partmap< _linetype, _valuetype >::end(), and partmap< _linetype, _valuetype >::split().

Referenced by partmap< Address, TrackedSet >::defaultValue(), and partmap< _linetype, _valuetype >::split().

template<typename _linetype, typename _valuetype >
_valuetype & partmap< _linetype, _valuetype >::getValue ( const _linetype &  pnt)

Get the value object at a point.

Look up the first split point coming before the given point and return the value object it maps to. If there is no earlier split point return the default value.

Parameters
pntis the given point in the linear space
Returns
the corresponding value object

References partmap< _linetype, _valuetype >::database, and partmap< _linetype, _valuetype >::defaultvalue.

Referenced by partmap< _linetype, _valuetype >::bounds(), partmap< Address, TrackedSet >::empty(), ContextInternal::getContext(), Database::getProperty(), and ContextInternal::getTrackedSet().

template<typename _linetype, typename _valuetype >
const _valuetype & partmap< _linetype, _valuetype >::getValue ( const _linetype &  pnt) const

Get the value object at a point.

Look up the first split point coming before the given point and return the value object it maps to. If there is no earlier split point return the default value.

Parameters
pntis the given point in the linear space
Returns
the corresponding value object

References partmap< _linetype, _valuetype >::database, and partmap< _linetype, _valuetype >::defaultvalue.

template<typename _linetype, typename _valuetype >
_valuetype & partmap< _linetype, _valuetype >::split ( const _linetype &  pnt)

Introduce a new split point.

Add (if not already present) a point to the linear partition.

Parameters
pntis the (new) point
Returns
the (possibly) new value object for the range starting at the point

References partmap< _linetype, _valuetype >::clearRange(), partmap< _linetype, _valuetype >::database, and partmap< _linetype, _valuetype >::defaultvalue.

Referenced by partmap< _linetype, _valuetype >::bounds(), and partmap< _linetype, _valuetype >::clearRange().


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