Thread-safe flyweight pool for chemical Element instances.
More...
#include <Atom.hpp>
|
| static const Element * | defaultElement () noexcept |
| | Returns a shared sentinel empty element instance.
|
| static const Element & | get (std::uint16_t index) noexcept |
| | Lock-free O(1) lookup of an interned Element by its compact 16-bit pool index.
|
| static std::uint16_t | internIndex (const Element &elem) |
| | Interns an Element and returns its compact 16-bit pool index.
|
| static std::uint16_t | internIndex (std::string_view symbol, ElementID elem_id) |
| | Interns an element by symbol and ID and returns its compact 16-bit pool index.
|
| static const Element * | intern (const Element &elem) |
| | Interns an Element into the pool or returns an existing instance.
|
| static const Element * | intern (std::string_view symbol, ElementID elem_id) |
| | Interns an element by symbol and ID into the pool.
|
Thread-safe flyweight pool for chemical Element instances.
◆ defaultElement()
| const Element * correlation::core::ElementPool::defaultElement |
( |
| ) |
|
|
inlinestaticnodiscardnoexcept |
Returns a shared sentinel empty element instance.
- Returns
- Pointer to default element.
◆ get()
| const Element & correlation::core::ElementPool::get |
( |
std::uint16_t | index | ) |
|
|
inlinestaticnodiscardnoexcept |
Lock-free O(1) lookup of an interned Element by its compact 16-bit pool index.
- Parameters
-
- Returns
- Const reference to the interned Element.
◆ intern() [1/2]
| const Element * correlation::core::ElementPool::intern |
( |
const Element & | elem | ) |
|
|
inlinestaticnodiscard |
Interns an Element into the pool or returns an existing instance.
- Parameters
-
- Returns
- Immutable pointer to shared Element.
◆ intern() [2/2]
| const Element * correlation::core::ElementPool::intern |
( |
std::string_view | symbol, |
|
|
ElementID | elem_id ) |
|
inlinestaticnodiscard |
Interns an element by symbol and ID into the pool.
- Parameters
-
| [in] | symbol | Chemical symbol. |
| [in] | elem_id | Element identifier. |
- Returns
- Immutable pointer to shared Element.
◆ internIndex() [1/2]
| std::uint16_t correlation::core::ElementPool::internIndex |
( |
const Element & | elem | ) |
|
|
inlinestaticnodiscard |
Interns an Element and returns its compact 16-bit pool index.
- Parameters
-
- Returns
- Compact pool index (0 for default empty element).
◆ internIndex() [2/2]
| std::uint16_t correlation::core::ElementPool::internIndex |
( |
std::string_view | symbol, |
|
|
ElementID | elem_id ) |
|
inlinestaticnodiscard |
Interns an element by symbol and ID and returns its compact 16-bit pool index.
- Parameters
-
| [in] | symbol | Chemical symbol. |
| [in] | elem_id | Element identifier. |
- Returns
- Compact pool index (0 for default empty element).
◆ table()
| std::array< std::atomic< const Element * >, kMaxElements > & correlation::core::ElementPool::table |
( |
| ) |
|
|
inlinestaticprivatenoexcept |
◆ kMaxElements
| std::size_t correlation::core::ElementPool::kMaxElements = 65536 |
|
staticconstexpr |
The documentation for this class was generated from the following file: