|
Slick OrderBook 1.1.0
High-Performance C++23 OrderBook Library
|
Container for storing sorted price levels Uses a sorted vector for cache-friendly storage (optimal for < 100 levels) More...
#include <level_container.hpp>
Public Types | |
| using | value_type = PriceLevelL2 |
| using | iterator = typename std::vector< PriceLevelL2 >::iterator |
| using | const_iterator = typename std::vector< PriceLevelL2 >::const_iterator |
| using | Comparator = std::function< bool(const PriceLevelL2 &, const PriceLevelL2 &)> |
Public Member Functions | |
| LevelContainer () | |
| Default constructor (for array initialization on MSVC) | |
| LevelContainer (Side side, std::size_t initial_capacity=32) | |
| Constructor with side and initial capacity. | |
| Side | side () const noexcept |
| Get Side. | |
| std::size_t | size () const noexcept |
| Get number of levels. | |
| bool | empty () const noexcept |
| Check if empty. | |
| const PriceLevelL2 & | operator[] (std::size_t index) const noexcept |
| Get level at index (no bounds checking) | |
| const PriceLevelL2 & | at (std::size_t index) const |
| Get level at index with bounds checking. | |
| const PriceLevelL2 * | best () const noexcept |
| Get best level (first element) | |
| iterator | find (Price price) noexcept |
| Find level by price (binary search) Returns iterator to level with matching price, or end() if not found. | |
| const_iterator | find (Price price) const noexcept |
| Find level by price (binary search, const version) | |
| const PriceLevelL2 * | getLevel (Price price) const noexcept |
| Get level by price (returns pointer or nullptr) | |
| std::pair< iterator, bool > | insertOrUpdate (Price price, Quantity quantity, Timestamp timestamp) |
| Insert or update a level If price exists, updates quantity; otherwise inserts new level Returns iterator to the level and whether insertion occurred. | |
| bool | erase (Price price) noexcept |
| Remove level by price Returns true if level was found and removed. | |
| iterator | erase (iterator it) noexcept |
| Remove level by iterator. | |
| void | clear () noexcept |
| Clear all levels. | |
| void | reserve (std::size_t capacity) |
| Reserve capacity. | |
| std::size_t | capacity () const noexcept |
| Get capacity. | |
| std::vector< PriceLevelL2 > | getLevels (std::size_t depth=0) const |
| Get all levels up to depth. | |
| iterator | begin () noexcept |
| Iterators. | |
| iterator | end () noexcept |
| const_iterator | begin () const noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cbegin () const noexcept |
| const_iterator | cend () const noexcept |
Container for storing sorted price levels Uses a sorted vector for cache-friendly storage (optimal for < 100 levels)
The container is configured at construction time to sort either as bids (descending) or asks (ascending), allowing use in std::array for O(1) side indexing.
Definition at line 20 of file level_container.hpp.
| using slick::orderbook::detail::LevelContainer::Comparator = std::function<bool(const PriceLevelL2&, const PriceLevelL2&)> |
Definition at line 25 of file level_container.hpp.
| using slick::orderbook::detail::LevelContainer::const_iterator = typename std::vector<PriceLevelL2>::const_iterator |
Definition at line 24 of file level_container.hpp.
| using slick::orderbook::detail::LevelContainer::iterator = typename std::vector<PriceLevelL2>::iterator |
Definition at line 23 of file level_container.hpp.
Definition at line 22 of file level_container.hpp.
|
inline |
Default constructor (for array initialization on MSVC)
Definition at line 28 of file level_container.hpp.
References slick::orderbook::Buy.
|
inlineexplicit |
Constructor with side and initial capacity.
| side | Side (Buy = bids/descending, Sell = asks/ascending) |
| initial_capacity | Initial capacity for levels |
Definition at line 33 of file level_container.hpp.
References slick::orderbook::Buy.
|
inline |
Get level at index with bounds checking.
Definition at line 63 of file level_container.hpp.
|
inlinenoexcept |
Definition at line 163 of file level_container.hpp.
|
inlinenoexcept |
Iterators.
Definition at line 161 of file level_container.hpp.
|
inlinenoexcept |
Get best level (first element)
Definition at line 68 of file level_container.hpp.
|
inlinenoexcept |
Get capacity.
Definition at line 147 of file level_container.hpp.
|
inlinenoexcept |
Definition at line 165 of file level_container.hpp.
|
inlinenoexcept |
Definition at line 166 of file level_container.hpp.
|
inlinenoexcept |
Clear all levels.
Definition at line 137 of file level_container.hpp.
|
inlinenoexcept |
Check if empty.
Definition at line 53 of file level_container.hpp.
|
inlinenoexcept |
Definition at line 164 of file level_container.hpp.
|
inlinenoexcept |
Definition at line 162 of file level_container.hpp.
Remove level by iterator.
Definition at line 132 of file level_container.hpp.
|
inlinenoexcept |
Remove level by price Returns true if level was found and removed.
Definition at line 122 of file level_container.hpp.
|
inlinenoexcept |
Find level by price (binary search, const version)
Definition at line 84 of file level_container.hpp.
Find level by price (binary search) Returns iterator to level with matching price, or end() if not found.
Definition at line 74 of file level_container.hpp.
|
inlinenoexcept |
Get level by price (returns pointer or nullptr)
Definition at line 94 of file level_container.hpp.
|
inline |
Get all levels up to depth.
| depth | Maximum number of levels to return (0 = all) |
Definition at line 153 of file level_container.hpp.
|
inline |
Insert or update a level If price exists, updates quantity; otherwise inserts new level Returns iterator to the level and whether insertion occurred.
Definition at line 102 of file level_container.hpp.
|
inlinenoexcept |
Get level at index (no bounds checking)
Definition at line 58 of file level_container.hpp.
|
inline |
Reserve capacity.
Definition at line 142 of file level_container.hpp.
|
inlinenoexcept |
Get Side.
Definition at line 43 of file level_container.hpp.
|
inlinenoexcept |
Get number of levels.
Definition at line 48 of file level_container.hpp.