12#include "MantidKernel/DllConfig.h"
16#include <boost/multi_index/hashed_index.hpp>
17#include <boost/multi_index/mem_fun.hpp>
18#include <boost/multi_index/sequenced_index.hpp>
19#include <boost/multi_index_container.hpp>
35 using item_list =
typename boost::multi_index::multi_index_container<
37 boost::multi_index::indexed_by<boost::multi_index::sequenced<>,
38 boost::multi_index::hashed_unique<::boost::multi_index::const_mem_fun<
39 T, std::uintptr_t, &T::hashIndexFunction>>>>;
54 MRUList(
const std::size_t &max_num_items_) : max_num_items(max_num_items_) {}
78 std::shared_ptr<T>
insert(std::shared_ptr<T> item) {
79 std::lock_guard<std::mutex> _lock(m_mutex);
80 auto p = this->il.push_front(std::move(item));
84 this->il.relocate(this->il.begin(), p.first);
89 exceeding_size = this->il.size() > max_num_items;
92 std::shared_ptr<T> toWrite;
98 toWrite = std::move(this->il.back());
108 std::lock_guard<std::mutex> _lock(m_mutex);
118 std::lock_guard<std::mutex> _lock(m_mutex);
120 auto it = il.template get<1>().find(
index);
121 if (it != il.template get<1>().end()) {
122 il.template get<1>().erase(it);
128 size_t size()
const {
return il.size(); }
136 std::lock_guard<std::mutex> _lock(m_mutex);
138 auto it = il.template get<1>().find(
index);
139 if (it == il.template get<1>().end()) {
std::map< DeltaEMode::Type, std::string > index
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
An MRU (most recently used) list keeps record of the last n inserted items, listing first the newer o...
MRUList & operator=(MRUList &)
Private, unimplemented copy assignment operator.
size_t size() const
Size of the list.
std::mutex m_mutex
Mutex for modifying the MRU list.
void clear()
Delete all the T's pointed to by the list, and empty the list itself.
const std::size_t max_num_items
The length of the list.
void deleteIndex(const uintptr_t index)
Delete the T at the given index.
T * find(const uintptr_t index) const
Find an element of the list from the key of the index.
MRUList(const std::size_t &max_num_items_)
Constructor.
item_list il
The most recently used list.
MRUList(MRUList &)
Private, unimplemented copy constructor.
std::shared_ptr< T > insert(std::shared_ptr< T > item)
Insert an item into the list.
typename boost::multi_index::nth_index< item_list, 1 >::type ordered_item_list
This typedef makes an ordered item list (you access it by the 1st index)
typename boost::multi_index::multi_index_container< std::shared_ptr< T >, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_unique<::boost::multi_index::const_mem_fun< T, std::uintptr_t, &T::hashIndexFunction > > > > item_list
hideous typedef for the container holding the list
Helper class which provides the Collimation Length for SANS instruments.