Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
KM3NETDAQ::JRandomTimeslice::random_indices_t Struct Reference

Auxiliary data structure for randomisation of indices. More...

#include <JRandomTimeslice.hh>

Inheritance diagram for KM3NETDAQ::JRandomTimeslice::random_indices_t:
std::vector< size_t >

Public Member Functions

 random_indices_t (const size_t N)
 Constructor.
 
void random_shuffle (const std::set< size_t > &keep)
 Randomly shuffle values between fixed indices.
 

Private Member Functions

void random_shuffle (const int i1, const int i2)
 Randomly shuffle values between given indices.
 

Detailed Description

Auxiliary data structure for randomisation of indices.

Definition at line 166 of file JRandomTimeslice.hh.

Constructor & Destructor Documentation

◆ random_indices_t()

KM3NETDAQ::JRandomTimeslice::random_indices_t::random_indices_t ( const size_t N)
inline

Constructor.

Parameters
Nnumber of indices

Definition at line 174 of file JRandomTimeslice.hh.

174 :
176 {}

Member Function Documentation

◆ random_shuffle() [1/2]

void KM3NETDAQ::JRandomTimeslice::random_indices_t::random_shuffle ( const std::set< size_t > & keep)
inline

Randomly shuffle values between fixed indices.

Parameters
keepfixed indices

Definition at line 183 of file JRandomTimeslice.hh.

184 {
185 for (size_t i = 0; i != this->size(); ++i) {
186 (*this)[i] = i;
187 }
188
189 size_t i1 = 0;
190
191 for (const size_t i2 : keep) {
192
193 random_shuffle(i1, i2);
194
195 i1 = i2 + 1;
196 }
197
198 random_shuffle(i1, this->size());
199 }
void random_shuffle(const std::set< size_t > &keep)
Randomly shuffle values between fixed indices.

◆ random_shuffle() [2/2]

void KM3NETDAQ::JRandomTimeslice::random_indices_t::random_shuffle ( const int i1,
const int i2 )
inlineprivate

Randomly shuffle values between given indices.

Parameters
i1first index (included)
i2last index (excluded)

Definition at line 208 of file JRandomTimeslice.hh.

209 {
210 for (int i = i2 - 1; i > i1; --i) {
211
212 const int l = i1 + gRandom->Integer(i - i1);
213
214 std::swap((*this)[i], (*this)[l]);
215 }
216 }

The documentation for this struct was generated from the following file: