Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create prelude module and move the re-exported items to it #64

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/practice2_d_maxflow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ac_library_rs::MfGraph;
use ac_library_rs::prelude::*;
use std::io::Read;

#[allow(clippy::many_single_char_names)]
Expand Down
2 changes: 1 addition & 1 deletion examples/practice2_j_segment_tree.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ac_library_rs::{Max, Segtree};
use ac_library_rs::prelude::*;
use std::io::Read;

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/practice2_k_range_affine_range_sum.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ac_library_rs::{LazySegtree, MapMonoid, ModInt998244353, Monoid};
use ac_library_rs::prelude::*;
use std::io::Read;

type Mint = ModInt998244353;
Expand Down
2 changes: 1 addition & 1 deletion examples/practice2_l_lazy_segment_tree.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(clippy::many_single_char_names)]
use ac_library_rs::{LazySegtree, MapMonoid, Monoid};
use ac_library_rs::prelude::*;
use std::io::Read;
use std::iter;

Expand Down
13 changes: 5 additions & 8 deletions src/convolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ macro_rules! modulus {
const VALUE: u32 = $name as _;
const HINT_VALUE_IS_PRIME: bool = true;

fn butterfly_cache() -> &'static ::std::thread::LocalKey<::std::cell::RefCell<::std::option::Option<crate::modint::ButterflyCache<Self>>>> {
fn butterfly_cache() -> &'static ::std::thread::LocalKey<::std::cell::RefCell<::std::option::Option<self::modint::ButterflyCache<Self>>>> {
thread_local! {
static BUTTERFLY_CACHE: ::std::cell::RefCell<::std::option::Option<crate::modint::ButterflyCache<$name>>> = ::std::default::Default::default();
static BUTTERFLY_CACHE: ::std::cell::RefCell<::std::option::Option<self::modint::ButterflyCache<$name>>> = ::std::default::Default::default();
}
&BUTTERFLY_CACHE
}
Expand All @@ -19,9 +19,9 @@ macro_rules! modulus {
};
}

use crate::{
use super::{
internal_bit, internal_math,
modint::{ButterflyCache, Modulus, RemEuclidU32, StaticModInt},
modint::{self, ButterflyCache, Modulus, RemEuclidU32, StaticModInt},
};
use std::{
cmp,
Expand Down Expand Up @@ -232,10 +232,7 @@ fn prepare<M: Modulus>() -> ButterflyCache<M> {

#[cfg(test)]
mod tests {
use crate::{
modint::{Mod998244353, Modulus, StaticModInt},
RemEuclidU32,
};
use super::super::modint::{self, Mod998244353, Modulus, RemEuclidU32, StaticModInt};
use rand::{rngs::ThreadRng, Rng as _};
use std::{
convert::{TryFrom, TryInto as _},
Expand Down
2 changes: 1 addition & 1 deletion src/internal_math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub(crate) fn primitive_root(m: i32) -> i32 {
mod tests {
#![allow(clippy::unreadable_literal)]
#![allow(clippy::cognitive_complexity)]
use crate::internal_math::{inv_gcd, is_prime, pow_mod, primitive_root, safe_mod, Barrett};
use super::{inv_gcd, is_prime, pow_mod, primitive_root, safe_mod, Barrett};
use std::collections::HashSet;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/internal_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<T> SimpleQueue<T> {

#[cfg(test)]
mod test {
use crate::internal_queue::SimpleQueue;
use super::SimpleQueue;

#[allow(clippy::cognitive_complexity)]
#[test]
Expand Down
7 changes: 4 additions & 3 deletions src/lazysegtree.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::internal_bit::ceil_pow2;
use crate::Monoid;
use super::internal_bit::ceil_pow2;
use super::segtree::Monoid;

pub trait MapMonoid {
type M: Monoid;
Expand Down Expand Up @@ -314,7 +314,8 @@ where

#[cfg(test)]
mod tests {
use crate::{LazySegtree, MapMonoid, Max};
use super::super::segtree::Max;
use super::{LazySegtree, MapMonoid};

struct MaxAdd;
impl MapMonoid for MaxAdd {
Expand Down
20 changes: 1 addition & 19 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod math;
pub mod maxflow;
pub mod mincostflow;
pub mod modint;
pub mod prelude;
pub mod scc;
pub mod segtree;
pub mod string;
Expand All @@ -16,22 +17,3 @@ pub(crate) mod internal_math;
pub(crate) mod internal_queue;
pub(crate) mod internal_scc;
pub(crate) mod internal_type_traits;

pub use convolution::{convolution, convolution_i64};
pub use dsu::Dsu;
pub use fenwicktree::FenwickTree;
pub use lazysegtree::{LazySegtree, MapMonoid};
pub use math::{crt, floor_sum, inv_mod, pow_mod};
pub use maxflow::{Edge, MfGraph};
pub use mincostflow::MinCostFlowGraph;
pub use modint::{
Barrett, ButterflyCache, DefaultId, DynamicModInt, Id, Mod1000000007, Mod998244353, ModInt,
ModInt1000000007, ModInt998244353, Modulus, RemEuclidU32, StaticModInt,
};
pub use scc::SccGraph;
pub use segtree::{Additive, Max, Min, Monoid, Multiplicative, Segtree};
pub use string::{
lcp_array, lcp_array_arbitrary, suffix_array, suffix_array_arbitrary, suffix_array_manual,
z_algorithm, z_algorithm_arbitrary,
};
pub use twosat::TwoSat;
2 changes: 1 addition & 1 deletion src/math.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::internal_math;
use super::internal_math;

use std::mem::swap;

Expand Down
6 changes: 3 additions & 3 deletions src/maxflow.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(dead_code)]
use crate::internal_queue::SimpleQueue;
use crate::internal_type_traits::Integral;
use super::internal_queue::SimpleQueue;
use super::internal_type_traits::Integral;
use std::cmp::min;
use std::iter;

Expand Down Expand Up @@ -226,7 +226,7 @@ struct _Edge<Cap> {

#[cfg(test)]
mod test {
use crate::{Edge, MfGraph};
use super::{Edge, MfGraph};

#[test]
fn test_max_flow_wikipedia() {
Expand Down
2 changes: 1 addition & 1 deletion src/mincostflow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::internal_type_traits::Integral;
use super::internal_type_traits::Integral;

pub struct MinCostFlowEdge<T> {
pub from: usize,
Expand Down
4 changes: 2 additions & 2 deletions src/modint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! - The type of the argument of `pow` is `u64`, not `i64`.
//! - Modints implement `FromStr` and `Display`. Modints in the original ACL don't have `operator<<` or `operator>>`.

use crate::internal_math;
use super::internal_math;
use std::{
cell::RefCell,
convert::{Infallible, TryInto as _},
Expand Down Expand Up @@ -681,7 +681,7 @@ impl_folding! {

#[cfg(test)]
mod tests {
use crate::modint::ModInt1000000007;
use super::ModInt1000000007;

#[test]
fn static_modint_new() {
Expand Down
20 changes: 20 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pub use super::{
convolution::{convolution, convolution_i64},
dsu::Dsu,
fenwicktree::FenwickTree,
lazysegtree::{LazySegtree, MapMonoid},
math::{crt, floor_sum, inv_mod, pow_mod},
maxflow::{Edge, MfGraph},
mincostflow::MinCostFlowGraph,
modint::{
Barrett, ButterflyCache, DynamicModInt, Id, Mod1000000007, Mod998244353, ModInt,
ModInt1000000007, ModInt998244353, Modulus, StaticModInt,
},
scc::SccGraph,
segtree::{Additive, Max, Min, Monoid, Multiplicative, Segtree},
string::{
lcp_array, lcp_array_arbitrary, suffix_array, suffix_array_arbitrary, suffix_array_manual,
z_algorithm, z_algorithm_arbitrary,
},
twosat::TwoSat,
};
2 changes: 1 addition & 1 deletion src/scc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::internal_scc;
use super::internal_scc;

pub struct SccGraph {
internal: internal_scc::SccGraph,
Expand Down
8 changes: 4 additions & 4 deletions src/segtree.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::internal_bit::ceil_pow2;
use crate::internal_type_traits::{BoundedAbove, BoundedBelow, One, Zero};
use super::internal_bit::ceil_pow2;
use super::internal_type_traits::{BoundedAbove, BoundedBelow, One, Zero};
use std::cmp::{max, min};
use std::convert::Infallible;
use std::marker::PhantomData;
Expand Down Expand Up @@ -238,8 +238,8 @@ where

#[cfg(test)]
mod tests {
use crate::segtree::Max;
use crate::Segtree;
use super::super::segtree::Segtree;
use super::Max;

#[test]
fn test_max_segtree() {
Expand Down
2 changes: 1 addition & 1 deletion src/twosat.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::internal_scc;
use super::internal_scc;

pub struct TwoSat {
n: usize,
Expand Down