Class BookPrimitives
java.lang.Object
com.quantfinlib.orderbook.BookPrimitives
The zero-allocation building blocks shared by the hot-lane books
(
HftOrderBook venue-side, marketdata.L3BookBuilder
participant-side): occupancy-bitmap scans and a primitive open-addressing
long→int map with backward-shift deletion. Static methods over
caller-owned arrays — invokestatic with no receiver, so sharing
costs nothing on the hot path and the subtlest code in the library
(the circular probe-order rule in mapRemoveAt(long[], int[], int, int)) exists exactly
once.
Map convention: key 0 is the empty-slot sentinel (both books use
strictly positive ids/refs); capacity is a power of two with
mask = capacity - 1 and load factor ≤ 0.5. Scans return -1 for
"none".
-
Method Summary
Modifier and TypeMethodDescriptionstatic intmapFind(long[] keys, int mask, long key) Slot ofkey, or -1.static voidmapPut(long[] keys, int[] vals, int mask, long key, int value) Inserts into the open-addressing map (caller guarantees the key is absent).static voidmapRemoveAt(long[] keys, int[] vals, int mask, int slot) Backward-shift deletion: re-places every entry of the probe run that follows the hole, so lookups never need tombstones and cancel churn cannot degrade probe lengths over a long session.static longmix(long z) Stafford variant 13 finalizer: cheap, well-mixed long hash.static intnextSetAtOrAbove(long[] bits, int from) Lowest set bit at or abovefrom, or -1.static intnextSetAtOrBelow(long[] bits, int from) Highest set bit at or belowfrom, or -1.
-
Method Details
-
nextSetAtOrAbove
public static int nextSetAtOrAbove(long[] bits, int from) Lowest set bit at or abovefrom, or -1. Bits past the ladder must be clear. -
nextSetAtOrBelow
public static int nextSetAtOrBelow(long[] bits, int from) Highest set bit at or belowfrom, or -1. -
mapPut
public static void mapPut(long[] keys, int[] vals, int mask, long key, int value) Inserts into the open-addressing map (caller guarantees the key is absent). -
mapFind
public static int mapFind(long[] keys, int mask, long key) Slot ofkey, or -1. -
mapRemoveAt
public static void mapRemoveAt(long[] keys, int[] vals, int mask, int slot) Backward-shift deletion: re-places every entry of the probe run that follows the hole, so lookups never need tombstones and cancel churn cannot degrade probe lengths over a long session. -
mix
public static long mix(long z) Stafford variant 13 finalizer: cheap, well-mixed long hash.
-