Container to hold list of Data_Interval; implements nested interval reduction. More...
#include <data_intervaller.hpp>
Public Member Functions | |
| Data_Intervaller (const Data_Intervaller &tin) | |
| Data_Interval< IDXTYPE > * | getFirstBlock (const unsigned int loopdepth=0) |
positions loop loopdepth at the first interval and returns it, or nullptr if there are none | |
| Data_Interval< IDXTYPE > * | getNextBlock (const unsigned int loopdepth=0) |
| bool | check_validity (const IDXTYPE maxidx) |
| checks whether all intervals are non-overlapping, ordered ascending, and all fit to <0,maxidx> (maxidx==0 disables maxidx test) | |
| IDXTYPE | sum () |
| sums the sizes of all contained intervals, i.e. the total number of samples they cover | |
| IDXTYPE | max_idx () |
| returns the largest sample index any interval covers, i.e. the maximum of startidx+count-1 over non-empty intervals (0 if there are none) | |
| void | reduce (const std::shared_ptr< Data_Intervaller< CONTAINER, IDXTYPE > > reducer, std::shared_ptr< Data_Intervaller< CONTAINER, IDXTYPE > > target) |
Translates reducer's RELATIVE index intervals into absolute ones and stores them in target. | |
Private Types | |
| typedef Data_Intervaller< CONTAINER, IDXTYPE >::iterator | TCI |
| this container's iterator type, used to type blockiter and the sum()/max_idx()/reduce() loop variables | |
Private Attributes | |
| std::vector< TCI > | blockiter |
| to enable multiple independent get*Block() loops | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Data_Intervaller< CONTAINER, IDXTYPE > &ia) |
Streams every contained interval as "si:<startidx>, c:<count>" lines to os. | |
Container to hold list of Data_Interval; implements nested interval reduction.
| FST::Data_Intervaller< CONTAINER, IDXTYPE >::Data_Intervaller | ( | const Data_Intervaller< CONTAINER, IDXTYPE > & | tin | ) |
Deep-copies tin's interval list; blockiter (the active get*Block() loop cursors) is deliberately NOT copied – it holds iterators into the source container, so the copy starts with no active block loop (getFirstBlock() (re)initializes it per loopdepth).
| bool FST::Data_Intervaller< CONTAINER, IDXTYPE >::check_validity | ( | const IDXTYPE | maxidx | ) |
checks whether all intervals are non-overlapping, ordered ascending, and all fit to <0,maxidx> (maxidx==0 disables maxidx test)
| Data_Interval< IDXTYPE > * FST::Data_Intervaller< CONTAINER, IDXTYPE >::getNextBlock | ( | const unsigned int | loopdepth = 0 | ) |
advances loop loopdepth (previously started via getFirstBlock() with the same loopdepth) and returns the next interval, or nullptr once exhausted
| void FST::Data_Intervaller< CONTAINER, IDXTYPE >::reduce | ( | const std::shared_ptr< Data_Intervaller< CONTAINER, IDXTYPE > > | reducer, |
| std::shared_ptr< Data_Intervaller< CONTAINER, IDXTYPE > > | target ) |
Translates reducer's RELATIVE index intervals into absolute ones and stores them in target.
The intervals held here select a subset of the data by absolute sample index. reducer selects a further subset of THAT selection, addressing it as if the intervals here were concatenated into one contiguous run: its index 0 is this list's first sample, its index 1 the second, and so on across interval boundaries. reduce() maps every such relative interval back to the absolute indexes it actually denotes, splitting it wherever it straddles a boundary of this list, and appends the results to target.
This is what makes nested splitting work: a splitter at a deeper level enumerates positions within the enclosing level's training part without knowing where in the data that part lies.
| reducer | the relative-index selection to translate; its indexes must all be smaller than sum() |
| target | receives the absolute-index result; CLEARED first, so any previous content is lost |