Mantid
|
An MRU (most recently used) list keeps record of the last n inserted items, listing first the newer ones. More...
#include <MRUList.h>
Public Member Functions | |
void | clear () |
Delete all the T's pointed to by the list, and empty the list itself. More... | |
void | deleteIndex (const uintptr_t index) |
Delete the T at the given index. More... | |
T * | find (const uintptr_t index) const |
Find an element of the list from the key of the index. More... | |
std::shared_ptr< T > | insert (std::shared_ptr< T > item) |
Insert an item into the list. More... | |
MRUList () | |
Constructor. More... | |
MRUList (const std::size_t &max_num_items_) | |
Constructor. More... | |
size_t | size () const |
Size of the list. More... | |
~MRUList () | |
Destructor. More... | |
Private Types | |
using | item_list = 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 > > > > |
hideous typedef for the container holding the list More... | |
using | ordered_item_list = typename boost::multi_index::nth_index< item_list, 1 >::type |
This typedef makes an ordered item list (you access it by the 1st index) More... | |
Private Member Functions | |
MRUList (MRUList &) | |
Private, unimplemented copy constructor. More... | |
MRUList & | operator= (MRUList &) |
Private, unimplemented copy assignment operator. More... | |
Private Attributes | |
item_list | il |
The most recently used list. More... | |
std::mutex | m_mutex |
Mutex for modifying the MRU list. More... | |
const std::size_t | max_num_items |
The length of the list. More... | |
An MRU (most recently used) list keeps record of the last n inserted items, listing first the newer ones.
Care has to be taken when a duplicate item is inserted: instead of letting it appear twice, the MRU list relocates it to the first position. This class has been largely taken from one of the examples given in the Boost.MultiIndex documentation (http://www.boost.org/libs/multi_index/doc/reference/index.html)
|
private |
|
private |
|
inline |
|
inline |
|
inline |
|
private |
Private, unimplemented copy constructor.
|
inline |
|
inline |
|
inline |
|
inline |
Insert an item into the list.
If it's already in the list, it's moved to the top. If it's a new item, it's put at the top and the last item in the list is written to file and dropped.
item | :: The item, of type T, to put in the list |
|
private |
Private, unimplemented copy assignment operator.
|
inline |
|
mutableprivate |
|
mutableprivate |
|
private |