|
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. | |
| 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. | |
| std::shared_ptr< T > | insert (std::shared_ptr< T > item) |
| Insert an item into the list. | |
| MRUList () | |
| Constructor. | |
| MRUList (const std::size_t &max_num_items_) | |
| Constructor. | |
| size_t | size () const |
| Size of the list. | |
| ~MRUList () | |
| Destructor. | |
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 | |
| 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) | |
Private Member Functions | |
| MRUList (MRUList &) | |
| Private, unimplemented copy constructor. | |
| MRUList & | operator= (MRUList &) |
| Private, unimplemented copy assignment operator. | |
Private Attributes | |
| item_list | il |
| The most recently used list. | |
| std::mutex | m_mutex |
| Mutex for modifying the MRU list. | |
| const std::size_t | max_num_items |
| The length of the list. | |
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 |
Destructor.
Definition at line 64 of file MRUList.h.
References Mantid::Kernel::MRUList< T >::clear().
|
private |
Private, unimplemented copy constructor.
|
inline |
Delete all the T's pointed to by the list, and empty the list itself.
Definition at line 107 of file MRUList.h.
References Mantid::Kernel::MRUList< T >::m_mutex.
Referenced by Mantid::Kernel::MRUList< T >::~MRUList().
|
inline |
Delete the T at the given index.
Will also delete the object itself.
| index | :: the key (index) for this T that you want to remove from the MRU. |
Definition at line 117 of file MRUList.h.
References Mantid::Kernel::MRUList< T >::il, index, and Mantid::Kernel::MRUList< T >::m_mutex.
|
inline |
Find an element of the list from the key of the index.
| index | :: The index value to search the list for |
Definition at line 135 of file MRUList.h.
References Mantid::Kernel::MRUList< T >::il, index, and Mantid::Kernel::MRUList< T >::m_mutex.
|
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 |
Definition at line 78 of file MRUList.h.
References Mantid::Kernel::MRUList< T >::m_mutex, and Mantid::Kernel::MRUList< T >::max_num_items.
|
private |
Private, unimplemented copy assignment operator.
|
inline |
Size of the list.
Definition at line 128 of file MRUList.h.
References Mantid::Kernel::MRUList< T >::il.
|
mutableprivate |
The most recently used list.
Definition at line 45 of file MRUList.h.
Referenced by Mantid::Kernel::MRUList< T >::deleteIndex(), Mantid::Kernel::MRUList< T >::find(), and Mantid::Kernel::MRUList< T >::size().
|
mutableprivate |
Mutex for modifying the MRU list.
Definition at line 153 of file MRUList.h.
Referenced by Mantid::Kernel::MRUList< T >::clear(), Mantid::Kernel::MRUList< T >::deleteIndex(), Mantid::Kernel::MRUList< T >::find(), and Mantid::Kernel::MRUList< T >::insert().
|
private |
The length of the list.
Definition at line 47 of file MRUList.h.
Referenced by Mantid::Kernel::MRUList< T >::insert().