17. Stdlib and local-lib aligned with the v2 lock
stdlib/ and examples/local-lib/ now follow §16. The calls made while
writing the library against the spec, where the spec left room:
- 17.1
(id, op)is spelledMonoid(id, op). A structure takes a bare operator (SegTree<I, Int>(+, a)) or aMonoid;Monoid<T>.ofturns the first into the second. A bare tuple would need overloading on the argument's shape, which the checker does not have, and the name costs six letters. The cut wrappers (Sum,Max,Min,Prod,Xor,Order,Less,Greater,Semigroup,Group,flip,both,opt,MaxOpt) are deleted, not deprecated.
- 17.2
Fenwicktakes no operation. It is sums over anyTwith+and-(Fenwick<D, T>(),f.sum(range)); an invertible operation of your own goes in aSegTree.
- 17.3
RootedreplacesHld.fold_path(a, b, ds)andapply_path(a, b, mut ds, tag)take any structure overRooted<V>.Pre, so oneSegTreeorLazySegTreeserves paths and subtrees. A climbing stretch is folded top-down and turned withrev();Reversibledefaults to the identity, so only non-commutative values implement it.
- 17.4 Grid helpers are extension fns on
(R, C), imported by name (use std.grid.{adj4});Dir4/Dir8are small structs, since an enum cannot carry methods yet.
- 17.5
ModRis gone. A run-time modulus islet P = pthenMod<P>, the same type as a constant one.
- 17.6 Moved out of
std, intoexamples/local-lib/: the structures listed in T13 (Rope,RangeKth,LiChao,PotentialDsu,Cover,Hom,TwoStackFold,mo, NTT,XorBasis,Frac,Powers,dnc_opt,knuth,Hash2D,Trie,SuffixAutomaton,fold_others,fold_balanced,overlaps,borders,sos_sub/sos_sup), plusBipartiteDsu. Moved the other way, intostd:TwoSat(now instd.graph) and rollback (nowDsu.mark/undo_to).
- 17.7 Not done yet: the payload-enum
FlowGraphnode and a real-valuedbsearch, which wait for enums with payloads andF64ranges in the reference interpreter. The last five T13 structures are now inexamples/local-lib/:Fixed<D>(math/fixed.cp),Tri<D>(ds/tri.cp),Functional<V>(graph/functional.cp),Congruence(math/congruence.cp) andLiChaoArena(ds/li_chao_arena.cp).Fixed<D>hasparseandShow; aread()of one waits for structReadin the reference interpreter.