use pstd::{
Box, String, Vec,
collections::btree_map::CustomTuning,
collections::{BTreeMap, BTreeSet, DefaultHashBuilder, HashMap},
rc::{Rc, RcStr},
};
pub use pstd::localalloc::{Local, Temp};
pub fn local() -> Local {
Local::new()
}
pub fn temp() -> Temp {
Temp::new()
}
pub type TBox<T> = Box<T, Temp>;
pub fn tbox<T>(t: T) -> TBox<T> {
TBox::new_in(t, temp())
}
pub type TVec<T> = Vec<T, Temp>;
pub fn tvec<T>() -> TVec<T> {
TVec::new_in(temp())
}
pub type LBox<T> = Box<T, Local>;
pub fn lbox<T>(t: T) -> LBox<T> {
LBox::new_in(t, local())
}
pub type LRc<T> = Rc<T, Local>;
pub type LRcStr = RcStr<Local>;
pub fn lrc<T>(t: T) -> LRc<T> {
LRc::new_in(t, local())
}
pub fn lrcstr(s: &str) -> LRcStr {
LRcStr::new_in(s, local())
}
pub type LVec<T> = Vec<T, Local>;
pub fn lvec<T>() -> LVec<T> {
LVec::new_in(local())
}
pub fn lvec_with_capacity<T>(capacity: usize) -> LVec<T> {
LVec::with_capacity_in(capacity, local())
}
pub type LBTreeMap<K, V> = BTreeMap<K, V, CustomTuning<Local>>;
pub fn lbtreemap<K, V>() -> LBTreeMap<K, V> {
LBTreeMap::new_in(local())
}
pub type LBTreeSet<T> = BTreeSet<T, CustomTuning<Local>>;
pub fn lbtreeset<T>() -> LBTreeSet<T> {
LBTreeSet::new_in(local())
}
pub type LHashMap<K, V> = HashMap<K, V, DefaultHashBuilder, Local>;
pub fn lhashmap<K, V>() -> LHashMap<K, V> {
LHashMap::new_in(local())
}
#[cfg(feature = "dynbox")]
pub type DBox<T> = LBox<T>;
#[cfg(not(feature = "dynbox"))]
pub type DBox<T> = std::boxed::Box<T>;
#[cfg(feature = "dynbox")]
pub fn dbox<T>(t: T) -> LBox<T> {
LBox::new_in(t, local())
}
#[cfg(not(feature = "dynbox"))]
pub fn dbox<T>(t: T) -> std::boxed::Box<T> {
std::boxed::Box::new(t)
}
pub type LString = String<Local>;
pub fn lstring(s: &str) -> LString {
String::from_str_in(s, local())
}
pub fn lboxstr(s: &str) -> LBox<str> {
LBox::<str>::from_str_in(s, local())
}
pub fn tboxstr(s: &str) -> TBox<str> {
TBox::<str>::from_str_in(s, temp())
}