a simple mapping from one indexing system to another More...
#include <IDIndex.h>
Public Member Functions | |
IDIndex (Int first=0) | |
create an ID set. | |
IDIndex (IDIndex &that) | |
create a copy of another IDIndex | |
~IDIndex () | |
destroy this index | |
void | add (Int id) |
add an ID to the set; | |
Int | operator() (Int id) |
return the ID mapping | |
Int | first () |
return the output index that the first input ID is mapped to. | |
Int | next () |
return the next index to be mapped to when add is next called. | |
Int | size () |
return the number of input IDs mapped | |
void | clear () |
remove all ID mappings. | |
Private Attributes | |
Int | offset |
SimpleOrderedMap< Int, Int > | idmap |
a simple mapping from one indexing system to another
Public interface
This class is puts an index on an ordered list of IDs.
Suppose that you have a list of things accessed via an index (i.e. an integer ID), say spectral windows. Suppose further you want to map them into some other index system, perhaps because you are reordering them. This simple class can keep track of the mapping between the two systems.
The mapping is set up through sequenced calls to the add()
function, to which indices from the "input" system are passed. The order that the indices are passed indicate their order in the output system. One can then map to the output system by passing the input index to the () operator.
One sets the index that the first input index will be mapped to via the constructor, allowing one to map, for example, {1, 3, 2} into {4, 5, 6}.
Suppose only selected windows will be written out. Here's how we can keep track of the mapping:
IDIndex idx(1); // the first index mapped into is 1 for(Int i=0; i < nspect; i++) { if (windowSelected(i)) idx.add(i) // 0 -> 1 if selected } // which output window is the second window mapped to? Int outwin = idx(2); // outwin = -1 if not selected
The MirFiller class needs to keep track of which Miriad windows get mapped into which MS spectral windows. Since the user can select which windows will be loaded, its not easy to predict otherwise how the windows will get mapped. Furthermore, Miriad wideband channels are loaded as seperate windows in the output MS, thus the mapping from channel number to window will not necessarily start with 0.
Definition at line 87 of file IDIndex.h.
IDIndex::IDIndex | ( | Int | first = 0 |
) |
IDIndex::~IDIndex | ( | ) |
destroy this index
void IDIndex::add | ( | Int | id | ) | [inline] |
void IDIndex::clear | ( | ) | [inline] |
remove all ID mappings.
This returns the index to its state just after construction.
Definition at line 122 of file IDIndex.h.
References idmap.
Referenced by MirFreqSetup::clear().
Int IDIndex::first | ( | ) | [inline] |
Int IDIndex::next | ( | void | ) | [inline] |
Int IDIndex::operator() | ( | Int | id | ) | [inline] |
Int IDIndex::size | ( | ) | [inline] |
SimpleOrderedMap<Int, Int> IDIndex::idmap [private] |
Int IDIndex::offset [private] |