ROSE 0.11.145.147
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 40 of file IntervalMap.h.

#include <Sawyer/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.
 
Value split (const Interval &interval, Value &value, const typename Interval::Value &splitPoint)
 Split one value into two values.
 
void truncate (const Interval &interval, Value &value, const typename Interval::Value &splitPoint)
 Discard the right part of a value.
 

Member Typedef Documentation

◆ Interval

template<typename I , typename T >
typedef I Sawyer::Container::MergePolicy< I, T >::Interval

Definition at line 42 of file IntervalMap.h.

◆ Value

template<typename I , typename T >
typedef T Sawyer::Container::MergePolicy< I, T >::Value

Definition at line 43 of file IntervalMap.h.

Member Function Documentation

◆ merge()

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

◆ split()

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 82 of file IntervalMap.h.

◆ truncate()

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 92 of file IntervalMap.h.


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