ROSE  0.9.10.103
Public Types | Public Member Functions | List of all members
Sawyer::Container::MergePolicy< I, T > Class Template Reference

Description

template<typename I, typename T>
class Sawyer::Container::MergePolicy< I, T >

Policy indicating how values are merged and split.

Adjacent nodes of an IntervalMap can be joined together provided their values can also be joined together. This joining is a key feature of an IntervalMap since it can significantly reduce the number nodes required in the underlying map.

Definition at line 43 of file IntervalMap.h.

#include <IntervalMap.h>

Inheritance diagram for Sawyer::Container::MergePolicy< I, T >:
Inheritance graph
[legend]

Public Types

typedef I Interval
 
typedef T Value
 

Public Member Functions

bool merge (const Interval &leftInterval, Value &leftValue, const Interval &rightInterval, Value &rightValue)
 Merge two values if possible. More...
 
Value split (const Interval &interval, Value &value, const typename Interval::Value &splitPoint)
 Split one value into two values. More...
 
void truncate (const Interval &interval, Value &value, const typename Interval::Value &splitPoint)
 Discard the right part of a value. More...
 

Member Function Documentation

template<typename I, typename T>
bool Sawyer::Container::MergePolicy< I, T >::merge ( const Interval &  leftInterval,
Value &  leftValue,
const Interval &  rightInterval,
Value &  rightValue 
)
inline

Merge two values if possible.

The rightValue is merged into the leftValue if possible, or this method returns false without changing either value. After a successful merge, the rightValue will be removed from the IntervalMap and its destructor called.

Definition at line 61 of file IntervalMap.h.

template<typename I, typename T>
Value Sawyer::Container::MergePolicy< I, T >::split ( const Interval &  interval,
Value &  value,
const typename Interval::Value &  splitPoint 
)
inline

Split one value into two values.

The IntervalMap calls this method when the interval is being split into two smaller, adjacent intervals. The splitPoint argument is the split point and becomes the least value of the right interval. The value argument is modified in place to become the left value, and the right value is returned. This method is only invoked when the result would be two non-empty intervals.

Definition at line 73 of file IntervalMap.h.

template<typename I, typename T>
void Sawyer::Container::MergePolicy< I, T >::truncate ( const Interval &  interval,
Value &  value,
const typename Interval::Value &  splitPoint 
)
inline

Discard the right part of a value.

This method is the same as split except the right part of the resulting value is discarded. This is sometimes more efficient than calling split and then destroying the return value.

Definition at line 83 of file IntervalMap.h.


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