OpenMS
Loading...
Searching...
No Matches
IDDataContainer< Value, Key, Prefix, KeyMembers > Class Template Reference

A collection of identification records, unique and ordered by the key formed from the members KeyMembers. More...

#include <OpenMS/METADATA/ID/IDDataContainer.h>

Classes

struct  Compare
 

Public Types

using value_type = Value
 
using key_type = Key
 
using size_type = std::size_t
 
using iterator = typename Set::const_iterator
 
using const_iterator = iterator
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = reverse_iterator
 

Public Member Functions

 IDDataContainer ()=default
 
 IDDataContainer (std::initializer_list< Value > values)
 
iterator begin () const
 
iterator end () const
 
iterator cbegin () const
 
iterator cend () const
 
reverse_iterator rbegin () const
 
reverse_iterator rend () const
 
const Value & front () const
 
const Value & back () const
 
bool empty () const
 
size_type size () const
 
void clear ()
 
void swap (IDDataContainer &other) noexcept
 
std::pair< iterator, bool > insert (const Value &value)
 
std::pair< iterator, bool > push_back (const Value &value)
 
template<typename... Args>
std::pair< iterator, bool > emplace (Args &&... args)
 
template<typename... Args>
std::pair< iterator, bool > emplace_back (Args &&... args)
 
iterator erase (iterator position)
 
template<typename Modifier >
bool modify (iterator &position, Modifier &&modifier)
 Calls modifier(Value&) on the record at position.
 
iterator find (const Key &key) const
 
std::pair< iterator, iterator > equal_range (const Prefix &key) const
 

Private Types

using Set = std::set< Value, Compare >
 

Private Member Functions

bool stillOrdered_ (iterator position) const
 True if the record at position still sorts strictly between its neighbours.
 

Static Private Member Functions

template<typename T >
static decltype(auto) keyView (const T &x)
 

Private Attributes

Set records_
 

Friends

bool operator== (const IDDataContainer &lhs, const IDDataContainer &rhs)
 Value equality is available only for equality-comparable record types.
 

Detailed Description

template<typename Value, typename Key, typename Prefix = Key, auto... KeyMembers>
class OpenMS::IdentificationDataInternal::IDDataContainer< Value, Key, Prefix, KeyMembers >

A collection of identification records, unique and ordered by the key formed from the members KeyMembers.

A std::set underneath: references and iterators to records stay valid on insertion and on a modification that keeps the record's key, and they are 8-byte iterators that step inline. Lookup takes the key (a std::tuple for a composite key) or a Prefix of it. Copying copies the records; moving and swapping keep references to them.

modify() changes a record in place. A modification that changes the key moves the record to its new position (references to it stay valid); one that duplicates another record's key erases the record instead and returns false, as Boost.MultiIndex did.

Member Typedef Documentation

◆ const_iterator

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
using const_iterator = iterator

◆ const_reverse_iterator

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
using const_reverse_iterator = reverse_iterator

◆ iterator

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
using iterator = typename Set::const_iterator

◆ key_type

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
using key_type = Key

◆ reverse_iterator

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
using reverse_iterator = std::reverse_iterator<iterator>

◆ Set

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
using Set = std::set<Value, Compare>
private

◆ size_type

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
using size_type = std::size_t

◆ value_type

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
using value_type = Value

Constructor & Destructor Documentation

◆ IDDataContainer() [1/2]

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
IDDataContainer ( )
default

◆ IDDataContainer() [2/2]

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
IDDataContainer ( std::initializer_list< Value >  values)
inline

Member Function Documentation

◆ back()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
const Value & back ( ) const
inline

◆ begin()

◆ cbegin()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
iterator cbegin ( ) const
inline

◆ cend()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
iterator cend ( ) const
inline

◆ clear()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
void clear ( )
inline

◆ emplace()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
template<typename... Args>
std::pair< iterator, bool > emplace ( Args &&...  args)
inline

◆ emplace_back()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
template<typename... Args>
std::pair< iterator, bool > emplace_back ( Args &&...  args)
inline

◆ empty()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
bool empty ( ) const
inline

◆ end()

◆ equal_range()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
std::pair< iterator, iterator > equal_range ( const Prefix &  key) const
inline

◆ erase()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
iterator erase ( iterator  position)
inline

◆ find()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
iterator find ( const Key &  key) const
inline

◆ front()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
const Value & front ( ) const
inline

◆ insert()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
std::pair< iterator, bool > insert ( const Value &  value)
inline

◆ keyView()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
template<typename T >
static decltype(auto) keyView ( const T &  x)
inlinestaticprivate

◆ modify()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
template<typename Modifier >
bool modify ( iterator &  position,
Modifier &&  modifier 
)
inline

Calls modifier(Value&) on the record at position.

position follows the record: it keeps pointing at it after a key change, and after a modification that was rejected as a duplicate it points at the record after the erased one.

References IDDataContainer< Value, Key, Prefix, KeyMembers >::records_, and IDDataContainer< Value, Key, Prefix, KeyMembers >::stillOrdered_().

◆ push_back()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
std::pair< iterator, bool > push_back ( const Value &  value)
inline

◆ rbegin()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
reverse_iterator rbegin ( ) const
inline

◆ rend()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
reverse_iterator rend ( ) const
inline

◆ size()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
size_type size ( ) const
inline

◆ stillOrdered_()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
bool stillOrdered_ ( iterator  position) const
inlineprivate

True if the record at position still sorts strictly between its neighbours.

References IDDataContainer< Value, Key, Prefix, KeyMembers >::records_.

Referenced by IDDataContainer< Value, Key, Prefix, KeyMembers >::modify().

◆ swap()

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
void swap ( IDDataContainer< Value, Key, Prefix, KeyMembers > &  other)
inlinenoexcept

Friends And Related Symbol Documentation

◆ operator==

template<typename Value , typename Key , typename Prefix = Key, auto... KeyMembers>
bool operator== ( const IDDataContainer< Value, Key, Prefix, KeyMembers > &  lhs,
const IDDataContainer< Value, Key, Prefix, KeyMembers > &  rhs 
)
friend

Value equality is available only for equality-comparable record types.

Member Data Documentation

◆ records_