Mantid
Loading...
Searching...
No Matches
IndexSet.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2016 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include <vector>
10
11#include "MantidKernel/DllConfig.h"
12
13namespace Mantid {
14namespace Kernel {
15
26class MANTID_KERNEL_DLL IndexSet {
27public:
28 IndexSet(size_t fullRange);
29 IndexSet(int64_t min, int64_t max, size_t fullRange);
30 IndexSet(const std::vector<size_t> &indices, size_t fullRange);
31
33 size_t size() const { return m_size; }
34
36 size_t operator[](size_t index) const {
37 // This is accessed frequently in loops and thus inlined.
38 if (m_isRange)
39 return m_min + index;
40 return m_indices[index];
41 }
42
43private:
44 bool m_isRange = true;
45 // Default here to avoid uninitialized warning for m_isRange = false.
46 size_t m_min = 0;
47 size_t m_size;
48 std::vector<size_t> m_indices;
49};
50
51} // Namespace Kernel
52} // Namespace Mantid
size_t m_size
Maximum size of the store.
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
specnum_t m_min
IndexSet is a container that can be used to define and access a subset of elements in a larger contai...
Definition: IndexSet.h:26
size_t operator[](size_t index) const
Returns the element at given index (range 0...size()-1).
Definition: IndexSet.h:36
std::vector< size_t > m_indices
Definition: IndexSet.h:48
size_t size() const
Returns the size of the set.
Definition: IndexSet.h:33
Helper class which provides the Collimation Length for SANS instruments.