Skip to main content

dsi_bitstream/utils/
mod.rs

1/*
2 * SPDX-FileCopyrightText: 2023 Sebastiano Vigna
3 * SPDX-FileCopyrightText: 2025 Tommaso Fontana
4 *
5 * SPDX-License-Identifier: Apache-2.0 OR MIT
6 */
7
8//! Helpers and statistics.
9//!
10//! [`CountBitReader`] and [`CountBitWriter`] keep track of the number of bits
11//! read or written to a [`BitRead`] and [`BitWrite`], respectively, optionally
12//! printing on standard error the operations performed on the stream.
13//!
14//! [`DbgBitReader`] and [`DbgBitWriter`] print the operations performed by a
15//! [`BitRead`] or [`BitWrite`] on standard error (only when the `std` feature
16//! is enabled).
17//!
18//! [`CodesStats`] keeps track of the space needed to store a stream of
19//! integers using different codes.
20//!
21//! With the `implied` feature, it also provides
22//! `sample_implied_distribution`, an infinite iterator that returns samples
23//! from the implied distribution of a code, and the helper function
24//! `get_implied_distribution`.
25//!
26//! [`FindChangePoints`] finds, using exponential search, the points where a
27//! non-decreasing monotonic function changes value.
28//!
29//! [`BitRead`]: crate::traits::BitRead
30//! [`BitWrite`]: crate::traits::BitWrite
31
32mod count;
33pub use count::*;
34
35mod dbg_codes;
36pub use dbg_codes::*;
37
38mod find_change;
39pub use find_change::*;
40
41#[cfg(feature = "implied")]
42mod implied;
43#[cfg(feature = "implied")]
44pub use implied::*;
45
46pub mod stats;
47pub use stats::CodesStats;
48#[cfg(feature = "std")]
49pub use stats::CodesStatsWrapper;