OpendTect  6.3
odset.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Bert
8  Date: Feb 2009
9 ________________________________________________________________________
10 
11 -*/
12 
13 #ifndef gendefs_h
14 # include "gendefs.h"
15 #endif
16 
17 namespace OD
18 {
19 
32 mExpClass(Basic) Set
33 {
34 public:
35 
36  virtual ~Set() {}
37 
38  virtual od_int64 nrItems() const = 0;
39  virtual bool validIdx(od_int64) const = 0;
40  virtual void swap(od_int64,od_int64) = 0;
41  virtual void erase() = 0;
42 
43  inline bool isEmpty() const { return nrItems() <= 0; }
44  inline void setEmpty() { erase(); }
45 
46 };
47 
48 } // namespace
49 
50 
51 
54 template <class ODSET,class size_type>
55 inline void removeRange( ODSET& inst, size_type start, size_type stop )
56 {
57  inst.removeRange( start, stop );
58 }
59 
60 
64 template <class ODSET,class WITHADD>
65 inline void addNames( const ODSET& inp, WITHADD& withadd )
66 {
67  const typename ODSET::size_type sz = inp.size();
68  for ( typename ODSET::size_type idx=0; idx<sz; idx++ )
69  withadd.add( inp[idx]->name() );
70 }
71 
72 #define mODSetApplyToAll( itp, os, op ) \
73  for ( itp idx=(itp) os.nrItems()-1; idx>=0; idx-- ) \
74  { \
75  op; \
76  }
#define mExpClass(module)
Definition: commondefs.h:157
#define od_int64
Definition: plftypes.h:34
bool isEmpty() const
Definition: odset.h:43
virtual ~Set()
Definition: odset.h:36
void setEmpty()
Definition: odset.h:44
void removeRange(ODSET &inst, size_type start, size_type stop)
Removes a range from the set.
Definition: odset.h:55
Base class for all sets used in OpendTect.
Definition: odset.h:32
OpendTect.
Definition: commontypes.h:25
void addNames(const ODSET &inp, WITHADD &withadd)
Adds all names from a set to another set with an add() function (typically a BufferStringSet) ...
Definition: odset.h:65

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