A sorted set of BinIDs and values. More...
Classes | |
| struct | Pos |
| position in BinIDValueSet. an iterator. More... | |
Public Member Functions | |
| BinIDValueSet (int nr_vals, bool allow_duplucate_bids) | |
| BinIDValueSet (const BinIDValueSet &) | |
| virtual | ~BinIDValueSet () |
| BinIDValueSet & | operator= (const BinIDValueSet &) |
| void | allowDuplicateBids (bool yn) |
| void | empty () |
| bool | append (const BinIDValueSet &) |
| void | remove (const BinIDValueSet &) |
| void | copyStructureFrom (const BinIDValueSet &) |
| will also empty this set | |
| Pos | findFirst (const BinID &) const |
| bool | next (Pos &, bool skip_duplcate_bids=false) const |
| bool | prev (Pos &, bool skip_duplcate_bids=false) const |
| bool | valid (const BinID &) const |
| void | get (const Pos &, BinID &, float *v=0, int mxnrvals=-1) const |
| BinID | getBinID (const Pos &) const |
| Pos | getPos (od_int64 global_idx) const |
| Slow. And 0 < global_idx < totalNr() is not checked. | |
| Pos | add (const BinID &, const float *vs=0) |
| Either pass sufficient data or pass null. | |
| Pos | add (const BinIDValues &) |
| Wrong-sized will be handled correctly. | |
| void | set (Pos, const float *vs=0) |
| int | nrVals () const |
| int | nrInls () const |
| int | nrCrls (int inl) const |
| bool | isEmpty () const |
| bool | includes (const BinID &b) const |
| int | nrPos (int inlidx) const |
| od_int64 | totalSize () const |
| bool | hasInl (int) const |
| bool | hasCrl (int) const |
| BinID | firstPos () const |
| if empty, returns BinID(0,0) | |
| Interval< int > | inlRange () const |
| Interval< int > | crlRange (int inl=-1) const |
| Interval< float > | valRange (int) const |
| void | remove (const Pos &) |
| afterwards, Pos may be invalid | |
| void | remove (const TypeSet< Pos > &) |
| void | removeVal (int) |
| bool | setNrVals (int, bool kp_data=true) |
| int | nrDuplicateBinIDs () const |
| void | sortDuplicateBids (int value_nr, bool ascending=true) |
| void | removeDuplicateBids () |
| void | randomSubselect (od_int64 maxnr) |
| void | extend (const BinID &stepout, const BinID &stepoutstep) |
| Adds only BinID postions not yet in set. | |
| void | removeRange (int valnr, const Interval< float > &, bool inside=true) |
| void | remove (const HorSampling &hrg, bool inside) |
| Pos | add (const BinIDValue &) |
| Pos | add (const BinID &, float) |
| Pos | add (const BinID &, float, float) |
| Pos | add (const BinID &, const TypeSet< float > &) |
| void | add (const PosInfo::CubeData &) |
| void | get (const Pos &, BinIDValues &) const |
| void | get (const Pos &, BinIDValue &) const |
| void | get (const Pos &, BinID &, float &) const |
| void | get (const Pos &, BinID &, float &, float &) const |
| void | get (const Pos &, BinID &, TypeSet< float > &, int maxnrvals=-1) const |
| max == -1 => all | |
| void | set (const Pos &, float) |
| void | set (const Pos &, float, float) |
| void | set (const Pos &, const TypeSet< float > &) |
| void | getColumn (int valnr, TypeSet< float > &, bool incudf) const |
| void | fillPar (IOPar &, const char *key) const |
| void | usePar (const IOPar &, const char *key) |
| bool | getFrom (std::istream &) |
| bool | putTo (std::ostream &) const |
| bool | areBinidValuesThere (const BinIDValues &) const |
| float * | getVals (const Pos &pos) |
| Direct access to value arrays. No check on valid()! | |
| const float * | getVals (const Pos &pos) const |
| Direct access to value arrays. No check on valid()! | |
| float | getVal (const Pos &pos, int valnr) const |
| < Direct access to value arrays. No check on valid()! | |
| bool | hasDuplicateBinIDs () const |
Protected Member Functions | |
| void | addNew (Pos &, int, const float *) |
| void | sortPart (TypeSet< int > &, TypeSet< float > &, int, int, int, bool) |
| void | removeLine (int idx) |
| int | getInl (const Pos &pos) const |
| int | getCrl (const Pos &pos) const |
| TypeSet< int > & | getCrlSet (const Pos &pos) |
| const TypeSet< int > & | getCrlSet (const Pos &pos) const |
| TypeSet< float > & | getValSet (const Pos &pos) |
| const TypeSet< float > & | getValSet (const Pos &pos) const |
| TypeSet< int > & | getCrlSet (int idx) |
| const TypeSet< int > & | getCrlSet (int idx) const |
| TypeSet< float > & | getValSet (int idx) |
| const TypeSet< float > & | getValSet (int idx) const |
Protected Attributes | |
| const int | nrvals_ |
| TypeSet< int > | inls_ |
| ObjectSet< TypeSet< int > > | crlsets_ |
| ObjectSet< TypeSet< float > > | valsets_ |
| bool | allowdup_ |
A sorted set of BinIDs and values.
The set is sorted on both inline and crossline. This has a cost when creating the set, and it will be slower than a normal TypeSet for small sets. Further, the order in which you add positions will not be preserved.
Luckily there are also advantages. It is *much* faster for searching when the set is large. When you have a block of N inlines x N crosslines, the search time will be O( 2 log2(N) ) instead of O( N^2 / 2 ). Thus for 1000x1000 instead of 500000 you need 20 comparisons (probably a few more but not a lot more).
The iteration through the set should be done using the Pos iterator class. All positioning is already done with Pos, but you can in theory still use
const od_int64 sz = totalSize(); for ( od_int64 idx=0; idx<sz; idx++ ) { BinIDValueSet::Pos pos = bivs.getPos( idx ); // etc. }
but that will be very wasteful.
When you construct a BinIDValueSet, you must provide the number of values (which can be changed later) and whether duplicate BinIDs are allowed. In the set, new uninitialised values will be set to mUdf(float).
if you also want the values sorted (for the same BinID) use sortDuplicateBids().
Note: if one of the values is Z, make it the first value. Not that this is enforced by the set, but it will be assumed sooner or later.
| BinIDValueSet::BinIDValueSet | ( | int | nr_vals, | |
| bool | allow_duplucate_bids | |||
| ) |
| BinIDValueSet::BinIDValueSet | ( | const BinIDValueSet & | ) |
| virtual BinIDValueSet::~BinIDValueSet | ( | ) | [virtual] |
Either pass sufficient data or pass null.
| Pos BinIDValueSet::add | ( | const BinIDValue & | ) |
| void BinIDValueSet::add | ( | const PosInfo::CubeData & | ) |
| Pos BinIDValueSet::add | ( | const BinIDValues & | ) |
Wrong-sized will be handled correctly.
| void BinIDValueSet::addNew | ( | Pos & | , | |
| int | , | |||
| const float * | ||||
| ) | [protected] |
| void BinIDValueSet::allowDuplicateBids | ( | bool | yn | ) | [inline] |
| bool BinIDValueSet::append | ( | const BinIDValueSet & | ) |
| bool BinIDValueSet::areBinidValuesThere | ( | const BinIDValues & | ) | const |
| void BinIDValueSet::copyStructureFrom | ( | const BinIDValueSet & | ) |
will also empty this set
| Interval<int> BinIDValueSet::crlRange | ( | int | inl = -1 |
) | const |
| void BinIDValueSet::empty | ( | ) |
Adds only BinID postions not yet in set.
| void BinIDValueSet::fillPar | ( | IOPar & | , | |
| const char * | key | |||
| ) | const |
not found: j < 0. still, i can be >= 0 , then the inline is present Then, next(pos) will return the first on that inl.
| BinID BinIDValueSet::firstPos | ( | ) | const |
if empty, returns BinID(0,0)
| void BinIDValueSet::get | ( | const Pos & | , | |
| BinIDValues & | ||||
| ) | const |
| void BinIDValueSet::get | ( | const Pos & | , | |
| BinIDValue & | ||||
| ) | const |
max == -1 => all
| void BinIDValueSet::getColumn | ( | int | valnr, | |
| TypeSet< float > & | , | |||
| bool | incudf | |||
| ) | const |
| int BinIDValueSet::getCrl | ( | const Pos & | pos | ) | const [inline, protected] |
| TypeSet<int>& BinIDValueSet::getCrlSet | ( | int | idx | ) | [inline, protected] |
| const TypeSet<int>& BinIDValueSet::getCrlSet | ( | int | idx | ) | const [inline, protected] |
| bool BinIDValueSet::getFrom | ( | std::istream & | ) |
re-structures but keeps allowdup_ considers only 'reasonable' lines to add
| int BinIDValueSet::getInl | ( | const Pos & | pos | ) | const [inline, protected] |
| Pos BinIDValueSet::getPos | ( | od_int64 | global_idx | ) | const |
Slow. And 0 < global_idx < totalNr() is not checked.
| float BinIDValueSet::getVal | ( | const Pos & | pos, | |
| int | valnr | |||
| ) | const [inline] |
< Direct access to value arrays. No check on valid()!
| const float* BinIDValueSet::getVals | ( | const Pos & | pos | ) | const [inline] |
Direct access to value arrays. No check on valid()!
| float* BinIDValueSet::getVals | ( | const Pos & | pos | ) | [inline] |
Direct access to value arrays. No check on valid()!
| const TypeSet<float>& BinIDValueSet::getValSet | ( | int | idx | ) | const [inline, protected] |
| TypeSet<float>& BinIDValueSet::getValSet | ( | int | idx | ) | [inline, protected] |
| bool BinIDValueSet::hasCrl | ( | int | ) | const |
| bool BinIDValueSet::hasDuplicateBinIDs | ( | ) | const |
| bool BinIDValueSet::hasInl | ( | int | ) | const |
| bool BinIDValueSet::includes | ( | const BinID & | b | ) | const [inline] |
| Interval<int> BinIDValueSet::inlRange | ( | ) | const |
| bool BinIDValueSet::isEmpty | ( | ) | const [inline] |
| bool BinIDValueSet::next | ( | Pos & | , | |
| bool | skip_duplcate_bids = false | |||
| ) | const |
| int BinIDValueSet::nrCrls | ( | int | inl | ) | const |
| int BinIDValueSet::nrDuplicateBinIDs | ( | ) | const |
| int BinIDValueSet::nrInls | ( | ) | const [inline] |
| int BinIDValueSet::nrPos | ( | int | inlidx | ) | const |
| int BinIDValueSet::nrVals | ( | ) | const [inline] |
| BinIDValueSet& BinIDValueSet::operator= | ( | const BinIDValueSet & | ) |
| bool BinIDValueSet::prev | ( | Pos & | , | |
| bool | skip_duplcate_bids = false | |||
| ) | const |
| bool BinIDValueSet::putTo | ( | std::ostream & | ) | const |
| void BinIDValueSet::randomSubselect | ( | od_int64 | maxnr | ) |
You cannot remove while iterating Collect the to-be-removed and use this instead
| void BinIDValueSet::remove | ( | const HorSampling & | hrg, | |
| bool | inside | |||
| ) |
| void BinIDValueSet::remove | ( | const BinIDValueSet & | ) |
| void BinIDValueSet::removeDuplicateBids | ( | ) |
| void BinIDValueSet::removeLine | ( | int | idx | ) | [protected] |
| void BinIDValueSet::removeRange | ( | int | valnr, | |
| const Interval< float > & | , | |||
| bool | inside = true | |||
| ) |
Removes vectors with value for column valnr in- or outside interval
| void BinIDValueSet::removeVal | ( | int | ) |
| void BinIDValueSet::set | ( | Pos | , | |
| const float * | vs = 0 | |||
| ) |
null = set to undef no checks on data size (how could there be?) and also not whether Pos is actually in set! in doubt, use valid(Pos) .
| void BinIDValueSet::set | ( | const Pos & | , | |
| float | , | |||
| float | ||||
| ) |
| void BinIDValueSet::set | ( | const Pos & | , | |
| float | ||||
| ) |
| bool BinIDValueSet::setNrVals | ( | int | , | |
| bool | kp_data = true | |||
| ) |
| void BinIDValueSet::sortDuplicateBids | ( | int | value_nr, | |
| bool | ascending = true | |||
| ) |
| void BinIDValueSet::sortPart | ( | TypeSet< int > & | , | |
| TypeSet< float > & | , | |||
| int | , | |||
| int | , | |||
| int | , | |||
| bool | ||||
| ) | [protected] |
| od_int64 BinIDValueSet::totalSize | ( | ) | const |
| void BinIDValueSet::usePar | ( | const IOPar & | , | |
| const char * | key | |||
| ) |
| bool BinIDValueSet::valid | ( | const BinID & | ) | const |
| Interval<float> BinIDValueSet::valRange | ( | int | ) | const |
bool BinIDValueSet::allowdup_ [protected] |
ObjectSet< TypeSet<int> > BinIDValueSet::crlsets_ [protected] |
TypeSet<int> BinIDValueSet::inls_ [protected] |
const int BinIDValueSet::nrvals_ [protected] |
ObjectSet< TypeSet<float> > BinIDValueSet::valsets_ [protected] |
1.7.1