ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
BondList Class Reference

Bond storage. More...

#include <BondList.hpp>

Classes

class  Iterator
 

Public Types

using storage_type = Utils::compact_vector< int >
 
using value_type = BondView
 
using reference = std::add_lvalue_reference_t< BondView >
 
using const_reference = std::add_const_t< reference >
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using iterator = Iterator
 
using const_iterator = Iterator
 

Public Member Functions

 BondList ()=default
 
 BondList (BondList const &)=default
 
 BondList (BondList &&)=default
 
BondListoperator= (BondList const &rhs)
 
BondListoperator= (BondList &&rhs) noexcept
 
const_iterator begin () const
 Iterator to the beginning of the range of bonds in the list.
 
const_iterator end () const
 Iterator past the end of the range of bonds in the list.
 
void insert (BondView const &bond)
 Add a bond to the list.
 
const_iterator erase (const_iterator pos)
 Erase a bond from the list.
 
auto size () const
 Number of bonds.
 
void clear ()
 Erase all bonds from the list.
 
bool empty () const
 Check if the are any bonds in the list.
 

Friends

void swap (BondList &lhs, BondList &rhs)
 

Detailed Description

Bond storage.

This holds the bonds of a particle.

Implementation notes: Internally the bond list is represented as a sequence of integers. For each bond, first the ids of the bond partners are stored (which are positive numbers), then the negative of the value of the id of the bond plus one (which also is positive) is stored. This way we can use the sign bit of the int as a delimiter, every time a negative number is encountered one bond ends, and a new one starts. This mechanism allows us to efficiently store bonds of different numbers of partners in contiguous memory.

This is hidden from the client by providing access to the bonds only thru iterators that restore the semantic meanings of the entries, and know how to proceed to the next bond.

Definition at line 84 of file BondList.hpp.

Member Typedef Documentation

◆ const_iterator

Definition at line 154 of file BondList.hpp.

◆ const_reference

using BondList::const_reference = std::add_const_t<reference>

Definition at line 150 of file BondList.hpp.

◆ difference_type

using BondList::difference_type = std::ptrdiff_t

Definition at line 152 of file BondList.hpp.

◆ iterator

Definition at line 153 of file BondList.hpp.

◆ reference

using BondList::reference = std::add_lvalue_reference_t<BondView>

Definition at line 149 of file BondList.hpp.

◆ size_type

using BondList::size_type = std::size_t

Definition at line 151 of file BondList.hpp.

◆ storage_type

Definition at line 86 of file BondList.hpp.

◆ value_type

Definition at line 148 of file BondList.hpp.

Constructor & Destructor Documentation

◆ BondList() [1/3]

BondList::BondList ( )
default

◆ BondList() [2/3]

BondList::BondList ( BondList const &  )
default

◆ BondList() [3/3]

BondList::BondList ( BondList &&  )
default

Member Function Documentation

◆ begin()

const_iterator BondList::begin ( ) const
inline

Iterator to the beginning of the range of bonds in the list.

Definition at line 178 of file BondList.hpp.

Referenced by pair_bond_exists_on(), and size().

◆ clear()

void BondList::clear ( )
inline

Erase all bonds from the list.

Definition at line 215 of file BondList.hpp.

◆ empty()

bool BondList::empty ( ) const
inline

Check if the are any bonds in the list.

Definition at line 220 of file BondList.hpp.

◆ end()

const_iterator BondList::end ( ) const
inline

Iterator past the end of the range of bonds in the list.

Definition at line 182 of file BondList.hpp.

Referenced by pair_bond_exists_on(), and size().

◆ erase()

const_iterator BondList::erase ( const_iterator  pos)
inline

Erase a bond from the list.

Parameters
posIterator pointing to element to erase.
Returns
iterator pointing one past the erased element.

Definition at line 200 of file BondList.hpp.

◆ insert()

void BondList::insert ( BondView const &  bond)
inline

Add a bond to the list.

Parameters
bondBond to add.

Definition at line 189 of file BondList.hpp.

References BondView::bond_id(), and BondView::partner_ids().

◆ operator=() [1/2]

BondList & BondList::operator= ( BondList &&  rhs)
inlinenoexcept

Definition at line 167 of file BondList.hpp.

◆ operator=() [2/2]

BondList & BondList::operator= ( BondList const &  rhs)
inline

Definition at line 159 of file BondList.hpp.

◆ size()

auto BondList::size ( ) const
inline

Number of bonds.

Returns
The number of bonds in the list.

Definition at line 208 of file BondList.hpp.

References begin(), and end().

Friends And Related Symbol Documentation

◆ swap

void swap ( BondList lhs,
BondList rhs 
)
friend

Definition at line 223 of file BondList.hpp.


The documentation for this class was generated from the following file: