Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Mantid::Kernel::IndexSet Class Reference

IndexSet is a container that can be used to define and access a subset of elements in a larger container such as std::vector. More...

#include <IndexSet.h>

Public Member Functions

 IndexSet (const std::vector< size_t > &indices, size_t fullRange)
 Constructor for a set containing all specified indices. More...
 
 IndexSet (int64_t min, int64_t max, size_t fullRange)
 Constructor for a set covering the range from min to max. More...
 
 IndexSet (size_t fullRange)
 Constructor for a set covering the full range from 0 to fullRange-1. More...
 
size_t operator[] (size_t index) const
 Returns the element at given index (range 0...size()-1). More...
 
size_t size () const
 Returns the size of the set. More...
 

Private Attributes

std::vector< size_t > m_indices
 
bool m_isRange = true
 
size_t m_min = 0
 
size_t m_size
 

Detailed Description

IndexSet is a container that can be used to define and access a subset of elements in a larger container such as std::vector.

In particular this is used when accessing the spectra in a workspace. Users frequently need to specify a certain range or list of spectra to use for an operation. This class provides a set of indices for this purpose.

Author
Simon Heybrock, ESS

Definition at line 26 of file IndexSet.h.

Constructor & Destructor Documentation

◆ IndexSet() [1/3]

IndexSet::IndexSet ( size_t  fullRange)

Constructor for a set covering the full range from 0 to fullRange-1.

Definition at line 16 of file IndexSet.cpp.

◆ IndexSet() [2/3]

IndexSet::IndexSet ( int64_t  min,
int64_t  max,
size_t  fullRange 
)

Constructor for a set covering the range from min to max.

Range is verified at construction time.

Definition at line 20 of file IndexSet.cpp.

References m_min, and m_size.

◆ IndexSet() [3/3]

IndexSet::IndexSet ( const std::vector< size_t > &  indices,
size_t  fullRange 
)

Constructor for a set containing all specified indices.

Range is verified at construction time and duplicates are removed.

Definition at line 33 of file IndexSet.cpp.

References index, m_indices, and m_size.

Member Function Documentation

◆ operator[]()

size_t Mantid::Kernel::IndexSet::operator[] ( size_t  index) const
inline

Returns the element at given index (range 0...size()-1).

Definition at line 36 of file IndexSet.h.

References index, and m_min.

◆ size()

size_t Mantid::Kernel::IndexSet::size ( ) const
inline

Returns the size of the set.

Definition at line 33 of file IndexSet.h.

References m_size.

Referenced by Mantid::Algorithms::SpectrumAlgorithm::for_each().

Member Data Documentation

◆ m_indices

std::vector<size_t> Mantid::Kernel::IndexSet::m_indices
private

Definition at line 48 of file IndexSet.h.

Referenced by IndexSet().

◆ m_isRange

bool Mantid::Kernel::IndexSet::m_isRange = true
private

Definition at line 44 of file IndexSet.h.

◆ m_min

size_t Mantid::Kernel::IndexSet::m_min = 0
private

Definition at line 46 of file IndexSet.h.

Referenced by IndexSet().

◆ m_size

size_t Mantid::Kernel::IndexSet::m_size
private

Definition at line 47 of file IndexSet.h.

Referenced by IndexSet().


The documentation for this class was generated from the following files: