OpendTect-6_4  6.4
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Pos::IdxPairDataSet Class Reference

A sorted set of IdxPairs and associated data buffer. More...

Classes

class  ObjData
 
struct  SPos
 Set Position: position in IdxPairDataSet. More...
 

Public Types

typedef IdxPair::IdxType IdxType
 
typedef TypeSet< IdxType >::size_type ArrIdxType
 
typedef od_int64 ObjSzType
 
typedef od_int64 GlobIdxType
 

Public Member Functions

 IdxPairDataSet (ObjSzType, bool allow_duplicate_idxs, bool manage_data=true)
 
 IdxPairDataSet (const IdxPairDataSet &)
 
virtual ~IdxPairDataSet ()
 
IdxPairDataSetoperator= (const IdxPairDataSet &)
 
bool isEmpty () const
 
void setEmpty ()
 
void copyStructureFrom (const IdxPairDataSet &)
 will also empty this set More...
 
ObjSzType objSize () const
 
bool managesData () const
 
bool allowsDuplicateIdxPairs () const
 
void allowDuplicateIdxPairs (bool)
 
bool append (const IdxPairDataSet &)
 
void remove (const IdxPairDataSet &)
 
void remove (const TrcKeySampling &hrg, bool inside)
 
void remove (SPos)
 afterwards, input SPos may be invalid More...
 
void remove (const TypeSet< SPos > &)
 
SPos find (const IdxPair &ip) const
 
SPos findFirst (const IdxPair &ip) const
 
SPos findOccurrence (const IdxPair &, int occ=0) const
 
bool next (SPos &, bool skip_duplicate_idxpairs=false) const
 
bool prev (SPos &, bool skip_duplicate_idxpairs=false) const
 
bool isValid (const IdxPair &) const
 
IdxPair getIdxPair (SPos) const
 
const void * getObj (SPos) const
 
const void * get (SPos, IdxPair &) const
 
SPos getPos (GlobIdxType) const
 Very slow. More...
 
SPos add (const IdxPair &, const void *obj=0)
 If returned SPos is not valid memory was full. More...
 
void set (SPos, const void *obj=0)
 
void set (const IdxPair &ip, const void *obj=0)
 May do the wrong thing if you have duplicates. More...
 
SPos update (const IdxPair &, const void *obj=0)
 
ArrIdxType nrFirst () const
 
ArrIdxType nrSecond (IdxType firstidx) const
 
bool includes (const IdxPair &ip) const
 
bool hasFirst (IdxType) const
 
bool hasSecond (IdxType) const
 
IdxPair firstIdxPair () const
 when empty returns udf() More...
 
GlobIdxType totalSize () const
 
Interval< IdxTypefirstRange () const
 
Interval< IdxTypesecondRange (IdxType firsidx=-1) const
 
bool hasDuplicateIdxPairs () const
 
ArrIdxType nrDuplicateIdxPairs () const
 
void removeDuplicateIdxPairs ()
 
ArrIdxType nrPos (ArrIdxType lineidx) const
 
void extend (const IdxPairDelta &stepout, const IdxPairStep &, EntryCreatedFn fn=0)
 Adds only IdxPair postions not yet in set. More...
 
void add (const PosInfo::CubeData &, EntryCreatedFn fn=0)
 Adds only IdxPair postions not yet in set. More...
 
void randomSubselect (GlobIdxType maxsz)
 
bool dump (od_ostream &, bool binary) const
 
bool slurp (od_istream &, bool binary)
 
ArrIdxType nrInls () const
 
ArrIdxType nrCrls (IdxType inl) const
 
ArrIdxType nrRows () const
 
ArrIdxType nrCols (IdxType row) const
 
bool hasInl (IdxType inl) const
 
bool hasCrl (IdxType crl) const
 
bool hasRow (IdxType row) const
 
bool hasCol (IdxType col) const
 
Interval< IdxTypeinlRange () const
 
Interval< IdxTyperowRange () const
 
Interval< IdxTypecrlRange (IdxType inl=-1) const
 
Interval< IdxTypecolRange (IdxType row=-1) const
 
bool setObjSize (ObjSzType sz, ObjSzType offs_in_objs=-1, const void *initwith=0)
 
void decrObjSize (ObjSzType, ObjSzType offs=-1)
 
bool incrObjSize (ObjSzType, ObjSzType offs=-1, const void *=0)
 

Protected Types

typedef TypeSet< IdxTypeIdxSet
 
typedef od_int64 BufSzType
 

Protected Member Functions

const void * gtObj (const SPos &) const
 
bool addObj (SPos &, IdxType, const void *)
 
void putObj (const SPos &, const void *)
 
void addEntry (const Pos::IdxPair &, const void *, SPos &)
 
IdxType gtFrst (const SPos &pos) const
 
IdxType gtScnd (const SPos &pos) const
 
IdxPair gtIdxPair (const SPos &pos) const
 
IdxSetgtScndSet (const SPos &pos)
 
const IdxSetgtScndSet (const SPos &pos) const
 
ObjDatagtObjData (const SPos &pos)
 
const ObjDatagtObjData (const SPos &pos) const
 
IdxSetgtScndSet (ArrIdxType idx)
 
const IdxSetgtScndSet (ArrIdxType idx) const
 
ObjDatagtObjData (ArrIdxType idx)
 
const ObjDatagtObjData (ArrIdxType idx) const
 

Static Protected Member Functions

static ArrIdxType findIndexFor (const IdxSet &, IdxType, bool *found=0)
 

Protected Attributes

const ObjSzType objsz_
 
const bool mandata_
 
bool allowdup_
 
IdxSet frsts_
 
ObjectSet< IdxSetscndsets_
 
ObjectSet< ObjDataobjdatas_
 

Detailed Description

A sorted set of IdxPairs and associated data buffer.

The set is sorted on both first and second key (inl()/row()/lineNr() and crl()/col()/traceNr()). 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 rows x N columns, 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 SPos iterator class. All positioning is already done with SPos, but you can in theory still use

const od_int64 sz = totalSize();
for ( od_int64 idx=0; idx<sz; idx++ )
{
Pos::IdxPairDataSet::SPos pos = set.getPos( idx );
// etc.
}

but that will be very inefficient.

Note that you can use null pointers to add or set 'empty' slots. Note also: ObjSz is od_int64. Keep it like that as it ensures good index arithmetic for the buffers.

Member Typedef Documentation

Constructor & Destructor Documentation

Pos::IdxPairDataSet::IdxPairDataSet ( ObjSzType  ,
bool  allow_duplicate_idxs,
bool  manage_data = true 
)
Pos::IdxPairDataSet::IdxPairDataSet ( const IdxPairDataSet )
virtual Pos::IdxPairDataSet::~IdxPairDataSet ( )
virtual

Member Function Documentation

SPos Pos::IdxPairDataSet::add ( const IdxPair ,
const void *  obj = 0 
)

If returned SPos is not valid memory was full.

void Pos::IdxPairDataSet::add ( const PosInfo::CubeData ,
EntryCreatedFn  fn = 0 
)

Adds only IdxPair postions not yet in set.

void Pos::IdxPairDataSet::addEntry ( const Pos::IdxPair ,
const void *  ,
SPos  
)
protected
bool Pos::IdxPairDataSet::addObj ( SPos ,
IdxType  ,
const void *   
)
protected
void Pos::IdxPairDataSet::allowDuplicateIdxPairs ( bool  )
bool Pos::IdxPairDataSet::allowsDuplicateIdxPairs ( ) const
inline
bool Pos::IdxPairDataSet::append ( const IdxPairDataSet )
Interval<IdxType> Pos::IdxPairDataSet::colRange ( IdxType  row = -1) const
inline
void Pos::IdxPairDataSet::copyStructureFrom ( const IdxPairDataSet )

will also empty this set

Interval<IdxType> Pos::IdxPairDataSet::crlRange ( IdxType  inl = -1) const
inline
void Pos::IdxPairDataSet::decrObjSize ( ObjSzType  ,
ObjSzType  offs = -1 
)
bool Pos::IdxPairDataSet::dump ( od_ostream ,
bool  binary 
) const
void Pos::IdxPairDataSet::extend ( const IdxPairDelta stepout,
const IdxPairStep ,
EntryCreatedFn  fn = 0 
)

Adds only IdxPair postions not yet in set.

SPos Pos::IdxPairDataSet::find ( const IdxPair ip) const
inline
SPos Pos::IdxPairDataSet::findFirst ( const IdxPair ip) const
inline
static ArrIdxType Pos::IdxPairDataSet::findIndexFor ( const IdxSet ,
IdxType  ,
bool *  found = 0 
)
staticprotected
SPos Pos::IdxPairDataSet::findOccurrence ( const IdxPair ,
int  occ = 0 
) const
IdxPair Pos::IdxPairDataSet::firstIdxPair ( ) const

when empty returns udf()

Interval<IdxType> Pos::IdxPairDataSet::firstRange ( ) const
const void* Pos::IdxPairDataSet::get ( SPos  ,
IdxPair  
) const
IdxPair Pos::IdxPairDataSet::getIdxPair ( SPos  ) const
const void* Pos::IdxPairDataSet::getObj ( SPos  ) const
SPos Pos::IdxPairDataSet::getPos ( GlobIdxType  ) const

Very slow.

IdxType Pos::IdxPairDataSet::gtFrst ( const SPos pos) const
inlineprotected
IdxPair Pos::IdxPairDataSet::gtIdxPair ( const SPos pos) const
inlineprotected
const void* Pos::IdxPairDataSet::gtObj ( const SPos ) const
protected
ObjData& Pos::IdxPairDataSet::gtObjData ( const SPos pos)
inlineprotected
const ObjData& Pos::IdxPairDataSet::gtObjData ( const SPos pos) const
inlineprotected
ObjData& Pos::IdxPairDataSet::gtObjData ( ArrIdxType  idx)
inlineprotected
const ObjData& Pos::IdxPairDataSet::gtObjData ( ArrIdxType  idx) const
inlineprotected
IdxType Pos::IdxPairDataSet::gtScnd ( const SPos pos) const
inlineprotected
IdxSet& Pos::IdxPairDataSet::gtScndSet ( const SPos pos)
inlineprotected
const IdxSet& Pos::IdxPairDataSet::gtScndSet ( const SPos pos) const
inlineprotected
IdxSet& Pos::IdxPairDataSet::gtScndSet ( ArrIdxType  idx)
inlineprotected
const IdxSet& Pos::IdxPairDataSet::gtScndSet ( ArrIdxType  idx) const
inlineprotected
bool Pos::IdxPairDataSet::hasCol ( IdxType  col) const
inline
bool Pos::IdxPairDataSet::hasCrl ( IdxType  crl) const
inline
bool Pos::IdxPairDataSet::hasDuplicateIdxPairs ( ) const
bool Pos::IdxPairDataSet::hasFirst ( IdxType  ) const
bool Pos::IdxPairDataSet::hasInl ( IdxType  inl) const
inline
bool Pos::IdxPairDataSet::hasRow ( IdxType  row) const
inline
bool Pos::IdxPairDataSet::hasSecond ( IdxType  ) const
bool Pos::IdxPairDataSet::includes ( const IdxPair ip) const
inline
bool Pos::IdxPairDataSet::incrObjSize ( ObjSzType  ,
ObjSzType  offs = -1,
const void *  = 0 
)
Interval<IdxType> Pos::IdxPairDataSet::inlRange ( ) const
inline
bool Pos::IdxPairDataSet::isEmpty ( ) const
inline
bool Pos::IdxPairDataSet::isValid ( const IdxPair ) const
bool Pos::IdxPairDataSet::managesData ( ) const
inline
bool Pos::IdxPairDataSet::next ( SPos ,
bool  skip_duplicate_idxpairs = false 
) const
ArrIdxType Pos::IdxPairDataSet::nrCols ( IdxType  row) const
inline
ArrIdxType Pos::IdxPairDataSet::nrCrls ( IdxType  inl) const
inline
ArrIdxType Pos::IdxPairDataSet::nrDuplicateIdxPairs ( ) const
ArrIdxType Pos::IdxPairDataSet::nrFirst ( ) const
inline
ArrIdxType Pos::IdxPairDataSet::nrInls ( ) const
inline
ArrIdxType Pos::IdxPairDataSet::nrPos ( ArrIdxType  lineidx) const
ArrIdxType Pos::IdxPairDataSet::nrRows ( ) const
inline
ArrIdxType Pos::IdxPairDataSet::nrSecond ( IdxType  firstidx) const
ObjSzType Pos::IdxPairDataSet::objSize ( ) const
inline
IdxPairDataSet& Pos::IdxPairDataSet::operator= ( const IdxPairDataSet )
bool Pos::IdxPairDataSet::prev ( SPos ,
bool  skip_duplicate_idxpairs = false 
) const
void Pos::IdxPairDataSet::putObj ( const SPos ,
const void *   
)
protected
void Pos::IdxPairDataSet::randomSubselect ( GlobIdxType  maxsz)
void Pos::IdxPairDataSet::remove ( const IdxPairDataSet )
void Pos::IdxPairDataSet::remove ( const TrcKeySampling hrg,
bool  inside 
)
void Pos::IdxPairDataSet::remove ( SPos  )

afterwards, input SPos may be invalid

void Pos::IdxPairDataSet::remove ( const TypeSet< SPos > &  )

You cannot remove while iterating, so ... collect the to-be-removed and use this instead

void Pos::IdxPairDataSet::removeDuplicateIdxPairs ( )
Interval<IdxType> Pos::IdxPairDataSet::rowRange ( ) const
inline
Interval<IdxType> Pos::IdxPairDataSet::secondRange ( IdxType  firsidx = -1) const
void Pos::IdxPairDataSet::set ( SPos  ,
const void *  obj = 0 
)

Will not check whether SPos is in set When iterating, this is not an issue If unsure, check isValid(SPos)

void Pos::IdxPairDataSet::set ( const IdxPair ip,
const void *  obj = 0 
)
inline

May do the wrong thing if you have duplicates.

void Pos::IdxPairDataSet::setEmpty ( )
bool Pos::IdxPairDataSet::setObjSize ( ObjSzType  sz,
ObjSzType  offs_in_objs = -1,
const void *  initwith = 0 
)
bool Pos::IdxPairDataSet::slurp ( od_istream ,
bool  binary 
)
GlobIdxType Pos::IdxPairDataSet::totalSize ( ) const
SPos Pos::IdxPairDataSet::update ( const IdxPair ,
const void *  obj = 0 
)

May do the wrong thing if you have duplicates Will add if necessary If returned SPos is not valid memory was full

Member Data Documentation

bool Pos::IdxPairDataSet::allowdup_
protected
IdxSet Pos::IdxPairDataSet::frsts_
protected
const bool Pos::IdxPairDataSet::mandata_
protected
ObjectSet<ObjData> Pos::IdxPairDataSet::objdatas_
protected
const ObjSzType Pos::IdxPairDataSet::objsz_
protected
ObjectSet<IdxSet> Pos::IdxPairDataSet::scndsets_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019