Mantid
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Mantid::Geometry::Instrument::DetectorCache Struct Reference

A vector of DetectorCacheEntry, which holds the detector cache This is implemented as a vector rather than an ordered map to facilitate faster (unsorted) insertion some hotpaths requiring access by index. More...

Inheritance diagram for Mantid::Geometry::Instrument::DetectorCache:

Public Member Functions

DetectorCache::iterator find (detid_t id)
 Find the element in the detector cache with the given ID.
 
DetectorCache::const_iterator find (detid_t id) const
 Find the element in the detector cache with the given ID.
 
bool isFinalized () const
 
DetectorCache::iterator lower_bound (detid_t id)
 Perform a lower bound search on the detector cache, for the element with the given ID.
 
DetectorCache::const_iterator lower_bound (detid_t id) const
 Perform a lower bound search on the detector cache, for the element with the given ID.
 
detid_t maxID () const
 
detid_t minID () const
 
void setFinalized (bool const flag=true)
 
void setIncomplete ()
 

Public Attributes

bool m_isFinalized {true}
 
std::unordered_set< IDetector const * > m_toRemove
 

Detailed Description

A vector of DetectorCacheEntry, which holds the detector cache This is implemented as a vector rather than an ordered map to facilitate faster (unsorted) insertion some hotpaths requiring access by index.

This vector otherwise should act like an ordered map.

Note
this class anticipates future extension by optimizing the lower_bound and find methods

Definition at line 287 of file Instrument.h.

Member Function Documentation

◆ find() [1/2]

Instrument::DetectorCache::iterator Mantid::Geometry::Instrument::DetectorCache::find ( detid_t  id)

Find the element in the detector cache with the given ID.

Note that this method is only valid for a finalized (sorted) instrument cache; otherwise the results are undefined. This method should complete in O(log N), where N is the number of detectors in the cache.

Parameters
idthe detector ID to search for
Returns
an iterator to the DetectorCacheEntry with the given ID, or end() if no such element exists
Exceptions
std::runtime_errorif the detector cache is not finalized

Definition at line 515 of file Instrument.cpp.

References Mantid::Geometry::Instrument::isFinalized().

Referenced by Mantid::Geometry::Instrument::detectorIndex(), Mantid::Geometry::Instrument::getDetector(), Mantid::Geometry::Instrument::isMonitor(), Mantid::Geometry::Instrument::markAsMonitor(), and Mantid::Geometry::Instrument::removeDetector().

◆ find() [2/2]

Instrument::DetectorCache::const_iterator Mantid::Geometry::Instrument::DetectorCache::find ( detid_t  id) const

Find the element in the detector cache with the given ID.

Note that this method is only valid for a finalized (sorted) instrument cache; otherwise the results are undefined. This method should complete in O(log N), where N is the number of detectors in the cache.

Parameters
idthe detector ID to search for
Returns
a const iterator to the DetectorCacheEntry with the given ID, or end() if no such element exists
Exceptions
std::runtime_errorif the detector cache is not finalized

Definition at line 534 of file Instrument.cpp.

References Mantid::Geometry::Instrument::isFinalized().

◆ isFinalized()

bool Mantid::Geometry::Instrument::DetectorCache::isFinalized ( ) const
inline

Definition at line 289 of file Instrument.h.

Referenced by lower_bound().

◆ lower_bound() [1/2]

Instrument::DetectorCache::iterator Mantid::Geometry::Instrument::DetectorCache::lower_bound ( detid_t  id)

Perform a lower bound search on the detector cache, for the element with the given ID.

Note that this method is only valid for a finalized (sorted) detector cache; otherwise the results are undefined. This method should complete in O(log N), where N is the number of detectors in the cache.

Parameters
idthe detector ID to search for
Returns
an iterator to the first DetectorCacheEntry with ID >= the given ID, or end() if no such element exists
Exceptions
std::runtime_errorif the detector cache is not finalized
Note
optimizations in this method could improve performance in lookup speeds

Definition at line 483 of file Instrument.cpp.

References Mantid::Geometry::Instrument::DetectorCacheEntry::id(), and isFinalized().

Referenced by Mantid::Geometry::Instrument::markAsDetector().

◆ lower_bound() [2/2]

Instrument::DetectorCache::const_iterator Mantid::Geometry::Instrument::DetectorCache::lower_bound ( detid_t  id) const

Perform a lower bound search on the detector cache, for the element with the given ID.

Note that this method is only valid for a finalized (sorted) detector cache; otherwise the results are undefined. This method should complete in O(log N), where N is the number of detectors in the cache.

Parameters
idthe detector ID to search for
Returns
a constant iterator to the first DetectorCacheEntry with ID >= the given ID, or cend() if no such element exists
Exceptions
std::runtime_errorif the detector cache is not finalized
Note
optimizations in this method could improve performance in lookup speeds

Definition at line 500 of file Instrument.cpp.

References Mantid::Geometry::Instrument::DetectorCacheEntry::id(), and Mantid::Geometry::Instrument::isFinalized().

◆ maxID()

detid_t Mantid::Geometry::Instrument::DetectorCache::maxID ( ) const
inline

Definition at line 299 of file Instrument.h.

◆ minID()

detid_t Mantid::Geometry::Instrument::DetectorCache::minID ( ) const
inline

Definition at line 292 of file Instrument.h.

◆ setFinalized()

void Mantid::Geometry::Instrument::DetectorCache::setFinalized ( bool const  flag = true)
inline

◆ setIncomplete()

void Mantid::Geometry::Instrument::DetectorCache::setIncomplete ( )
inline

Member Data Documentation

◆ m_isFinalized

bool Mantid::Geometry::Instrument::DetectorCache::m_isFinalized {true}

Definition at line 288 of file Instrument.h.

◆ m_toRemove

std::unordered_set<IDetector const *> Mantid::Geometry::Instrument::DetectorCache::m_toRemove

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