Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
SegmentBuilder< K, T, C > Class Template Reference

#include <elm/stree/SegmentBuilder.h>

+ Inheritance diagram for SegmentBuilder< K, T, C >:

Public Member Functions

 SegmentBuilder (const T &def)
 
void add (const K &low, const K &high, const T &val)
 
void make (stree::Tree< K, T, C > &tree)
 

Additional Inherited Members

- Protected Types inherited from Builder< K, T, Comparator< K > >
typedef Tree< K, T, Comparator< K > >::node_t node_t
 
- Protected Member Functions inherited from Builder< K, T, Comparator< K > >
node_tallocate (t::uint32 n)
 
int make (node_t *nodes, int &s, int start, int end)
 

Detailed Description

template<class K, class T, class C = Comparator<K>>
class elm::stree::SegmentBuilder< K, T, C >

Builder for elm::stree::Tree based on a list of disjointed segments.

Warning
Unexpected results may occur if the segments are not disjointed.
Parameters
KKey type.
TRetrieven item type.
CComparator to compare keys (default to Comparator<K>).

Constructor & Destructor Documentation

◆ SegmentBuilder()

SegmentBuilder ( const T &  def)
inline

Member Function Documentation

◆ add()

void add ( const K &  low,
const K &  high,
const T &  val 
)
inline

SegmentBuilder::SegmentBuilder(const T& def); Build a segment builder with a default value: the value returned when a look-up select an area out of segments.

Parameters
defDefault value.

Add a segment for a range of keys between low (inclusive) and high (exclusive).

Parameters
lowLow value of the segment (inclusive).
highHigh value of the segment (exclusive).
valValue associated with the segment.

References elm::pair(), and Map< K, T, C, E, A >::put().

◆ make()

void make ( stree::Tree< K, T, C > &  tree)
inline

Build the segmented tree from the segments and values.

Parameters
treeTree to initialize.

References Builder< K, T, C >::allocate(), Tree< K, T, C >::node_t::data, elm::iter(), Builder< K, T, C >::make(), elm::io::p(), and Tree< K, T, C >::set().


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