26 MultiDimStorage(
int ndims,
int nvals);
28 virtual ~MultiDimStorage();
35 void setNrVals(
int,
bool keepdata);
36 void removeValue(
int);
38 bool allowsDuplicates()
const;
41 bool allowDuplicates(
bool);
45 int totalSize()
const;
55 int getPos(
int idx)
const;
59 template <
class IDX>
const T&
getRef(
const IDX& index,
int val)
const;
62 template <
class IDX> T&
getRef(
const IDX& index,
int val);
65 template <
class V,
class POS,
class IDX>
66 bool add(
const V& vals,
const POS& pos,
69 template <
class V,
class POS>
bool add(
const V& vals,
const POS& pos);
72 template <
class IDX>
void remove(
const IDX& index);
76 template <
class POS,
class IDX>
bool findFirst(
const POS&,IDX&)
const;
77 template <
class IDX>
bool getIndex(
int global_pos,IDX&)
const;
78 template <
class IDX,
class POS>
bool getPos(
const IDX&,POS&)
const;
79 template <
class IDX>
bool next(IDX&,
bool skipdups=
false)
const;
80 template <
class IDX>
bool prev(IDX&,
bool skipdups=
false)
const;
81 template <
class IDX>
bool isValidPos(
const IDX&)
const;
82 void removeDuplicates();
91 template <
class POS>
void getIndicesInRange(
const POS& start,
99 template <
class IDX>
void setToLastPos(IDX&)
const;
100 int findFirstPos(
int pos)
const;
101 template <
class POS>
void getIndicesInRangeI(
const POS& start,
117 template <
class T>
inline 121 , allowduplicates_( false )
125 template <
class T>
inline 145 template <
class T>
inline 152 template <
class T>
inline 173 template <
class T>
inline 182 template <
class T>
inline 188 for (
int idx=0; idx<b.
size(); idx++ )
190 const int pos = b.
getPos( idx );
231 template <
class T>
inline 236 template <
class T>
inline 251 template <
class T>
inline 265 template <
class T>
inline 279 template <
class T>
inline 286 template <
class T>
inline 294 template <
class T>
inline 302 template <
class T>
inline 307 template <
class T>
inline 313 template <
class T>
inline 328 template <
class T>
inline 349 template <
class T>
inline 353 template <
class T>
inline 357 template <
class T>
inline 373 const int nrpos =
size();
377 for (
int idx=0; idx<nrpos; idx++ )
379 for (
int idy=0; idy<nrvalstocp; idy++ )
389 template <
class T>
template <
class IDX>
inline 392 const int index = indexarr[
nrdims_-1];
399 template <
class T>
template <
class IDX>
inline 405 template <
class T>
template <
class V,
class POS,
class IDX>
inline 410 const int pos =
mCast(
int, posarr[dim] );
414 if ( !match ) index++;
416 if ( indexarr ) (*indexarr)[dim] = index;
447 for (
int idx=0; idx<
nrvals_; idx++ )
449 const int arrpos = index*nrvals_+idx;
465 for (
int idx=0; idx<
nrvals_; idx++ )
474 template <
class T>
template <
class V,
class POS>
inline 477 return add<V,POS,int*>( vals, posarr, 0 );
481 template <
class T>
template<
class IDX>
inline 485 const int index = indexarr[dim];
504 template <
class T>
template <
class POS,
class IDX>
inline 508 const int pos = posarr[dim];
514 indexarr[dim] = index;
520 template <
class T>
template <
class IDX,
class POS>
inline 524 int index = indexarr[dim];
533 template <
class T>
template <
class IDX>
inline 537 int& index = indexarr[dim];
544 if ( globalpos<localsum )
550 globalpos -= localsum;
566 template <
class T>
template <
class IDX>
inline 570 int& index = indexarr[dim];
615 }
while ( skipduplicate &&
positions_[index]==oldpos );
621 template <
class T>
template <
class IDX>
inline 625 int& index = indexarr[dim];
643 template <
class T>
template<
class IDX>
inline 647 const int index = indexarr[dim];
660 template <
class T>
inline 684 template <
class T>
template <
class POS>
inline 693 template <
class T>
template <
class POS>
inline 698 const int start = startarr[dim];
699 const int stop = stoparr[dim];
705 if ( idx<0 ) idx = 0;
707 for ( ; idx<sz; idx++ )
722 template <
class T>
template <
class IDX>
inline 726 const int index = indexarr[dim] =
size()-1;
732 template <
class T>
inline 742 for (
int idy=0; idy<
nrvals_; idy++ )
749 template <
class T>
inline 752 const int nrchunks = res.
size();
762 const int nrperchunk =
mNINT32((
float) totalsize / nrchunks );
765 int* idxs = allocidx;
766 for (
int idx=0; idx<
nrdims_; idx++ )
773 int chunk = idx/nrperchunk;
774 if ( chunk>=nrchunks )
779 if ( chunk==prevchunk )
782 for (
int idy=0; idy<
nrdims_; idy++ )
783 res[chunk][idy] = idxs[idy];
792 template <
class T>
template <
class IDXS>
inline 800 long long multiplicator = 1;
801 for (
int dim=0; dim<
nrdims_; dim++ )
803 dimsizes += multiplicator;
807 multiplicator *= ( rg.
width()+1 );
813 for (
int idx=0; idx<indices.
size(); idx++ )
815 long long sortkey = 0;
816 for (
int dim=0; dim<
nrdims_; dim++ )
817 sortkey += indices[idx][dim] * dimsizes[dim];
826 for (
int idx=
mCast(
int,idxs.
size()-1); idx>=0; idx-- )
827 indices[idx] = copy[(
int)idxs[idx]];
MultiDimStorage(int ndims, int nvals)
Definition: multidimstorage.h:118
virtual void insert(size_type, const T &)
Definition: typeset.h:368
Definition: multidimstorage.h:23
bool allowDuplicates(bool)
Definition: multidimstorage.h:237
#define mCast(tp, v)
Definition: commondefs.h:120
bool findFirst(const POS &, IDX &) const
Definition: multidimstorage.h:505
bool prev(IDX &, bool skipdups=false) const
Definition: multidimstorage.h:622
bool isEmpty() const
Definition: odset.h:43
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:173
int getPos(int idx) const
Definition: multidimstorage.h:308
int nrvals_
Definition: multidimstorage.h:113
void setNrVals(int, bool keepdata)
Definition: multidimstorage.h:358
bool getIndex(int global_pos, IDX &) const
Definition: multidimstorage.h:534
virtual T * removeSingle(size_type, bool keep_order=true)
Definition: objectset.h:464
#define mMIN(x, y)
Definition: commondefs.h:52
MultiDimStorage< T > & operator=(const MultiDimStorage< T > &)
Definition: multidimstorage.h:133
bool getRange(int dim, Interval< int > &) const
Definition: multidimstorage.h:314
virtual T * arr()
3rd party access
Definition: typeset.h:86
size_type size() const
Definition: objectset.h:48
bool append(TypeSetBase< T, I > &to, const TypeSetBase< S, J > &from)
append allowing a different type to be merged into set
Definition: typeset.h:205
T & getRef(ObjectSet< T > &objset, int i)
Definition: objectset.h:102
#define mNINT32(x)
Definition: commondefs.h:48
Set of (small) copyable elements.
Definition: commontypes.h:26
bool allowsDuplicates() const
Definition: multidimstorage.h:232
MultiDimStorage< T > * operator[](int)
Definition: multidimstorage.h:287
T width(bool allowrev=true) const
Definition: ranges.h:450
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
void getIndicesInRange(const POS &start, const POS &stop, TypeSet< int > &res) const
Definition: multidimstorage.h:685
virtual ~MultiDimStorage()
Definition: multidimstorage.h:146
bool isValidPos(const IDX &) const
Definition: multidimstorage.h:644
bool isEmpty() const
Definition: multidimstorage.h:252
int size() const
Definition: multidimstorage.h:280
bool add(const V &vals, const POS &pos, IDX *index=0)
Definition: multidimstorage.h:406
TypeSet< T > onedimstorage_
Definition: multidimstorage.h:108
void deepCopy(ObjectSet< T > &to, const ObjectSet< S > &from)
fill an ObjectSet with copies of the objects in the other set.
Definition: objectset.h:151
TypeSet< int > positions_
Definition: multidimstorage.h:106
bool append(const MultiDimStorage< T > &)
Definition: multidimstorage.h:183
void removeDuplicates()
Definition: multidimstorage.h:733
void getIndicesInRangeI(const POS &start, const POS &stop, TypeSet< int > &curpos, TypeSet< int > &res) const
Definition: multidimstorage.h:694
void setToLastPos(IDX &) const
Definition: multidimstorage.h:723
int nrdims_
Definition: multidimstorage.h:112
bool allowduplicates_
Definition: multidimstorage.h:109
void remove(const IDX &index)
Definition: multidimstorage.h:482
virtual bool append(const T *, size_type)
Definition: typeset.h:444
bool isOK() const
Definition: multidimstorage.h:153
int nrVals() const
Definition: multidimstorage.h:354
size_type size() const
Definition: typeset.h:263
T stop
Definition: ranges.h:91
void include(const T &, bool allowrev=true)
Definition: ranges.h:530
virtual void insertAt(T *newptr, size_type)
Definition: objectset.h:409
bool isEmpty(const char *)
void sort(ObjectSet< T > &os)
Sort ObjectSet. Must have operator > defined for elements.
Definition: objectset.h:224
int totalSize() const
Definition: multidimstorage.h:266
const T & getRef(const IDX &index, int val) const
Definition: multidimstorage.h:400
bool next(IDX &, bool skipdups=false) const
Definition: multidimstorage.h:567
ObjectSet< MultiDimStorage< T > > lowerdimstorage_
Definition: multidimstorage.h:107
int nrDims() const
Definition: multidimstorage.h:350
virtual void erase()
Definition: typeset.h:360
void setEmpty()
Definition: multidimstorage.h:174
void getRangeI(int dim, Interval< int > &) const
Definition: multidimstorage.h:329
T start
Definition: ranges.h:90
bool sort(TypeSet< IDX > &indices) const
void copy(TypeSetBase< T, I > &to, const TypeSetBase< S, I > &from)
Definition: typeset.h:221
virtual void removeSingle(size_type, bool preserver_order=true)
Definition: typeset.h:507
#define mClass(module)
Definition: commondefs.h:161
#define pErrMsg(msg)
Usual access point for programmer error messages.
Definition: errmsg.h:34
bool divide(ObjectSet< int > &) const
Definition: multidimstorage.h:750
virtual size_type indexOf(T, bool forward=true, size_type start=-1) const
Definition: typeset.h:332
virtual bool validIdx(int64_t) const
Definition: typeset.h:288
bool findPos(const T1 &posarr, T3 sz, T2 pos, T3 beforefirst, T3 &idx)
Definition: idxable.h:73
int findFirstPos(int pos) const
Definition: multidimstorage.h:661
int indexOf(int pos) const
Definition: multidimstorage.h:303
void deepErase(ObjectSet< T > &os)
empty the ObjectSet deleting all objects pointed to.
Definition: objectset.h:122
void sort_coupled(T *arr, IT *idxs, I sz)
Definition: sorting.h:40