OpendTect  6.6
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 TypeSet< IdxType >::size_type ArrIdxType
 
typedef od_int64 GlobIdxType
 
typedef IdxPair::IdxType IdxType
 
typedef od_int64 ObjSzType
 

Public Member Functions

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

Protected Types

typedef od_int64 BufSzType
 
typedef TypeSet< IdxTypeIdxSet
 

Protected Member Functions

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

Static Protected Member Functions

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

Protected Attributes

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

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.
}
void set(SPos, const void *obj=0)
GlobIdxType totalSize() const
Set Position: position in IdxPairDataSet.
Definition: posidxpairdataset.h:76

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

◆ ArrIdxType

◆ BufSzType

typedef od_int64 Pos::IdxPairDataSet::BufSzType
protected

◆ GlobIdxType

◆ IdxSet

◆ IdxType

◆ ObjSzType

Constructor & Destructor Documentation

◆ IdxPairDataSet() [1/2]

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

◆ IdxPairDataSet() [2/2]

Pos::IdxPairDataSet::IdxPairDataSet ( const IdxPairDataSet )

◆ ~IdxPairDataSet()

virtual Pos::IdxPairDataSet::~IdxPairDataSet ( )
virtual

Member Function Documentation

◆ add() [1/2]

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

If returned SPos is not valid memory was full.

◆ add() [2/2]

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

Adds only IdxPair postions not yet in set.

◆ addEntry()

void Pos::IdxPairDataSet::addEntry ( const Pos::IdxPair ,
const void *  ,
SPos  
)
protected

◆ addObj()

bool Pos::IdxPairDataSet::addObj ( SPos ,
IdxType  ,
const void *   
)
protected

◆ allowDuplicateIdxPairs()

void Pos::IdxPairDataSet::allowDuplicateIdxPairs ( bool  )

◆ allowsDuplicateIdxPairs()

bool Pos::IdxPairDataSet::allowsDuplicateIdxPairs ( ) const
inline

◆ append()

bool Pos::IdxPairDataSet::append ( const IdxPairDataSet )

◆ colRange()

Interval<IdxType> Pos::IdxPairDataSet::colRange ( IdxType  row = -1) const
inline

◆ copyStructureFrom()

void Pos::IdxPairDataSet::copyStructureFrom ( const IdxPairDataSet )

will also empty this set

◆ crlRange()

Interval<IdxType> Pos::IdxPairDataSet::crlRange ( IdxType  inl = -1) const
inline

◆ decrObjSize()

void Pos::IdxPairDataSet::decrObjSize ( ObjSzType  ,
ObjSzType  offs = -1 
)

◆ dump()

bool Pos::IdxPairDataSet::dump ( od_ostream ,
bool  binary 
) const

◆ extend()

void Pos::IdxPairDataSet::extend ( const IdxPairDelta stepout,
const IdxPairStep ,
EntryCreatedFn  fn = 0 
)

Adds only IdxPair postions not yet in set.

◆ find()

SPos Pos::IdxPairDataSet::find ( const IdxPair ip) const
inline

◆ findFirst()

SPos Pos::IdxPairDataSet::findFirst ( const IdxPair ip) const
inline

◆ findIndexFor()

static ArrIdxType Pos::IdxPairDataSet::findIndexFor ( const IdxSet ,
IdxType  ,
bool *  found = 0 
)
staticprotected

◆ findOccurrence()

SPos Pos::IdxPairDataSet::findOccurrence ( const IdxPair ,
int  occ = 0 
) const

◆ firstIdxPair()

IdxPair Pos::IdxPairDataSet::firstIdxPair ( ) const

when empty returns udf()

◆ firstRange()

Interval<IdxType> Pos::IdxPairDataSet::firstRange ( ) const

◆ get()

const void* Pos::IdxPairDataSet::get ( SPos  ,
IdxPair  
) const

◆ getIdxPair()

IdxPair Pos::IdxPairDataSet::getIdxPair ( SPos  ) const

◆ getObj()

const void* Pos::IdxPairDataSet::getObj ( SPos  ) const

◆ getPos()

SPos Pos::IdxPairDataSet::getPos ( GlobIdxType  ) const

Very slow.

◆ gtFrst()

IdxType Pos::IdxPairDataSet::gtFrst ( const SPos pos) const
inlineprotected

◆ gtIdxPair()

IdxPair Pos::IdxPairDataSet::gtIdxPair ( const SPos pos) const
inlineprotected

◆ gtObj()

const void* Pos::IdxPairDataSet::gtObj ( const SPos ) const
protected

◆ gtObjData() [1/4]

ObjData& Pos::IdxPairDataSet::gtObjData ( ArrIdxType  idx)
inlineprotected

◆ gtObjData() [2/4]

const ObjData& Pos::IdxPairDataSet::gtObjData ( ArrIdxType  idx) const
inlineprotected

◆ gtObjData() [3/4]

ObjData& Pos::IdxPairDataSet::gtObjData ( const SPos pos)
inlineprotected

◆ gtObjData() [4/4]

const ObjData& Pos::IdxPairDataSet::gtObjData ( const SPos pos) const
inlineprotected

◆ gtScnd()

IdxType Pos::IdxPairDataSet::gtScnd ( const SPos pos) const
inlineprotected

◆ gtScndSet() [1/4]

IdxSet& Pos::IdxPairDataSet::gtScndSet ( ArrIdxType  idx)
inlineprotected

◆ gtScndSet() [2/4]

const IdxSet& Pos::IdxPairDataSet::gtScndSet ( ArrIdxType  idx) const
inlineprotected

◆ gtScndSet() [3/4]

IdxSet& Pos::IdxPairDataSet::gtScndSet ( const SPos pos)
inlineprotected

◆ gtScndSet() [4/4]

const IdxSet& Pos::IdxPairDataSet::gtScndSet ( const SPos pos) const
inlineprotected

◆ hasCol()

bool Pos::IdxPairDataSet::hasCol ( IdxType  col) const
inline

◆ hasCrl()

bool Pos::IdxPairDataSet::hasCrl ( IdxType  crl) const
inline

◆ hasDuplicateIdxPairs()

bool Pos::IdxPairDataSet::hasDuplicateIdxPairs ( ) const

◆ hasFirst()

bool Pos::IdxPairDataSet::hasFirst ( IdxType  ) const

◆ hasInl()

bool Pos::IdxPairDataSet::hasInl ( IdxType  inl) const
inline

◆ hasRow()

bool Pos::IdxPairDataSet::hasRow ( IdxType  row) const
inline

◆ hasSecond()

bool Pos::IdxPairDataSet::hasSecond ( IdxType  ) const

◆ includes()

bool Pos::IdxPairDataSet::includes ( const IdxPair ip) const
inline

◆ incrObjSize()

bool Pos::IdxPairDataSet::incrObjSize ( ObjSzType  ,
ObjSzType  offs = -1,
const void *  = 0 
)

◆ inlRange()

Interval<IdxType> Pos::IdxPairDataSet::inlRange ( ) const
inline

◆ isEmpty()

bool Pos::IdxPairDataSet::isEmpty ( ) const
inline

◆ isValid()

bool Pos::IdxPairDataSet::isValid ( const IdxPair ) const

◆ managesData()

bool Pos::IdxPairDataSet::managesData ( ) const
inline

◆ next()

bool Pos::IdxPairDataSet::next ( SPos ,
bool  skip_duplicate_idxpairs = false 
) const

◆ nrCols()

ArrIdxType Pos::IdxPairDataSet::nrCols ( IdxType  row) const
inline

◆ nrCrls()

ArrIdxType Pos::IdxPairDataSet::nrCrls ( IdxType  inl) const
inline

◆ nrDuplicateIdxPairs()

ArrIdxType Pos::IdxPairDataSet::nrDuplicateIdxPairs ( ) const

◆ nrFirst()

ArrIdxType Pos::IdxPairDataSet::nrFirst ( ) const
inline

◆ nrInls()

ArrIdxType Pos::IdxPairDataSet::nrInls ( ) const
inline

◆ nrPos()

ArrIdxType Pos::IdxPairDataSet::nrPos ( ArrIdxType  lineidx) const

◆ nrRows()

ArrIdxType Pos::IdxPairDataSet::nrRows ( ) const
inline

◆ nrSecond()

ArrIdxType Pos::IdxPairDataSet::nrSecond ( IdxType  firstidx) const

◆ objSize()

ObjSzType Pos::IdxPairDataSet::objSize ( ) const
inline

◆ operator=()

IdxPairDataSet& Pos::IdxPairDataSet::operator= ( const IdxPairDataSet )

◆ prev()

bool Pos::IdxPairDataSet::prev ( SPos ,
bool  skip_duplicate_idxpairs = false 
) const

◆ putObj()

void Pos::IdxPairDataSet::putObj ( const SPos ,
const void *   
)
protected

◆ randomSubselect()

void Pos::IdxPairDataSet::randomSubselect ( GlobIdxType  maxsz)

◆ remove() [1/4]

void Pos::IdxPairDataSet::remove ( const IdxPairDataSet )

◆ remove() [2/4]

void Pos::IdxPairDataSet::remove ( const TrcKeySampling hrg,
bool  inside 
)

◆ remove() [3/4]

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

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

◆ remove() [4/4]

void Pos::IdxPairDataSet::remove ( SPos  )

afterwards, input SPos may be invalid

◆ removeDuplicateIdxPairs()

void Pos::IdxPairDataSet::removeDuplicateIdxPairs ( )

◆ rowRange()

Interval<IdxType> Pos::IdxPairDataSet::rowRange ( ) const
inline

◆ secondRange()

Interval<IdxType> Pos::IdxPairDataSet::secondRange ( IdxType  firsidx = -1) const

◆ set() [1/2]

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

May do the wrong thing if you have duplicates.

◆ set() [2/2]

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)

◆ setEmpty()

void Pos::IdxPairDataSet::setEmpty ( )

◆ setObjSize()

bool Pos::IdxPairDataSet::setObjSize ( ObjSzType  sz,
ObjSzType  offs_in_objs = -1,
const void *  initwith = 0 
)

◆ slurp()

bool Pos::IdxPairDataSet::slurp ( od_istream ,
bool  binary 
)

◆ totalSize()

GlobIdxType Pos::IdxPairDataSet::totalSize ( ) const

◆ update()

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

◆ allowdup_

bool Pos::IdxPairDataSet::allowdup_
protected

◆ frsts_

IdxSet Pos::IdxPairDataSet::frsts_
protected

◆ mandata_

const bool Pos::IdxPairDataSet::mandata_
protected

◆ objdatas_

ObjectSet<ObjData> Pos::IdxPairDataSet::objdatas_
protected

◆ objsz_

const ObjSzType Pos::IdxPairDataSet::objsz_
protected

◆ scndsets_

ObjectSet<IdxSet> Pos::IdxPairDataSet::scndsets_
protected

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