OpendTect-6_4  6.4
odset.h
Go to the documentation of this file.
1 #ifndef odset_h
2 #define odset_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert
9  Date: Feb 2009
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #ifndef gendefs_h
16 # include "gendefs.h"
17 #endif
18 
19 namespace OD
20 {
21 
34 mExpClass(Basic) Set
35 {
36 public:
37 
38  virtual ~Set() {}
39 
40  virtual od_int64 nrItems() const = 0;
41  virtual bool validIdx(od_int64) const = 0;
42  virtual void swap(od_int64,od_int64) = 0;
43  virtual void erase() = 0;
44 
45  inline bool isEmpty() const { return nrItems() <= 0; }
46  inline void setEmpty() { erase(); }
47 
48 };
49 
50 } // namespace
51 
52 
53 
56 template <class ODSET,class size_type>
57 inline void removeRange( ODSET& inst, size_type start, size_type stop )
58 {
59  inst.removeRange( start, stop );
60 }
61 
62 
66 template <class ODSET,class WITHADD>
67 inline void addNames( const ODSET& inp, WITHADD& withadd )
68 {
69  const typename ODSET::size_type sz = inp.size();
70  for ( typename ODSET::size_type idx=0; idx<sz; idx++ )
71  withadd.add( inp[idx]->name() );
72 }
73 
74 #define mODSetApplyToAll( itp, os, op ) \
75  for ( itp idx=(itp) os.nrItems()-1; idx>=0; idx-- ) \
76  { \
77  op; \
78  }
79 
80 
81 #endif
#define mExpClass(module)
Definition: commondefs.h:160
#define od_int64
Definition: plftypes.h:36
bool isEmpty() const
Definition: odset.h:45
virtual ~Set()
Definition: odset.h:38
void setEmpty()
Definition: odset.h:46
void removeRange(ODSET &inst, size_type start, size_type stop)
Removes a range from the set.
Definition: odset.h:57
Base class for all sets used in OpendTect.
Definition: odset.h:34
OpendTect.
Definition: commontypes.h:29
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:67

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