ITCHCPP 1.6.1
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
itch::book::OrderIndex Class Reference

A flat, open-addressed hash map from order reference number to pool index, used for O(1) order lookup without per-order heap allocation. More...

#include <order_index.hpp>

Public Member Functions

 OrderIndex ()
 Constructs an empty map with the initial table capacity pre-allocated.
 
auto size () const noexcept -> std::size_t
 The number of stored keys.
 
auto empty () const noexcept -> bool
 Whether the map holds no keys.
 
auto find (std::uint64_t key) const noexcept -> std::uint32_t
 Returns the value for key, or NPOS if absent.
 
auto contains (std::uint64_t key) const noexcept -> bool
 Whether key is present.
 
auto insert (std::uint64_t key, std::uint32_t value) -> void
 Inserts or overwrites the value for key.
 
auto erase (std::uint64_t key) -> void
 Removes key if present, repairing the probe chain in place.
 
auto clear () -> void
 Drops all keys (retaining capacity).
 

Static Public Attributes

static constexpr std::uint32_t NPOS = 0xFFFFFFFFU
 Sentinel returned by find when a key is absent.
 

Detailed Description

A flat, open-addressed hash map from order reference number to pool index, used for O(1) order lookup without per-order heap allocation.

std::unordered_map allocates a node on every insert and frees one on every erase, which on a feed of hundreds of millions of add/delete messages dominates the book's cost and defeats the allocation-free goal. This map stores its slots in a single contiguous vector, probes linearly (cache friendly), and uses backward-shift deletion so heavy add/cancel churn does not accumulate tombstones. It only allocates when it grows.

Definition at line 29 of file order_index.hpp.

Constructor & Destructor Documentation

◆ OrderIndex()

itch::book::OrderIndex::OrderIndex ( )
inline

Constructs an empty map with the initial table capacity pre-allocated.

Definition at line 36 of file order_index.hpp.

Member Function Documentation

◆ size()

auto itch::book::OrderIndex::size ( ) const -> std::size_t
inlinenoexcept

The number of stored keys.

Returns
The count of stored keys.

Definition at line 40 of file order_index.hpp.

◆ empty()

auto itch::book::OrderIndex::empty ( ) const -> bool
inlinenoexcept

Whether the map holds no keys.

Returns
True if the map holds no keys, false otherwise.

Definition at line 44 of file order_index.hpp.

Referenced by itch::book::L3Book::empty().

◆ find()

auto itch::book::OrderIndex::find ( std::uint64_t  key) const -> std::uint32_t
inlinenoexcept

Returns the value for key, or NPOS if absent.

Parameters
keyThe order reference number to look up.
Returns
The stored pool index for key, or NPOS if absent.

Definition at line 49 of file order_index.hpp.

References NPOS.

Referenced by contains().

◆ contains()

auto itch::book::OrderIndex::contains ( std::uint64_t  key) const -> bool
inlinenoexcept

Whether key is present.

Parameters
keyThe order reference number to check.
Returns
True if key is present, false otherwise.

Definition at line 63 of file order_index.hpp.

References find(), and NPOS.

◆ insert()

auto itch::book::OrderIndex::insert ( std::uint64_t  key,
std::uint32_t  value 
) -> void
inline

Inserts or overwrites the value for key.

Parameters
keyThe order reference number to insert or update.
valueThe pool index to associate with key.

Definition at line 70 of file order_index.hpp.

◆ erase()

auto itch::book::OrderIndex::erase ( std::uint64_t  key) -> void
inline

Removes key if present, repairing the probe chain in place.

Parameters
keyThe order reference number to remove.

Definition at line 88 of file order_index.hpp.

◆ clear()

auto itch::book::OrderIndex::clear ( ) -> void
inline

Drops all keys (retaining capacity).

Definition at line 100 of file order_index.hpp.

Member Data Documentation

◆ NPOS

constexpr std::uint32_t itch::book::OrderIndex::NPOS = 0xFFFFFFFFU
staticconstexpr

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