Struct BusinessDayGrid
pub(crate) struct BusinessDayGrid {
start: NaiveDate,
days: u32,
business: Vec<u64>,
prefix: Vec<u32>,
}Expand description
Day-number-indexed business-day classification over a fixed date horizon:
a bitset (one bit per day, set ⇔ business day) plus a per-word prefix sum
making “business days in [0, i)” a lookup-and-popcount. Immutable after
construction; ~4.6 KB of bits plus ~2.3 KB of prefix per century calendar.
Fields§
§start: NaiveDate§days: u32Number of days covered, starting at start.
business: Vec<u64>Bit i (word i / 64, bit i % 64) set ⇔ day i is a business day.
prefix: Vec<u32>prefix[w] = number of business days in words [0, w).
Implementations§
§impl BusinessDayGrid
impl BusinessDayGrid
pub(crate) fn build(
start: NaiveDate,
days: u32,
is_business: impl FnMut(NaiveDate) -> bool,
) -> Self
pub(crate) fn build( start: NaiveDate, days: u32, is_business: impl FnMut(NaiveDate) -> bool, ) -> Self
Builds the grid for [start, start + days) from a per-day classifier.
pub(crate) fn end_exclusive(&self) -> NaiveDate
pub(crate) fn end_exclusive(&self) -> NaiveDate
The first day after the covered horizon.
pub(crate) fn day_index(&self, date: NaiveDate) -> Option<u32>
pub(crate) fn day_index(&self, date: NaiveDate) -> Option<u32>
The day index of date, or None outside the horizon.
pub(crate) fn is_business(&self, idx: u32) -> bool
pub(crate) fn is_business(&self, idx: u32) -> bool
Whether day idx (in range) is a business day.
pub(crate) fn rank(&self, idx: u32) -> i64
pub(crate) fn rank(&self, idx: u32) -> i64
Number of business days among days [0, idx); idx may equal days.
pub(crate) fn count_in_horizon(&self, from: NaiveDate, to: NaiveDate) -> i64
pub(crate) fn count_in_horizon(&self, from: NaiveDate, to: NaiveDate) -> i64
Number of business days in the half-open date range [from, to)
intersected with the horizon (from <= to).
Trait Implementations§
§impl Clone for BusinessDayGrid
impl Clone for BusinessDayGrid
§fn clone(&self) -> BusinessDayGrid
fn clone(&self) -> BusinessDayGrid
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more