diff --git a/crates.js b/crates.js index 70e7227e..0224dcd0 100644 --- a/crates.js +++ b/crates.js @@ -1 +1 @@ -window.ALL_CRATES = ["accum","avl_tree","bfs","bfs01","binary","bitvec","bsgs","cht","cipolla","convex_hull","dfs","dijkstra_radix_heap","dinic","dual_segtree","elim","erato","euclid","fp","fps","gco","gss","heap_slope_trick","heap_tricks","hld","hopkarp","hungarian","interval_heap","io","lagrange","lazy_segbeats","lazy_segtree","lg","lin_ineq","link_cut_tree","low_link","make_graph","manacher","mincost_flow","monotone_minima","naive_poly","newton","next_permutation","numeric_search","partially_persistent_union_find","radix_heap","randtools","rational","rb","rbtree","riff","scc","segbeats","segbeats_task3","segtree","skew_heap","snippetter","sparse_table","splay_tree","suffix_array","swag","tree_fold","trial","trie","two_sat","uf_checklist","union_find","veb","vec_lines","wavelet_matrix","z_algo","zeta"]; \ No newline at end of file +window.ALL_CRATES = ["accum","avl_tree","bfs","bfs01","binary","bitvec","bsgs","cht","cipolla","convex_hull","dfs","dijkstra_radix_heap","dinic","dual_segtree","elim","erato","euclid","fp","fps","gco","graph","gss","heap_slope_trick","heap_tricks","hld","hopkarp","hungarian","interval_heap","io","lagrange","lazy_segbeats","lazy_segtree","lg","lin_ineq","link_cut_tree","low_link","make_graph","manacher","mincost_flow","monotone_minima","naive_poly","newton","next_permutation","numeric_search","partially_persistent_union_find","radix_heap","randtools","rational","rb","rbtree","riff","segbeats","segbeats_task3","segtree","skew_heap","snippetter","sparse_table","splay_tree","suffix_array","swag","tree_fold","trial","trie","uf_checklist","union_find","veb","vec_lines","wavelet_matrix","z_algo","zeta"]; \ No newline at end of file diff --git a/dependencies.js b/dependencies.js index 12cc89ff..509ff181 100644 --- a/dependencies.js +++ b/dependencies.js @@ -1 +1 @@ -dependencies = {"zeta":{"dependencies":[],"tags":[]},"skew-heap":{"dependencies":[],"tags":[]},"dfs":{"dependencies":[],"tags":[]},"swag":{"dependencies":[],"tags":[]},"euclid":{"dependencies":[],"tags":[]},"segtree":{"dependencies":[],"tags":[]},"radix_heap":{"dependencies":[],"tags":[]},"make_graph":{"dependencies":[],"tags":[]},"hopkarp":{"dependencies":[],"tags":[]},"next_permutation":{"dependencies":[],"tags":[]},"lagrange":{"dependencies":["fp"],"tags":[]},"manacher":{"dependencies":[],"tags":[]},"wavelet_matrix":{"dependencies":[],"tags":[]},"convex_hull":{"dependencies":[],"tags":[]},"accum":{"dependencies":[],"tags":[]},"partially_persistent_union_find":{"dependencies":[],"tags":[]},"splay_tree":{"dependencies":[],"tags":[]},"hungarian":{"dependencies":[],"tags":[]},"monotone_minima":{"dependencies":[],"tags":[]},"fps":{"dependencies":["fp"],"tags":[]},"rbtree":{"dependencies":[],"tags":[]},"io":{"dependencies":[],"tags":[]},"avl_tree":{"dependencies":[],"tags":[]},"randtools":{"dependencies":[],"tags":[]},"lin_ineq":{"dependencies":[],"tags":[]},"low_link":{"dependencies":[],"tags":[]},"segbeats_task3":{"dependencies":[],"tags":[]},"bitvec":{"dependencies":[],"tags":[]},"z_algo":{"dependencies":[],"tags":[]},"numeric_search":{"dependencies":[],"tags":[]},"trial":{"dependencies":[],"tags":[]},"rational":{"dependencies":[],"tags":[]},"tree_fold":{"dependencies":[],"tags":[]},"trie":{"dependencies":[],"tags":[]},"rb":{"dependencies":[],"tags":[]},"naive_poly":{"dependencies":[],"tags":[]},"uf_checklist":{"dependencies":["union_find"],"tags":[]},"elim":{"dependencies":[],"tags":[]},"link_cut_tree":{"dependencies":[],"tags":[]},"binary":{"dependencies":[],"tags":[]},"mincost_flow":{"dependencies":[],"tags":[]},"dinic":{"dependencies":[],"tags":[]},"gss":{"dependencies":[],"tags":[]},"newton":{"dependencies":[],"tags":[]},"sparse_table":{"dependencies":[],"tags":[]},"lazy_segbeats":{"dependencies":[],"tags":[]},"veb":{"dependencies":[],"tags":[]},"dual_segtree":{"dependencies":[],"tags":[]},"lg":{"dependencies":[],"tags":[]},"interval_heap":{"dependencies":[],"tags":[]},"cipolla":{"dependencies":[],"tags":[]},"dijkstra_radix_heap":{"dependencies":["radix_heap"],"tags":[]},"erato":{"dependencies":[],"tags":[]},"hld":{"dependencies":[],"tags":[]},"bfs":{"dependencies":[],"tags":[]},"gco":{"dependencies":["dinic"],"tags":[]},"heap_slope_trick":{"dependencies":[],"tags":[]},"two_sat":{"dependencies":["scc"],"tags":[]},"riff":{"dependencies":[],"tags":[]},"vec_lines":{"dependencies":[],"tags":[]},"cht":{"dependencies":[],"tags":[]},"segbeats":{"dependencies":[],"tags":[]},"union_find":{"dependencies":[],"tags":[]},"scc":{"dependencies":[],"tags":[]},"suffix_array":{"dependencies":[],"tags":[]},"lazy_segtree":{"dependencies":[],"tags":[]},"bfs01":{"dependencies":[],"tags":[]},"bsgs":{"dependencies":[],"tags":[]},"fp":{"dependencies":[],"tags":[]},"heap_tricks":{"dependencies":[],"tags":[]}} \ No newline at end of file +dependencies = {"wavelet_matrix":{"dependencies":[],"tags":[]},"make_graph":{"dependencies":[],"tags":[]},"rb":{"dependencies":[],"tags":[]},"gco":{"dependencies":["dinic"],"tags":[]},"partially_persistent_union_find":{"dependencies":[],"tags":[]},"rbtree":{"dependencies":[],"tags":[]},"mincost_flow":{"dependencies":[],"tags":[]},"binary":{"dependencies":[],"tags":[]},"interval_heap":{"dependencies":[],"tags":[]},"trial":{"dependencies":[],"tags":[]},"riff":{"dependencies":[],"tags":[]},"fp":{"dependencies":[],"tags":[]},"monotone_minima":{"dependencies":[],"tags":[]},"segtree":{"dependencies":[],"tags":[]},"dinic":{"dependencies":[],"tags":[]},"cht":{"dependencies":[],"tags":[]},"lin_ineq":{"dependencies":[],"tags":[]},"veb":{"dependencies":[],"tags":[]},"hopkarp":{"dependencies":[],"tags":[]},"dijkstra_radix_heap":{"dependencies":["radix_heap"],"tags":[]},"trie":{"dependencies":[],"tags":[]},"link_cut_tree":{"dependencies":[],"tags":[]},"rational":{"dependencies":[],"tags":[]},"gss":{"dependencies":[],"tags":[]},"heap_slope_trick":{"dependencies":[],"tags":[]},"bsgs":{"dependencies":[],"tags":[]},"swag":{"dependencies":[],"tags":[]},"lazy_segtree":{"dependencies":[],"tags":[]},"sparse_table":{"dependencies":[],"tags":[]},"uf_checklist":{"dependencies":["union_find"],"tags":[]},"suffix_array":{"dependencies":[],"tags":[]},"bfs01":{"dependencies":[],"tags":[]},"zeta":{"dependencies":[],"tags":[]},"naive_poly":{"dependencies":[],"tags":[]},"dual_segtree":{"dependencies":[],"tags":[]},"radix_heap":{"dependencies":[],"tags":[]},"fps":{"dependencies":["fp"],"tags":[]},"lazy_segbeats":{"dependencies":[],"tags":[]},"lagrange":{"dependencies":["fp"],"tags":[]},"euclid":{"dependencies":[],"tags":[]},"lg":{"dependencies":[],"tags":[]},"avl_tree":{"dependencies":[],"tags":[]},"splay_tree":{"dependencies":[],"tags":[]},"bitvec":{"dependencies":[],"tags":[]},"elim":{"dependencies":[],"tags":[]},"next_permutation":{"dependencies":[],"tags":[]},"erato":{"dependencies":[],"tags":[]},"hungarian":{"dependencies":[],"tags":[]},"heap_tricks":{"dependencies":[],"tags":[]},"low_link":{"dependencies":[],"tags":[]},"cipolla":{"dependencies":[],"tags":[]},"union_find":{"dependencies":[],"tags":[]},"manacher":{"dependencies":[],"tags":[]},"io":{"dependencies":[],"tags":[]},"hld":{"dependencies":[],"tags":[]},"segbeats":{"dependencies":[],"tags":[]},"tree_fold":{"dependencies":[],"tags":[]},"convex_hull":{"dependencies":[],"tags":[]},"graph":{"dependencies":[],"tags":[]},"randtools":{"dependencies":[],"tags":[]},"accum":{"dependencies":[],"tags":[]},"skew-heap":{"dependencies":[],"tags":[]},"vec_lines":{"dependencies":[],"tags":[]},"z_algo":{"dependencies":[],"tags":[]},"bfs":{"dependencies":[],"tags":[]},"numeric_search":{"dependencies":[],"tags":[]},"newton":{"dependencies":[],"tags":[]},"segbeats_task3":{"dependencies":[],"tags":[]},"dfs":{"dependencies":[],"tags":[]}} \ No newline at end of file diff --git a/graph/all.html b/graph/all.html new file mode 100644 index 00000000..b57a4ef5 --- /dev/null +++ b/graph/all.html @@ -0,0 +1,35 @@ +List of all items in this crate
+ + + + + +

List of all items

Structs

Functions

\ No newline at end of file diff --git a/graph/csr/struct.Csr.html b/graph/csr/struct.Csr.html new file mode 100644 index 00000000..dd725d74 --- /dev/null +++ b/graph/csr/struct.Csr.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../graph/struct.Csr.html...

+ + + \ No newline at end of file diff --git a/graph/csr/struct.Iter.html b/graph/csr/struct.Iter.html new file mode 100644 index 00000000..43280e0f --- /dev/null +++ b/graph/csr/struct.Iter.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../graph/struct.Iter.html...

+ + + \ No newline at end of file diff --git a/graph/csr/struct.LastMut.html b/graph/csr/struct.LastMut.html new file mode 100644 index 00000000..e8f87ee9 --- /dev/null +++ b/graph/csr/struct.LastMut.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../graph/struct.LastMut.html...

+ + + \ No newline at end of file diff --git a/graph/fn.kosaraju.html b/graph/fn.kosaraju.html new file mode 100644 index 00000000..222687a5 --- /dev/null +++ b/graph/fn.kosaraju.html @@ -0,0 +1,46 @@ +kosaraju in graph - Rust
+ + + + + +

Function graph::kosaraju

source ·
pub fn kosaraju(n: usize, edges: &[(usize, usize)]) -> Csr<usize>
Expand description

Returns the strongly connected components of a directed graph.

+

Examples

+
use graph::kosaraju;
+let n = 6;
+let edges = [ (1, 4), (5, 2), (3, 0), (5, 5), (4, 1), (0, 3), (4, 2)];
+let scc = kosaraju(n, &edges);
+assert_eq!(scc.len(), 4);
+assert_eq!(scc[0], [5]);
+assert_eq!(scc[1], [1, 4]);
+assert_eq!(scc[2], [2]);
+assert_eq!(scc[3], [0, 3]);
+
\ No newline at end of file diff --git a/graph/index.html b/graph/index.html new file mode 100644 index 00000000..ccdfab38 --- /dev/null +++ b/graph/index.html @@ -0,0 +1,48 @@ +graph - Rust
+ + + + + +

Crate graph

source ·
Expand description

Kosaraju’s algorithm for strongly connected components

+

Note: CSR (Compressed Sparse Row)

+

Graphs and set partitions are represented in CSR format Csr.

+

Examples

+
use graph::kosaraju;
+let n = 6;
+let edges = [ (1, 4), (5, 2), (3, 0), (5, 5), (4, 1), (0, 3), (4, 2)];
+let scc = kosaraju(n, &edges);
+assert_eq!(scc.len(), 4);
+assert_eq!(scc[0], [5]);
+assert_eq!(scc[1], [1, 4]);
+assert_eq!(scc[2], [2]);
+assert_eq!(scc[3], [0, 3]);
+

Structs

  • Compressed Sparse Row format
  • Immutable iterator over rows.
  • Mutable and extendable reference to the last section.

Functions

  • Returns the strongly connected components of a directed graph.
\ No newline at end of file diff --git a/graph/sidebar-items.js b/graph/sidebar-items.js new file mode 100644 index 00000000..311fb80b --- /dev/null +++ b/graph/sidebar-items.js @@ -0,0 +1 @@ +window.SIDEBAR_ITEMS = {"fn":["kosaraju"],"struct":["Csr","Iter","LastMut"]}; \ No newline at end of file diff --git a/graph/struct.Csr.html b/graph/struct.Csr.html new file mode 100644 index 00000000..972cd0a3 --- /dev/null +++ b/graph/struct.Csr.html @@ -0,0 +1,153 @@ +Csr in graph - Rust
+ + + + + +

Struct graph::Csr

source ·
pub struct Csr<T> {
+    pub data: Vec<T>,
+    pub boundary: Vec<usize>,
+}
Expand description

Compressed Sparse Row format

+

Notation

+
    +
  • $X = [x_0, x_1, \dots, x_{n-1}]$: data
  • +
  • $S = [s_0, s_1, \dots, s_{m}]$: boundaries
  • +
+

Invariants

+
    +
  • $0 = s_0 \leq s_1 \leq \dots \leq s_m = n$
  • +
+

Semantics

+

This struct represents a list of lists $A$ of elements of type T.

+

$$ +A_{i, j} = X[s_i + j] +$$

+

Fields§

§data: Vec<T>

$X = [x_0, x_1, \dots, x_{n-1}]$

+
§boundary: Vec<usize>

$S = [s_0, s_1, \dots, s_{m}]$

+

Implementations§

source§

impl<T> Csr<T>

source

pub fn new() -> Self

Create a CSR corrsponding to $A = [\ ]$.

+
Example
+
use graph::Csr;
+let csr: Csr<usize> = Csr::new();
+assert!(csr.is_empty());
+
source

pub fn with_capacity(data_capacity: usize, sections_capacity: usize) -> Self

Create a CSR corrsponding to $A = [\ ]$ with preallocated memory.

+
Example
+
use graph::Csr;
+let csr: Csr<usize> = Csr::with_capacity(10, 5);
+assert!(csr.is_empty());
+
source

pub fn from_sections<A>(rows: &[A]) -> Selfwhere + A: AsRef<[T]>, + T: Clone,

Create a CSR from a list of sections.

+
Example
+
use graph::Csr;
+let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+assert_eq!(csr.section(0), &[1, 2, 3]);
+assert_eq!(csr.section(1), &[4, 5]);
+
source

pub fn section(&self, i: usize) -> &[T]

Get the $i$-th section $A_i$. Alias for &self[i].

+
Example
+
use graph::Csr;
+let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+assert_eq!(csr.section(0), &[1, 2, 3]);
+
source

pub fn section_mut(&mut self, i: usize) -> &mut [T]

Get the mutable $i$-th section $A_i$. Alias for &mut self[i].

+
Example
+
use graph::Csr;
+let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+csr.section_mut(0)[0] = 42;
+assert_eq!(csr.section(0), &[42, 2, 3]);
+
source

pub fn is_empty(&self) -> bool

Check if the CSR is empty. (i.e. $A = [\ ]$)

+
Example
+
use graph::Csr;
+let csr = Csr::<()>::new();
+assert!(csr.is_empty());
+
source

pub fn len(&self) -> usize

Get the number of sections $m = |A|$.

+
Example
+
use graph::Csr;
+let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+assert_eq!(csr.len(), 2);
+
source

pub fn flat_len(&self) -> usize

Get the total number of elements in $A$. (i.e. $\sum_{i=0}^{m-1} |A_i|$)

+
Example
+
use graph::Csr;
+let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+assert_eq!(csr.flat_len(), 5);
+
source

pub fn last_mut(&mut self) -> LastMut<'_, T>

Get the mutable and extendable reference to the last section.

+
Example
+
use graph::Csr;
+let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+csr.last_mut().push(42);
+assert_eq!(csr.section(1), &[4, 5, 42]);
+
source

pub fn push_empty(&mut self)

Push an empty section $A_m = [\ ]$.

+
Example
+
use graph::Csr;
+let mut csr = Csr::<()>::new();
+csr.push_empty();
+assert_eq!(csr.section(0), &[]);
+
source

pub fn push_section(&mut self, section: &[T])where + T: Clone,

Clone and push a section.

+
Example
+
use graph::Csr;
+let mut csr = Csr::new();
+csr.push_section(&[1, 2, 3]);
+assert_eq!(csr.section(0), &[1, 2, 3]);
+
source

pub fn iter(&self) -> Iter<'_, T>

Return an iterator over the sections.

+
source

pub fn to_vec(&self) -> Vec<Vec<T>>where + T: Clone,

Copies self into a new Vec<Vec<T>>.

+
Example
+
use graph::Csr;
+let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+assert_eq!(csr.to_vec(), vec![vec![1, 2, 3], vec![4, 5]]);
+
source§

impl Csr<usize>

source

pub fn from_edges(n: usize, edges: &[(usize, usize)]) -> Self

Create a CSR from a list of edges.

+
Example
+
use graph::Csr;
+let csr = Csr::from_edges(3, &[(0, 1), (1, 2), (2, 0)]);
+assert_eq!(csr.to_vec(), vec![vec![1], vec![2], vec![0]]);
+
source

pub fn from_edges_and_rev(n: usize, edges: &[(usize, usize)]) -> (Self, Self)

Create CSRs of $G$ and $G^{\mathrm{op}}$ from a list of edges.

+
Example
+
use graph::Csr;
+let (g, rg) = Csr::from_edges_and_rev(3, &[(0, 1), (1, 2), (2, 0)]);
+assert_eq!(g.to_vec(), vec![vec![1], vec![2], vec![0]]);
+assert_eq!(rg.to_vec(), vec![vec![2], vec![0], vec![1]]);
+

Trait Implementations§

source§

impl<T> Debug for Csr<T>where + T: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Default for Csr<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T, A> FromIterator<A> for Csr<T>where + A: IntoIterator<Item = T>,

source§

fn from_iter<I: IntoIterator<Item = A>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<T> Index<usize> for Csr<T>

§

type Output = [T]

The returned type after indexing.
source§

fn index(&self, i: usize) -> &[T]

Performs the indexing (container[index]) operation. Read more
source§

impl<T> IndexMut<usize> for Csr<T>

source§

fn index_mut(&mut self, i: usize) -> &mut [T]

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'a, T> IntoIterator for &'a Csr<T>

§

type Item = &'a [T]

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Csr<T>where + T: RefUnwindSafe,

§

impl<T> Send for Csr<T>where + T: Send,

§

impl<T> Sync for Csr<T>where + T: Sync,

§

impl<T> Unpin for Csr<T>where + T: Unpin,

§

impl<T> UnwindSafe for Csr<T>where + T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere + T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere + T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere + T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

+
source§

impl<T, U> Into<U> for Twhere + U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
source§

impl<T, U> TryFrom<U> for Twhere + U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere + U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
\ No newline at end of file diff --git a/graph/struct.Iter.html b/graph/struct.Iter.html new file mode 100644 index 00000000..eb54d0f8 --- /dev/null +++ b/graph/struct.Iter.html @@ -0,0 +1,242 @@ +Iter in graph - Rust
+ + + + + +

Struct graph::Iter

source ·
pub struct Iter<'a, T> { /* private fields */ }
Expand description

Immutable iterator over rows.

+

Trait Implementations§

source§

impl<'a, T> DoubleEndedIterator for Iter<'a, T>

source§

fn next_back(&mut self) -> Option<Self::Item>

Removes and returns an element from the end of the iterator. Read more
source§

fn advance_back_by(&mut self, n: usize) -> Result<(), NonZeroUsize>

🔬This is a nightly-only experimental API. (iter_advance_by)
Advances the iterator from the back by n elements. Read more
1.37.0 · source§

fn nth_back(&mut self, n: usize) -> Option<Self::Item>

Returns the nth element from the end of the iterator. Read more
1.27.0 · source§

fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> Rwhere + Self: Sized, + F: FnMut(B, Self::Item) -> R, + R: Try<Output = B>,

This is the reverse version of Iterator::try_fold(): it takes +elements starting from the back of the iterator. Read more
1.27.0 · source§

fn rfold<B, F>(self, init: B, f: F) -> Bwhere + Self: Sized, + F: FnMut(B, Self::Item) -> B,

An iterator method that reduces the iterator’s elements to a single, +final value, starting from the back. Read more
1.27.0 · source§

fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item>where + Self: Sized, + P: FnMut(&Self::Item) -> bool,

Searches for an element of an iterator from the back that satisfies a predicate. Read more
source§

impl<'a, T> ExactSizeIterator for Iter<'a, T>

source§

fn len(&self) -> usize

Returns the exact remaining length of the iterator. Read more
source§

fn is_empty(&self) -> bool

🔬This is a nightly-only experimental API. (exact_size_is_empty)
Returns true if the iterator is empty. Read more
source§

impl<'a, T> Iterator for Iter<'a, T>

§

type Item = &'a [T]

The type of the elements being iterated over.
source§

fn next(&mut self) -> Option<Self::Item>

Advances the iterator and returns the next value. Read more
source§

fn next_chunk<const N: usize>( + &mut self +) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where + Self: Sized,

🔬This is a nightly-only experimental API. (iter_next_chunk)
Advances the iterator and returns an array containing the next N values. Read more
1.0.0 · source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the iterator. Read more
1.0.0 · source§

fn count(self) -> usizewhere + Self: Sized,

Consumes the iterator, counting the number of iterations and returning it. Read more
1.0.0 · source§

fn last(self) -> Option<Self::Item>where + Self: Sized,

Consumes the iterator, returning the last element. Read more
source§

fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize>

🔬This is a nightly-only experimental API. (iter_advance_by)
Advances the iterator by n elements. Read more
1.0.0 · source§

fn nth(&mut self, n: usize) -> Option<Self::Item>

Returns the nth element of the iterator. Read more
1.28.0 · source§

fn step_by(self, step: usize) -> StepBy<Self>where + Self: Sized,

Creates an iterator starting at the same point, but stepping by +the given amount at each iteration. Read more
1.0.0 · source§

fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>where + Self: Sized, + U: IntoIterator<Item = Self::Item>,

Takes two iterators and creates a new iterator over both in sequence. Read more
1.0.0 · source§

fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where + Self: Sized, + U: IntoIterator,

‘Zips up’ two iterators into a single iterator of pairs. Read more
source§

fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>where + Self: Sized, + G: FnMut() -> Self::Item,

🔬This is a nightly-only experimental API. (iter_intersperse)
Creates a new iterator which places an item generated by separator +between adjacent items of the original iterator. Read more
1.0.0 · source§

fn map<B, F>(self, f: F) -> Map<Self, F>where + Self: Sized, + F: FnMut(Self::Item) -> B,

Takes a closure and creates an iterator which calls that closure on each +element. Read more
1.21.0 · source§

fn for_each<F>(self, f: F)where + Self: Sized, + F: FnMut(Self::Item),

Calls a closure on each element of an iterator. Read more
1.0.0 · source§

fn filter<P>(self, predicate: P) -> Filter<Self, P>where + Self: Sized, + P: FnMut(&Self::Item) -> bool,

Creates an iterator which uses a closure to determine if an element +should be yielded. Read more
1.0.0 · source§

fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>where + Self: Sized, + F: FnMut(Self::Item) -> Option<B>,

Creates an iterator that both filters and maps. Read more
1.0.0 · source§

fn enumerate(self) -> Enumerate<Self>where + Self: Sized,

Creates an iterator which gives the current iteration count as well as +the next value. Read more
1.0.0 · source§

fn peekable(self) -> Peekable<Self>where + Self: Sized,

Creates an iterator which can use the peek and peek_mut methods +to look at the next element of the iterator without consuming it. See +their documentation for more information. Read more
1.0.0 · source§

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>where + Self: Sized, + P: FnMut(&Self::Item) -> bool,

Creates an iterator that skips elements based on a predicate. Read more
1.0.0 · source§

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>where + Self: Sized, + P: FnMut(&Self::Item) -> bool,

Creates an iterator that yields elements based on a predicate. Read more
1.57.0 · source§

fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>where + Self: Sized, + P: FnMut(Self::Item) -> Option<B>,

Creates an iterator that both yields elements based on a predicate and maps. Read more
1.0.0 · source§

fn skip(self, n: usize) -> Skip<Self>where + Self: Sized,

Creates an iterator that skips the first n elements. Read more
1.0.0 · source§

fn take(self, n: usize) -> Take<Self>where + Self: Sized,

Creates an iterator that yields the first n elements, or fewer +if the underlying iterator ends sooner. Read more
1.0.0 · source§

fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>where + Self: Sized, + F: FnMut(&mut St, Self::Item) -> Option<B>,

An iterator adapter which, like fold, holds internal state, but +unlike fold, produces a new iterator. Read more
1.0.0 · source§

fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>where + Self: Sized, + U: IntoIterator, + F: FnMut(Self::Item) -> U,

Creates an iterator that works like map, but flattens nested structure. Read more
1.0.0 · source§

fn fuse(self) -> Fuse<Self>where + Self: Sized,

Creates an iterator which ends after the first None. Read more
1.0.0 · source§

fn inspect<F>(self, f: F) -> Inspect<Self, F>where + Self: Sized, + F: FnMut(&Self::Item),

Does something with each element of an iterator, passing the value on. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Selfwhere + Self: Sized,

Borrows an iterator, rather than consuming it. Read more
1.0.0 · source§

fn collect<B>(self) -> Bwhere + B: FromIterator<Self::Item>, + Self: Sized,

Transforms an iterator into a collection. Read more
source§

fn collect_into<E>(self, collection: &mut E) -> &mut Ewhere + E: Extend<Self::Item>, + Self: Sized,

🔬This is a nightly-only experimental API. (iter_collect_into)
Collects all the items from an iterator into a collection. Read more
1.0.0 · source§

fn partition<B, F>(self, f: F) -> (B, B)where + Self: Sized, + B: Default + Extend<Self::Item>, + F: FnMut(&Self::Item) -> bool,

Consumes an iterator, creating two collections from it. Read more
source§

fn partition_in_place<'a, T, P>(self, predicate: P) -> usizewhere + T: 'a, + Self: Sized + DoubleEndedIterator<Item = &'a mut T>, + P: FnMut(&T) -> bool,

🔬This is a nightly-only experimental API. (iter_partition_in_place)
Reorders the elements of this iterator in-place according to the given predicate, +such that all those that return true precede all those that return false. +Returns the number of true elements found. Read more
source§

fn is_partitioned<P>(self, predicate: P) -> boolwhere + Self: Sized, + P: FnMut(Self::Item) -> bool,

🔬This is a nightly-only experimental API. (iter_is_partitioned)
Checks if the elements of this iterator are partitioned according to the given predicate, +such that all those that return true precede all those that return false. Read more
1.27.0 · source§

fn try_fold<B, F, R>(&mut self, init: B, f: F) -> Rwhere + Self: Sized, + F: FnMut(B, Self::Item) -> R, + R: Try<Output = B>,

An iterator method that applies a function as long as it returns +successfully, producing a single, final value. Read more
1.27.0 · source§

fn try_for_each<F, R>(&mut self, f: F) -> Rwhere + Self: Sized, + F: FnMut(Self::Item) -> R, + R: Try<Output = ()>,

An iterator method that applies a fallible function to each item in the +iterator, stopping at the first error and returning that error. Read more
1.0.0 · source§

fn fold<B, F>(self, init: B, f: F) -> Bwhere + Self: Sized, + F: FnMut(B, Self::Item) -> B,

Folds every element into an accumulator by applying an operation, +returning the final result. Read more
1.51.0 · source§

fn reduce<F>(self, f: F) -> Option<Self::Item>where + Self: Sized, + F: FnMut(Self::Item, Self::Item) -> Self::Item,

Reduces the elements to a single one, by repeatedly applying a reducing +operation. Read more
source§

fn try_reduce<F, R>( + &mut self, + f: F +) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryTypewhere + Self: Sized, + F: FnMut(Self::Item, Self::Item) -> R, + R: Try<Output = Self::Item>, + <R as Try>::Residual: Residual<Option<Self::Item>>,

🔬This is a nightly-only experimental API. (iterator_try_reduce)
Reduces the elements to a single one by repeatedly applying a reducing operation. If the +closure returns a failure, the failure is propagated back to the caller immediately. Read more
1.0.0 · source§

fn all<F>(&mut self, f: F) -> boolwhere + Self: Sized, + F: FnMut(Self::Item) -> bool,

Tests if every element of the iterator matches a predicate. Read more
1.0.0 · source§

fn any<F>(&mut self, f: F) -> boolwhere + Self: Sized, + F: FnMut(Self::Item) -> bool,

Tests if any element of the iterator matches a predicate. Read more
1.0.0 · source§

fn find<P>(&mut self, predicate: P) -> Option<Self::Item>where + Self: Sized, + P: FnMut(&Self::Item) -> bool,

Searches for an element of an iterator that satisfies a predicate. Read more
1.30.0 · source§

fn find_map<B, F>(&mut self, f: F) -> Option<B>where + Self: Sized, + F: FnMut(Self::Item) -> Option<B>,

Applies function to the elements of iterator and returns +the first non-none result. Read more
source§

fn try_find<F, R>( + &mut self, + f: F +) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryTypewhere + Self: Sized, + F: FnMut(&Self::Item) -> R, + R: Try<Output = bool>, + <R as Try>::Residual: Residual<Option<Self::Item>>,

🔬This is a nightly-only experimental API. (try_find)
Applies function to the elements of iterator and returns +the first true result or the first error. Read more
1.0.0 · source§

fn position<P>(&mut self, predicate: P) -> Option<usize>where + Self: Sized, + P: FnMut(Self::Item) -> bool,

Searches for an element in an iterator, returning its index. Read more
1.0.0 · source§

fn rposition<P>(&mut self, predicate: P) -> Option<usize>where + P: FnMut(Self::Item) -> bool, + Self: Sized + ExactSizeIterator + DoubleEndedIterator,

Searches for an element in an iterator from the right, returning its +index. Read more
1.6.0 · source§

fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>where + B: Ord, + Self: Sized, + F: FnMut(&Self::Item) -> B,

Returns the element that gives the maximum value from the +specified function. Read more
1.15.0 · source§

fn max_by<F>(self, compare: F) -> Option<Self::Item>where + Self: Sized, + F: FnMut(&Self::Item, &Self::Item) -> Ordering,

Returns the element that gives the maximum value with respect to the +specified comparison function. Read more
1.6.0 · source§

fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>where + B: Ord, + Self: Sized, + F: FnMut(&Self::Item) -> B,

Returns the element that gives the minimum value from the +specified function. Read more
1.15.0 · source§

fn min_by<F>(self, compare: F) -> Option<Self::Item>where + Self: Sized, + F: FnMut(&Self::Item, &Self::Item) -> Ordering,

Returns the element that gives the minimum value with respect to the +specified comparison function. Read more
1.0.0 · source§

fn rev(self) -> Rev<Self>where + Self: Sized + DoubleEndedIterator,

Reverses an iterator’s direction. Read more
1.0.0 · source§

fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where + FromA: Default + Extend<A>, + FromB: Default + Extend<B>, + Self: Sized + Iterator<Item = (A, B)>,

Converts an iterator of pairs into a pair of containers. Read more
1.36.0 · source§

fn copied<'a, T>(self) -> Copied<Self>where + T: 'a + Copy, + Self: Sized + Iterator<Item = &'a T>,

Creates an iterator which copies all of its elements. Read more
1.0.0 · source§

fn cloned<'a, T>(self) -> Cloned<Self>where + T: 'a + Clone, + Self: Sized + Iterator<Item = &'a T>,

Creates an iterator which clones all of its elements. Read more
source§

fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where + Self: Sized,

🔬This is a nightly-only experimental API. (iter_array_chunks)
Returns an iterator over N elements of the iterator at a time. Read more
1.11.0 · source§

fn sum<S>(self) -> Swhere + Self: Sized, + S: Sum<Self::Item>,

Sums the elements of an iterator. Read more
1.11.0 · source§

fn product<P>(self) -> Pwhere + Self: Sized, + P: Product<Self::Item>,

Iterates over the entire iterator, multiplying all the elements Read more
source§

fn cmp_by<I, F>(self, other: I, cmp: F) -> Orderingwhere + Self: Sized, + I: IntoIterator, + F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,

🔬This is a nightly-only experimental API. (iter_order_by)
Lexicographically compares the elements of this Iterator with those +of another with respect to the specified comparison function. Read more
1.5.0 · source§

fn partial_cmp<I>(self, other: I) -> Option<Ordering>where + I: IntoIterator, + Self::Item: PartialOrd<<I as IntoIterator>::Item>, + Self: Sized,

Lexicographically compares the PartialOrd elements of +this Iterator with those of another. The comparison works like short-circuit +evaluation, returning a result without comparing the remaining elements. +As soon as an order can be determined, the evaluation stops and a result is returned. Read more
source§

fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where + Self: Sized, + I: IntoIterator, + F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,

🔬This is a nightly-only experimental API. (iter_order_by)
Lexicographically compares the elements of this Iterator with those +of another with respect to the specified comparison function. Read more
1.5.0 · source§

fn eq<I>(self, other: I) -> boolwhere + I: IntoIterator, + Self::Item: PartialEq<<I as IntoIterator>::Item>, + Self: Sized,

Determines if the elements of this Iterator are equal to those of +another. Read more
source§

fn eq_by<I, F>(self, other: I, eq: F) -> boolwhere + Self: Sized, + I: IntoIterator, + F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,

🔬This is a nightly-only experimental API. (iter_order_by)
Determines if the elements of this Iterator are equal to those of +another with respect to the specified equality function. Read more
1.5.0 · source§

fn ne<I>(self, other: I) -> boolwhere + I: IntoIterator, + Self::Item: PartialEq<<I as IntoIterator>::Item>, + Self: Sized,

Determines if the elements of this Iterator are not equal to those of +another. Read more
1.5.0 · source§

fn lt<I>(self, other: I) -> boolwhere + I: IntoIterator, + Self::Item: PartialOrd<<I as IntoIterator>::Item>, + Self: Sized,

Determines if the elements of this Iterator are lexicographically +less than those of another. Read more
1.5.0 · source§

fn le<I>(self, other: I) -> boolwhere + I: IntoIterator, + Self::Item: PartialOrd<<I as IntoIterator>::Item>, + Self: Sized,

Determines if the elements of this Iterator are lexicographically +less or equal to those of another. Read more
1.5.0 · source§

fn gt<I>(self, other: I) -> boolwhere + I: IntoIterator, + Self::Item: PartialOrd<<I as IntoIterator>::Item>, + Self: Sized,

Determines if the elements of this Iterator are lexicographically +greater than those of another. Read more
1.5.0 · source§

fn ge<I>(self, other: I) -> boolwhere + I: IntoIterator, + Self::Item: PartialOrd<<I as IntoIterator>::Item>, + Self: Sized,

Determines if the elements of this Iterator are lexicographically +greater than or equal to those of another. Read more
source§

fn is_sorted_by<F>(self, compare: F) -> boolwhere + Self: Sized, + F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,

🔬This is a nightly-only experimental API. (is_sorted)
Checks if the elements of this iterator are sorted using the given comparator function. Read more
source§

fn is_sorted_by_key<F, K>(self, f: F) -> boolwhere + Self: Sized, + F: FnMut(Self::Item) -> K, + K: PartialOrd<K>,

🔬This is a nightly-only experimental API. (is_sorted)
Checks if the elements of this iterator are sorted using the given key extraction +function. Read more

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for Iter<'a, T>where + T: RefUnwindSafe,

§

impl<'a, T> Send for Iter<'a, T>where + T: Sync,

§

impl<'a, T> Sync for Iter<'a, T>where + T: Sync,

§

impl<'a, T> Unpin for Iter<'a, T>

§

impl<'a, T> UnwindSafe for Iter<'a, T>where + T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere + T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere + T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere + T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

+
source§

impl<T, U> Into<U> for Twhere + U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
source§

impl<I> IntoIterator for Iwhere + I: Iterator,

§

type Item = <I as Iterator>::Item

The type of the elements being iterated over.
§

type IntoIter = I

Which kind of iterator are we turning this into?
const: unstable · source§

fn into_iter(self) -> I

Creates an iterator from a value. Read more
source§

impl<T, U> TryFrom<U> for Twhere + U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere + U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
\ No newline at end of file diff --git a/graph/struct.LastMut.html b/graph/struct.LastMut.html new file mode 100644 index 00000000..7d29ebbc --- /dev/null +++ b/graph/struct.LastMut.html @@ -0,0 +1,2300 @@ +LastMut in graph - Rust
+ + + + + +

Struct graph::LastMut

source ·
pub struct LastMut<'a, T> { /* private fields */ }
Expand description

Mutable and extendable reference to the last section.

+

Implementations§

source§

impl<'a, T> LastMut<'a, T>

source

pub fn push(self, x: T)

Push an element to the last section.

+
Example
+
use graph::Csr;
+let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+csr.last_mut().push(42);
+assert_eq!(csr.section(1), &[4, 5, 42]);
+
source

pub fn extend<I: IntoIterator<Item = T>>(self, iter: I)

Extend the last section with an iterator.

+
Example
+
use graph::Csr;
+let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+csr.last_mut().extend(vec![42, 43]);
+assert_eq!(csr.section(1), &[4, 5, 42, 43]);
+
source

pub fn extend_from_slice(&mut self, slice: &[T])where + T: Clone,

Copy elements from a slice to the last section.

+
Example
+
use graph::Csr;
+let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+csr.last_mut().extend_from_slice(&[42, 43]);
+assert_eq!(csr.section(1), &[4, 5, 42, 43]);
+

Methods from Deref<Target = [T]>§

1.0.0 · source

pub fn len(&self) -> usize

Returns the number of elements in the slice.

+
Examples
+
let a = [1, 2, 3];
+assert_eq!(a.len(), 3);
+
1.0.0 · source

pub fn is_empty(&self) -> bool

Returns true if the slice has a length of 0.

+
Examples
+
let a = [1, 2, 3];
+assert!(!a.is_empty());
+
1.0.0 · source

pub fn first(&self) -> Option<&T>

Returns the first element of the slice, or None if it is empty.

+
Examples
+
let v = [10, 40, 30];
+assert_eq!(Some(&10), v.first());
+
+let w: &[i32] = &[];
+assert_eq!(None, w.first());
+
1.0.0 · source

pub fn first_mut(&mut self) -> Option<&mut T>

Returns a mutable pointer to the first element of the slice, or None if it is empty.

+
Examples
+
let x = &mut [0, 1, 2];
+
+if let Some(first) = x.first_mut() {
+    *first = 5;
+}
+assert_eq!(x, &[5, 1, 2]);
+
1.5.0 · source

pub fn split_first(&self) -> Option<(&T, &[T])>

Returns the first and all the rest of the elements of the slice, or None if it is empty.

+
Examples
+
let x = &[0, 1, 2];
+
+if let Some((first, elements)) = x.split_first() {
+    assert_eq!(first, &0);
+    assert_eq!(elements, &[1, 2]);
+}
+
1.5.0 · source

pub fn split_first_mut(&mut self) -> Option<(&mut T, &mut [T])>

Returns the first and all the rest of the elements of the slice, or None if it is empty.

+
Examples
+
let x = &mut [0, 1, 2];
+
+if let Some((first, elements)) = x.split_first_mut() {
+    *first = 3;
+    elements[0] = 4;
+    elements[1] = 5;
+}
+assert_eq!(x, &[3, 4, 5]);
+
1.5.0 · source

pub fn split_last(&self) -> Option<(&T, &[T])>

Returns the last and all the rest of the elements of the slice, or None if it is empty.

+
Examples
+
let x = &[0, 1, 2];
+
+if let Some((last, elements)) = x.split_last() {
+    assert_eq!(last, &2);
+    assert_eq!(elements, &[0, 1]);
+}
+
1.5.0 · source

pub fn split_last_mut(&mut self) -> Option<(&mut T, &mut [T])>

Returns the last and all the rest of the elements of the slice, or None if it is empty.

+
Examples
+
let x = &mut [0, 1, 2];
+
+if let Some((last, elements)) = x.split_last_mut() {
+    *last = 3;
+    elements[0] = 4;
+    elements[1] = 5;
+}
+assert_eq!(x, &[4, 5, 3]);
+
1.0.0 · source

pub fn last(&self) -> Option<&T>

Returns the last element of the slice, or None if it is empty.

+
Examples
+
let v = [10, 40, 30];
+assert_eq!(Some(&30), v.last());
+
+let w: &[i32] = &[];
+assert_eq!(None, w.last());
+
1.0.0 · source

pub fn last_mut(&mut self) -> Option<&mut T>

Returns a mutable pointer to the last item in the slice.

+
Examples
+
let x = &mut [0, 1, 2];
+
+if let Some(last) = x.last_mut() {
+    *last = 10;
+}
+assert_eq!(x, &[0, 1, 10]);
+
1.0.0 · source

pub fn get<I>(&self, index: I) -> Option<&<I as SliceIndex<[T]>>::Output>where + I: SliceIndex<[T]>,

Returns a reference to an element or subslice depending on the type of +index.

+
    +
  • If given a position, returns a reference to the element at that +position or None if out of bounds.
  • +
  • If given a range, returns the subslice corresponding to that range, +or None if out of bounds.
  • +
+
Examples
+
let v = [10, 40, 30];
+assert_eq!(Some(&40), v.get(1));
+assert_eq!(Some(&[10, 40][..]), v.get(0..2));
+assert_eq!(None, v.get(3));
+assert_eq!(None, v.get(0..4));
+
1.0.0 · source

pub fn get_mut<I>( + &mut self, + index: I +) -> Option<&mut <I as SliceIndex<[T]>>::Output>where + I: SliceIndex<[T]>,

Returns a mutable reference to an element or subslice depending on the +type of index (see get) or None if the index is out of bounds.

+
Examples
+
let x = &mut [0, 1, 2];
+
+if let Some(elem) = x.get_mut(1) {
+    *elem = 42;
+}
+assert_eq!(x, &[0, 42, 2]);
+
1.0.0 · source

pub unsafe fn get_unchecked<I>( + &self, + index: I +) -> &<I as SliceIndex<[T]>>::Outputwhere + I: SliceIndex<[T]>,

Returns a reference to an element or subslice, without doing bounds +checking.

+

For a safe alternative see get.

+
Safety
+

Calling this method with an out-of-bounds index is undefined behavior +even if the resulting reference is not used.

+
Examples
+
let x = &[1, 2, 4];
+
+unsafe {
+    assert_eq!(x.get_unchecked(1), &2);
+}
+
1.0.0 · source

pub unsafe fn get_unchecked_mut<I>( + &mut self, + index: I +) -> &mut <I as SliceIndex<[T]>>::Outputwhere + I: SliceIndex<[T]>,

Returns a mutable reference to an element or subslice, without doing +bounds checking.

+

For a safe alternative see get_mut.

+
Safety
+

Calling this method with an out-of-bounds index is undefined behavior +even if the resulting reference is not used.

+
Examples
+
let x = &mut [1, 2, 4];
+
+unsafe {
+    let elem = x.get_unchecked_mut(1);
+    *elem = 13;
+}
+assert_eq!(x, &[1, 13, 4]);
+
1.0.0 · source

pub fn as_ptr(&self) -> *const T

Returns a raw pointer to the slice’s buffer.

+

The caller must ensure that the slice outlives the pointer this +function returns, or else it will end up pointing to garbage.

+

The caller must also ensure that the memory the pointer (non-transitively) points to +is never written to (except inside an UnsafeCell) using this pointer or any pointer +derived from it. If you need to mutate the contents of the slice, use as_mut_ptr.

+

Modifying the container referenced by this slice may cause its buffer +to be reallocated, which would also make any pointers to it invalid.

+
Examples
+
let x = &[1, 2, 4];
+let x_ptr = x.as_ptr();
+
+unsafe {
+    for i in 0..x.len() {
+        assert_eq!(x.get_unchecked(i), &*x_ptr.add(i));
+    }
+}
+
1.0.0 · source

pub fn as_mut_ptr(&mut self) -> *mut T

Returns an unsafe mutable pointer to the slice’s buffer.

+

The caller must ensure that the slice outlives the pointer this +function returns, or else it will end up pointing to garbage.

+

Modifying the container referenced by this slice may cause its buffer +to be reallocated, which would also make any pointers to it invalid.

+
Examples
+
let x = &mut [1, 2, 4];
+let x_ptr = x.as_mut_ptr();
+
+unsafe {
+    for i in 0..x.len() {
+        *x_ptr.add(i) += 2;
+    }
+}
+assert_eq!(x, &[3, 4, 6]);
+
1.48.0 · source

pub fn as_ptr_range(&self) -> Range<*const T>

Returns the two raw pointers spanning the slice.

+

The returned range is half-open, which means that the end pointer +points one past the last element of the slice. This way, an empty +slice is represented by two equal pointers, and the difference between +the two pointers represents the size of the slice.

+

See as_ptr for warnings on using these pointers. The end pointer +requires extra caution, as it does not point to a valid element in the +slice.

+

This function is useful for interacting with foreign interfaces which +use two pointers to refer to a range of elements in memory, as is +common in C++.

+

It can also be useful to check if a pointer to an element refers to an +element of this slice:

+ +
let a = [1, 2, 3];
+let x = &a[1] as *const _;
+let y = &5 as *const _;
+
+assert!(a.as_ptr_range().contains(&x));
+assert!(!a.as_ptr_range().contains(&y));
+
1.48.0 · source

pub fn as_mut_ptr_range(&mut self) -> Range<*mut T>

Returns the two unsafe mutable pointers spanning the slice.

+

The returned range is half-open, which means that the end pointer +points one past the last element of the slice. This way, an empty +slice is represented by two equal pointers, and the difference between +the two pointers represents the size of the slice.

+

See as_mut_ptr for warnings on using these pointers. The end +pointer requires extra caution, as it does not point to a valid element +in the slice.

+

This function is useful for interacting with foreign interfaces which +use two pointers to refer to a range of elements in memory, as is +common in C++.

+
1.0.0 · source

pub fn swap(&mut self, a: usize, b: usize)

Swaps two elements in the slice.

+
Arguments
+
    +
  • a - The index of the first element
  • +
  • b - The index of the second element
  • +
+
Panics
+

Panics if a or b are out of bounds.

+
Examples
+
let mut v = ["a", "b", "c", "d", "e"];
+v.swap(2, 4);
+assert!(v == ["a", "b", "e", "d", "c"]);
+
source

pub unsafe fn swap_unchecked(&mut self, a: usize, b: usize)

🔬This is a nightly-only experimental API. (slice_swap_unchecked)

Swaps two elements in the slice, without doing bounds checking.

+

For a safe alternative see swap.

+
Arguments
+
    +
  • a - The index of the first element
  • +
  • b - The index of the second element
  • +
+
Safety
+

Calling this method with an out-of-bounds index is undefined behavior. +The caller has to ensure that a < self.len() and b < self.len().

+
Examples
+
#![feature(slice_swap_unchecked)]
+
+let mut v = ["a", "b", "c", "d"];
+// SAFETY: we know that 1 and 3 are both indices of the slice
+unsafe { v.swap_unchecked(1, 3) };
+assert!(v == ["a", "d", "c", "b"]);
+
1.0.0 · source

pub fn reverse(&mut self)

Reverses the order of elements in the slice, in place.

+
Examples
+
let mut v = [1, 2, 3];
+v.reverse();
+assert!(v == [3, 2, 1]);
+
1.0.0 · source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the slice.

+

The iterator yields all items from start to end.

+
Examples
+
let x = &[1, 2, 4];
+let mut iterator = x.iter();
+
+assert_eq!(iterator.next(), Some(&1));
+assert_eq!(iterator.next(), Some(&2));
+assert_eq!(iterator.next(), Some(&4));
+assert_eq!(iterator.next(), None);
+
1.0.0 · source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Returns an iterator that allows modifying each value.

+

The iterator yields all items from start to end.

+
Examples
+
let x = &mut [1, 2, 4];
+for elem in x.iter_mut() {
+    *elem += 2;
+}
+assert_eq!(x, &[3, 4, 6]);
+
1.0.0 · source

pub fn windows(&self, size: usize) -> Windows<'_, T>

Returns an iterator over all contiguous windows of length +size. The windows overlap. If the slice is shorter than +size, the iterator returns no values.

+
Panics
+

Panics if size is 0.

+
Examples
+
let slice = ['r', 'u', 's', 't'];
+let mut iter = slice.windows(2);
+assert_eq!(iter.next().unwrap(), &['r', 'u']);
+assert_eq!(iter.next().unwrap(), &['u', 's']);
+assert_eq!(iter.next().unwrap(), &['s', 't']);
+assert!(iter.next().is_none());
+

If the slice is shorter than size:

+ +
let slice = ['f', 'o', 'o'];
+let mut iter = slice.windows(4);
+assert!(iter.next().is_none());
+

There’s no windows_mut, as that existing would let safe code violate the +“only one &mut at a time to the same thing” rule. However, you can sometimes +use Cell::as_slice_of_cells in +conjunction with windows to accomplish something similar:

+ +
use std::cell::Cell;
+
+let mut array = ['R', 'u', 's', 't', ' ', '2', '0', '1', '5'];
+let slice = &mut array[..];
+let slice_of_cells: &[Cell<char>] = Cell::from_mut(slice).as_slice_of_cells();
+for w in slice_of_cells.windows(3) {
+    Cell::swap(&w[0], &w[2]);
+}
+assert_eq!(array, ['s', 't', ' ', '2', '0', '1', '5', 'u', 'R']);
+
1.0.0 · source

pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T>

Returns an iterator over chunk_size elements of the slice at a time, starting at the +beginning of the slice.

+

The chunks are slices and do not overlap. If chunk_size does not divide the length of the +slice, then the last chunk will not have length chunk_size.

+

See chunks_exact for a variant of this iterator that returns chunks of always exactly +chunk_size elements, and rchunks for the same iterator but starting at the end of the +slice.

+
Panics
+

Panics if chunk_size is 0.

+
Examples
+
let slice = ['l', 'o', 'r', 'e', 'm'];
+let mut iter = slice.chunks(2);
+assert_eq!(iter.next().unwrap(), &['l', 'o']);
+assert_eq!(iter.next().unwrap(), &['r', 'e']);
+assert_eq!(iter.next().unwrap(), &['m']);
+assert!(iter.next().is_none());
+
1.0.0 · source

pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T>

Returns an iterator over chunk_size elements of the slice at a time, starting at the +beginning of the slice.

+

The chunks are mutable slices, and do not overlap. If chunk_size does not divide the +length of the slice, then the last chunk will not have length chunk_size.

+

See chunks_exact_mut for a variant of this iterator that returns chunks of always +exactly chunk_size elements, and rchunks_mut for the same iterator but starting at +the end of the slice.

+
Panics
+

Panics if chunk_size is 0.

+
Examples
+
let v = &mut [0, 0, 0, 0, 0];
+let mut count = 1;
+
+for chunk in v.chunks_mut(2) {
+    for elem in chunk.iter_mut() {
+        *elem += count;
+    }
+    count += 1;
+}
+assert_eq!(v, &[1, 1, 2, 2, 3]);
+
1.31.0 · source

pub fn chunks_exact(&self, chunk_size: usize) -> ChunksExact<'_, T>

Returns an iterator over chunk_size elements of the slice at a time, starting at the +beginning of the slice.

+

The chunks are slices and do not overlap. If chunk_size does not divide the length of the +slice, then the last up to chunk_size-1 elements will be omitted and can be retrieved +from the remainder function of the iterator.

+

Due to each chunk having exactly chunk_size elements, the compiler can often optimize the +resulting code better than in the case of chunks.

+

See chunks for a variant of this iterator that also returns the remainder as a smaller +chunk, and rchunks_exact for the same iterator but starting at the end of the slice.

+
Panics
+

Panics if chunk_size is 0.

+
Examples
+
let slice = ['l', 'o', 'r', 'e', 'm'];
+let mut iter = slice.chunks_exact(2);
+assert_eq!(iter.next().unwrap(), &['l', 'o']);
+assert_eq!(iter.next().unwrap(), &['r', 'e']);
+assert!(iter.next().is_none());
+assert_eq!(iter.remainder(), &['m']);
+
1.31.0 · source

pub fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<'_, T>

Returns an iterator over chunk_size elements of the slice at a time, starting at the +beginning of the slice.

+

The chunks are mutable slices, and do not overlap. If chunk_size does not divide the +length of the slice, then the last up to chunk_size-1 elements will be omitted and can be +retrieved from the into_remainder function of the iterator.

+

Due to each chunk having exactly chunk_size elements, the compiler can often optimize the +resulting code better than in the case of chunks_mut.

+

See chunks_mut for a variant of this iterator that also returns the remainder as a +smaller chunk, and rchunks_exact_mut for the same iterator but starting at the end of +the slice.

+
Panics
+

Panics if chunk_size is 0.

+
Examples
+
let v = &mut [0, 0, 0, 0, 0];
+let mut count = 1;
+
+for chunk in v.chunks_exact_mut(2) {
+    for elem in chunk.iter_mut() {
+        *elem += count;
+    }
+    count += 1;
+}
+assert_eq!(v, &[1, 1, 2, 2, 0]);
+
source

pub unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]]

🔬This is a nightly-only experimental API. (slice_as_chunks)

Splits the slice into a slice of N-element arrays, +assuming that there’s no remainder.

+
Safety
+

This may only be called when

+
    +
  • The slice splits exactly into N-element chunks (aka self.len() % N == 0).
  • +
  • N != 0.
  • +
+
Examples
+
#![feature(slice_as_chunks)]
+let slice: &[char] = &['l', 'o', 'r', 'e', 'm', '!'];
+let chunks: &[[char; 1]] =
+    // SAFETY: 1-element chunks never have remainder
+    unsafe { slice.as_chunks_unchecked() };
+assert_eq!(chunks, &[['l'], ['o'], ['r'], ['e'], ['m'], ['!']]);
+let chunks: &[[char; 3]] =
+    // SAFETY: The slice length (6) is a multiple of 3
+    unsafe { slice.as_chunks_unchecked() };
+assert_eq!(chunks, &[['l', 'o', 'r'], ['e', 'm', '!']]);
+
+// These would be unsound:
+// let chunks: &[[_; 5]] = slice.as_chunks_unchecked() // The slice length is not a multiple of 5
+// let chunks: &[[_; 0]] = slice.as_chunks_unchecked() // Zero-length chunks are never allowed
+
source

pub fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T])

🔬This is a nightly-only experimental API. (slice_as_chunks)

Splits the slice into a slice of N-element arrays, +starting at the beginning of the slice, +and a remainder slice with length strictly less than N.

+
Panics
+

Panics if N is 0. This check will most probably get changed to a compile time +error before this method gets stabilized.

+
Examples
+
#![feature(slice_as_chunks)]
+let slice = ['l', 'o', 'r', 'e', 'm'];
+let (chunks, remainder) = slice.as_chunks();
+assert_eq!(chunks, &[['l', 'o'], ['r', 'e']]);
+assert_eq!(remainder, &['m']);
+

If you expect the slice to be an exact multiple, you can combine +let-else with an empty slice pattern:

+ +
#![feature(slice_as_chunks)]
+let slice = ['R', 'u', 's', 't'];
+let (chunks, []) = slice.as_chunks::<2>() else {
+    panic!("slice didn't have even length")
+};
+assert_eq!(chunks, &[['R', 'u'], ['s', 't']]);
+
source

pub fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]])

🔬This is a nightly-only experimental API. (slice_as_chunks)

Splits the slice into a slice of N-element arrays, +starting at the end of the slice, +and a remainder slice with length strictly less than N.

+
Panics
+

Panics if N is 0. This check will most probably get changed to a compile time +error before this method gets stabilized.

+
Examples
+
#![feature(slice_as_chunks)]
+let slice = ['l', 'o', 'r', 'e', 'm'];
+let (remainder, chunks) = slice.as_rchunks();
+assert_eq!(remainder, &['l']);
+assert_eq!(chunks, &[['o', 'r'], ['e', 'm']]);
+
source

pub fn array_chunks<const N: usize>(&self) -> ArrayChunks<'_, T, N>

🔬This is a nightly-only experimental API. (array_chunks)

Returns an iterator over N elements of the slice at a time, starting at the +beginning of the slice.

+

The chunks are array references and do not overlap. If N does not divide the +length of the slice, then the last up to N-1 elements will be omitted and can be +retrieved from the remainder function of the iterator.

+

This method is the const generic equivalent of chunks_exact.

+
Panics
+

Panics if N is 0. This check will most probably get changed to a compile time +error before this method gets stabilized.

+
Examples
+
#![feature(array_chunks)]
+let slice = ['l', 'o', 'r', 'e', 'm'];
+let mut iter = slice.array_chunks();
+assert_eq!(iter.next().unwrap(), &['l', 'o']);
+assert_eq!(iter.next().unwrap(), &['r', 'e']);
+assert!(iter.next().is_none());
+assert_eq!(iter.remainder(), &['m']);
+
source

pub unsafe fn as_chunks_unchecked_mut<const N: usize>( + &mut self +) -> &mut [[T; N]]

🔬This is a nightly-only experimental API. (slice_as_chunks)

Splits the slice into a slice of N-element arrays, +assuming that there’s no remainder.

+
Safety
+

This may only be called when

+
    +
  • The slice splits exactly into N-element chunks (aka self.len() % N == 0).
  • +
  • N != 0.
  • +
+
Examples
+
#![feature(slice_as_chunks)]
+let slice: &mut [char] = &mut ['l', 'o', 'r', 'e', 'm', '!'];
+let chunks: &mut [[char; 1]] =
+    // SAFETY: 1-element chunks never have remainder
+    unsafe { slice.as_chunks_unchecked_mut() };
+chunks[0] = ['L'];
+assert_eq!(chunks, &[['L'], ['o'], ['r'], ['e'], ['m'], ['!']]);
+let chunks: &mut [[char; 3]] =
+    // SAFETY: The slice length (6) is a multiple of 3
+    unsafe { slice.as_chunks_unchecked_mut() };
+chunks[1] = ['a', 'x', '?'];
+assert_eq!(slice, &['L', 'o', 'r', 'a', 'x', '?']);
+
+// These would be unsound:
+// let chunks: &[[_; 5]] = slice.as_chunks_unchecked_mut() // The slice length is not a multiple of 5
+// let chunks: &[[_; 0]] = slice.as_chunks_unchecked_mut() // Zero-length chunks are never allowed
+
source

pub fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T])

🔬This is a nightly-only experimental API. (slice_as_chunks)

Splits the slice into a slice of N-element arrays, +starting at the beginning of the slice, +and a remainder slice with length strictly less than N.

+
Panics
+

Panics if N is 0. This check will most probably get changed to a compile time +error before this method gets stabilized.

+
Examples
+
#![feature(slice_as_chunks)]
+let v = &mut [0, 0, 0, 0, 0];
+let mut count = 1;
+
+let (chunks, remainder) = v.as_chunks_mut();
+remainder[0] = 9;
+for chunk in chunks {
+    *chunk = [count; 2];
+    count += 1;
+}
+assert_eq!(v, &[1, 1, 2, 2, 9]);
+
source

pub fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]])

🔬This is a nightly-only experimental API. (slice_as_chunks)

Splits the slice into a slice of N-element arrays, +starting at the end of the slice, +and a remainder slice with length strictly less than N.

+
Panics
+

Panics if N is 0. This check will most probably get changed to a compile time +error before this method gets stabilized.

+
Examples
+
#![feature(slice_as_chunks)]
+let v = &mut [0, 0, 0, 0, 0];
+let mut count = 1;
+
+let (remainder, chunks) = v.as_rchunks_mut();
+remainder[0] = 9;
+for chunk in chunks {
+    *chunk = [count; 2];
+    count += 1;
+}
+assert_eq!(v, &[9, 1, 1, 2, 2]);
+
source

pub fn array_chunks_mut<const N: usize>(&mut self) -> ArrayChunksMut<'_, T, N>

🔬This is a nightly-only experimental API. (array_chunks)

Returns an iterator over N elements of the slice at a time, starting at the +beginning of the slice.

+

The chunks are mutable array references and do not overlap. If N does not divide +the length of the slice, then the last up to N-1 elements will be omitted and +can be retrieved from the into_remainder function of the iterator.

+

This method is the const generic equivalent of chunks_exact_mut.

+
Panics
+

Panics if N is 0. This check will most probably get changed to a compile time +error before this method gets stabilized.

+
Examples
+
#![feature(array_chunks)]
+let v = &mut [0, 0, 0, 0, 0];
+let mut count = 1;
+
+for chunk in v.array_chunks_mut() {
+    *chunk = [count; 2];
+    count += 1;
+}
+assert_eq!(v, &[1, 1, 2, 2, 0]);
+
source

pub fn array_windows<const N: usize>(&self) -> ArrayWindows<'_, T, N>

🔬This is a nightly-only experimental API. (array_windows)

Returns an iterator over overlapping windows of N elements of a slice, +starting at the beginning of the slice.

+

This is the const generic equivalent of windows.

+

If N is greater than the size of the slice, it will return no windows.

+
Panics
+

Panics if N is 0. This check will most probably get changed to a compile time +error before this method gets stabilized.

+
Examples
+
#![feature(array_windows)]
+let slice = [0, 1, 2, 3];
+let mut iter = slice.array_windows();
+assert_eq!(iter.next().unwrap(), &[0, 1]);
+assert_eq!(iter.next().unwrap(), &[1, 2]);
+assert_eq!(iter.next().unwrap(), &[2, 3]);
+assert!(iter.next().is_none());
+
1.31.0 · source

pub fn rchunks(&self, chunk_size: usize) -> RChunks<'_, T>

Returns an iterator over chunk_size elements of the slice at a time, starting at the end +of the slice.

+

The chunks are slices and do not overlap. If chunk_size does not divide the length of the +slice, then the last chunk will not have length chunk_size.

+

See rchunks_exact for a variant of this iterator that returns chunks of always exactly +chunk_size elements, and chunks for the same iterator but starting at the beginning +of the slice.

+
Panics
+

Panics if chunk_size is 0.

+
Examples
+
let slice = ['l', 'o', 'r', 'e', 'm'];
+let mut iter = slice.rchunks(2);
+assert_eq!(iter.next().unwrap(), &['e', 'm']);
+assert_eq!(iter.next().unwrap(), &['o', 'r']);
+assert_eq!(iter.next().unwrap(), &['l']);
+assert!(iter.next().is_none());
+
1.31.0 · source

pub fn rchunks_mut(&mut self, chunk_size: usize) -> RChunksMut<'_, T>

Returns an iterator over chunk_size elements of the slice at a time, starting at the end +of the slice.

+

The chunks are mutable slices, and do not overlap. If chunk_size does not divide the +length of the slice, then the last chunk will not have length chunk_size.

+

See rchunks_exact_mut for a variant of this iterator that returns chunks of always +exactly chunk_size elements, and chunks_mut for the same iterator but starting at the +beginning of the slice.

+
Panics
+

Panics if chunk_size is 0.

+
Examples
+
let v = &mut [0, 0, 0, 0, 0];
+let mut count = 1;
+
+for chunk in v.rchunks_mut(2) {
+    for elem in chunk.iter_mut() {
+        *elem += count;
+    }
+    count += 1;
+}
+assert_eq!(v, &[3, 2, 2, 1, 1]);
+
1.31.0 · source

pub fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact<'_, T>

Returns an iterator over chunk_size elements of the slice at a time, starting at the +end of the slice.

+

The chunks are slices and do not overlap. If chunk_size does not divide the length of the +slice, then the last up to chunk_size-1 elements will be omitted and can be retrieved +from the remainder function of the iterator.

+

Due to each chunk having exactly chunk_size elements, the compiler can often optimize the +resulting code better than in the case of rchunks.

+

See rchunks for a variant of this iterator that also returns the remainder as a smaller +chunk, and chunks_exact for the same iterator but starting at the beginning of the +slice.

+
Panics
+

Panics if chunk_size is 0.

+
Examples
+
let slice = ['l', 'o', 'r', 'e', 'm'];
+let mut iter = slice.rchunks_exact(2);
+assert_eq!(iter.next().unwrap(), &['e', 'm']);
+assert_eq!(iter.next().unwrap(), &['o', 'r']);
+assert!(iter.next().is_none());
+assert_eq!(iter.remainder(), &['l']);
+
1.31.0 · source

pub fn rchunks_exact_mut(&mut self, chunk_size: usize) -> RChunksExactMut<'_, T>

Returns an iterator over chunk_size elements of the slice at a time, starting at the end +of the slice.

+

The chunks are mutable slices, and do not overlap. If chunk_size does not divide the +length of the slice, then the last up to chunk_size-1 elements will be omitted and can be +retrieved from the into_remainder function of the iterator.

+

Due to each chunk having exactly chunk_size elements, the compiler can often optimize the +resulting code better than in the case of chunks_mut.

+

See rchunks_mut for a variant of this iterator that also returns the remainder as a +smaller chunk, and chunks_exact_mut for the same iterator but starting at the beginning +of the slice.

+
Panics
+

Panics if chunk_size is 0.

+
Examples
+
let v = &mut [0, 0, 0, 0, 0];
+let mut count = 1;
+
+for chunk in v.rchunks_exact_mut(2) {
+    for elem in chunk.iter_mut() {
+        *elem += count;
+    }
+    count += 1;
+}
+assert_eq!(v, &[0, 2, 2, 1, 1]);
+
source

pub fn group_by<F>(&self, pred: F) -> GroupBy<'_, T, F>where + F: FnMut(&T, &T) -> bool,

🔬This is a nightly-only experimental API. (slice_group_by)

Returns an iterator over the slice producing non-overlapping runs +of elements using the predicate to separate them.

+

The predicate is called on two elements following themselves, +it means the predicate is called on slice[0] and slice[1] +then on slice[1] and slice[2] and so on.

+
Examples
+
#![feature(slice_group_by)]
+
+let slice = &[1, 1, 1, 3, 3, 2, 2, 2];
+
+let mut iter = slice.group_by(|a, b| a == b);
+
+assert_eq!(iter.next(), Some(&[1, 1, 1][..]));
+assert_eq!(iter.next(), Some(&[3, 3][..]));
+assert_eq!(iter.next(), Some(&[2, 2, 2][..]));
+assert_eq!(iter.next(), None);
+

This method can be used to extract the sorted subslices:

+ +
#![feature(slice_group_by)]
+
+let slice = &[1, 1, 2, 3, 2, 3, 2, 3, 4];
+
+let mut iter = slice.group_by(|a, b| a <= b);
+
+assert_eq!(iter.next(), Some(&[1, 1, 2, 3][..]));
+assert_eq!(iter.next(), Some(&[2, 3][..]));
+assert_eq!(iter.next(), Some(&[2, 3, 4][..]));
+assert_eq!(iter.next(), None);
+
source

pub fn group_by_mut<F>(&mut self, pred: F) -> GroupByMut<'_, T, F>where + F: FnMut(&T, &T) -> bool,

🔬This is a nightly-only experimental API. (slice_group_by)

Returns an iterator over the slice producing non-overlapping mutable +runs of elements using the predicate to separate them.

+

The predicate is called on two elements following themselves, +it means the predicate is called on slice[0] and slice[1] +then on slice[1] and slice[2] and so on.

+
Examples
+
#![feature(slice_group_by)]
+
+let slice = &mut [1, 1, 1, 3, 3, 2, 2, 2];
+
+let mut iter = slice.group_by_mut(|a, b| a == b);
+
+assert_eq!(iter.next(), Some(&mut [1, 1, 1][..]));
+assert_eq!(iter.next(), Some(&mut [3, 3][..]));
+assert_eq!(iter.next(), Some(&mut [2, 2, 2][..]));
+assert_eq!(iter.next(), None);
+

This method can be used to extract the sorted subslices:

+ +
#![feature(slice_group_by)]
+
+let slice = &mut [1, 1, 2, 3, 2, 3, 2, 3, 4];
+
+let mut iter = slice.group_by_mut(|a, b| a <= b);
+
+assert_eq!(iter.next(), Some(&mut [1, 1, 2, 3][..]));
+assert_eq!(iter.next(), Some(&mut [2, 3][..]));
+assert_eq!(iter.next(), Some(&mut [2, 3, 4][..]));
+assert_eq!(iter.next(), None);
+
1.0.0 · source

pub fn split_at(&self, mid: usize) -> (&[T], &[T])

Divides one slice into two at an index.

+

The first will contain all indices from [0, mid) (excluding +the index mid itself) and the second will contain all +indices from [mid, len) (excluding the index len itself).

+
Panics
+

Panics if mid > len.

+
Examples
+
let v = [1, 2, 3, 4, 5, 6];
+
+{
+   let (left, right) = v.split_at(0);
+   assert_eq!(left, []);
+   assert_eq!(right, [1, 2, 3, 4, 5, 6]);
+}
+
+{
+    let (left, right) = v.split_at(2);
+    assert_eq!(left, [1, 2]);
+    assert_eq!(right, [3, 4, 5, 6]);
+}
+
+{
+    let (left, right) = v.split_at(6);
+    assert_eq!(left, [1, 2, 3, 4, 5, 6]);
+    assert_eq!(right, []);
+}
+
1.0.0 · source

pub fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T])

Divides one mutable slice into two at an index.

+

The first will contain all indices from [0, mid) (excluding +the index mid itself) and the second will contain all +indices from [mid, len) (excluding the index len itself).

+
Panics
+

Panics if mid > len.

+
Examples
+
let mut v = [1, 0, 3, 0, 5, 6];
+let (left, right) = v.split_at_mut(2);
+assert_eq!(left, [1, 0]);
+assert_eq!(right, [3, 0, 5, 6]);
+left[1] = 2;
+right[1] = 4;
+assert_eq!(v, [1, 2, 3, 4, 5, 6]);
+
source

pub unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T])

🔬This is a nightly-only experimental API. (slice_split_at_unchecked)

Divides one slice into two at an index, without doing bounds checking.

+

The first will contain all indices from [0, mid) (excluding +the index mid itself) and the second will contain all +indices from [mid, len) (excluding the index len itself).

+

For a safe alternative see split_at.

+
Safety
+

Calling this method with an out-of-bounds index is undefined behavior +even if the resulting reference is not used. The caller has to ensure that +0 <= mid <= self.len().

+
Examples
+
#![feature(slice_split_at_unchecked)]
+
+let v = [1, 2, 3, 4, 5, 6];
+
+unsafe {
+   let (left, right) = v.split_at_unchecked(0);
+   assert_eq!(left, []);
+   assert_eq!(right, [1, 2, 3, 4, 5, 6]);
+}
+
+unsafe {
+    let (left, right) = v.split_at_unchecked(2);
+    assert_eq!(left, [1, 2]);
+    assert_eq!(right, [3, 4, 5, 6]);
+}
+
+unsafe {
+    let (left, right) = v.split_at_unchecked(6);
+    assert_eq!(left, [1, 2, 3, 4, 5, 6]);
+    assert_eq!(right, []);
+}
+
source

pub unsafe fn split_at_mut_unchecked( + &mut self, + mid: usize +) -> (&mut [T], &mut [T])

🔬This is a nightly-only experimental API. (slice_split_at_unchecked)

Divides one mutable slice into two at an index, without doing bounds checking.

+

The first will contain all indices from [0, mid) (excluding +the index mid itself) and the second will contain all +indices from [mid, len) (excluding the index len itself).

+

For a safe alternative see split_at_mut.

+
Safety
+

Calling this method with an out-of-bounds index is undefined behavior +even if the resulting reference is not used. The caller has to ensure that +0 <= mid <= self.len().

+
Examples
+
#![feature(slice_split_at_unchecked)]
+
+let mut v = [1, 0, 3, 0, 5, 6];
+// scoped to restrict the lifetime of the borrows
+unsafe {
+    let (left, right) = v.split_at_mut_unchecked(2);
+    assert_eq!(left, [1, 0]);
+    assert_eq!(right, [3, 0, 5, 6]);
+    left[1] = 2;
+    right[1] = 4;
+}
+assert_eq!(v, [1, 2, 3, 4, 5, 6]);
+
source

pub fn split_array_ref<const N: usize>(&self) -> (&[T; N], &[T])

🔬This is a nightly-only experimental API. (split_array)

Divides one slice into an array and a remainder slice at an index.

+

The array will contain all indices from [0, N) (excluding +the index N itself) and the slice will contain all +indices from [N, len) (excluding the index len itself).

+
Panics
+

Panics if N > len.

+
Examples
+
#![feature(split_array)]
+
+let v = &[1, 2, 3, 4, 5, 6][..];
+
+{
+   let (left, right) = v.split_array_ref::<0>();
+   assert_eq!(left, &[]);
+   assert_eq!(right, [1, 2, 3, 4, 5, 6]);
+}
+
+{
+    let (left, right) = v.split_array_ref::<2>();
+    assert_eq!(left, &[1, 2]);
+    assert_eq!(right, [3, 4, 5, 6]);
+}
+
+{
+    let (left, right) = v.split_array_ref::<6>();
+    assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
+    assert_eq!(right, []);
+}
+
source

pub fn split_array_mut<const N: usize>(&mut self) -> (&mut [T; N], &mut [T])

🔬This is a nightly-only experimental API. (split_array)

Divides one mutable slice into an array and a remainder slice at an index.

+

The array will contain all indices from [0, N) (excluding +the index N itself) and the slice will contain all +indices from [N, len) (excluding the index len itself).

+
Panics
+

Panics if N > len.

+
Examples
+
#![feature(split_array)]
+
+let mut v = &mut [1, 0, 3, 0, 5, 6][..];
+let (left, right) = v.split_array_mut::<2>();
+assert_eq!(left, &mut [1, 0]);
+assert_eq!(right, [3, 0, 5, 6]);
+left[1] = 2;
+right[1] = 4;
+assert_eq!(v, [1, 2, 3, 4, 5, 6]);
+
source

pub fn rsplit_array_ref<const N: usize>(&self) -> (&[T], &[T; N])

🔬This is a nightly-only experimental API. (split_array)

Divides one slice into an array and a remainder slice at an index from +the end.

+

The slice will contain all indices from [0, len - N) (excluding +the index len - N itself) and the array will contain all +indices from [len - N, len) (excluding the index len itself).

+
Panics
+

Panics if N > len.

+
Examples
+
#![feature(split_array)]
+
+let v = &[1, 2, 3, 4, 5, 6][..];
+
+{
+   let (left, right) = v.rsplit_array_ref::<0>();
+   assert_eq!(left, [1, 2, 3, 4, 5, 6]);
+   assert_eq!(right, &[]);
+}
+
+{
+    let (left, right) = v.rsplit_array_ref::<2>();
+    assert_eq!(left, [1, 2, 3, 4]);
+    assert_eq!(right, &[5, 6]);
+}
+
+{
+    let (left, right) = v.rsplit_array_ref::<6>();
+    assert_eq!(left, []);
+    assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
+}
+
source

pub fn rsplit_array_mut<const N: usize>(&mut self) -> (&mut [T], &mut [T; N])

🔬This is a nightly-only experimental API. (split_array)

Divides one mutable slice into an array and a remainder slice at an +index from the end.

+

The slice will contain all indices from [0, len - N) (excluding +the index N itself) and the array will contain all +indices from [len - N, len) (excluding the index len itself).

+
Panics
+

Panics if N > len.

+
Examples
+
#![feature(split_array)]
+
+let mut v = &mut [1, 0, 3, 0, 5, 6][..];
+let (left, right) = v.rsplit_array_mut::<4>();
+assert_eq!(left, [1, 0]);
+assert_eq!(right, &mut [3, 0, 5, 6]);
+left[1] = 2;
+right[1] = 4;
+assert_eq!(v, [1, 2, 3, 4, 5, 6]);
+
1.0.0 · source

pub fn split<F>(&self, pred: F) -> Split<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over subslices separated by elements that match +pred. The matched element is not contained in the subslices.

+
Examples
+
let slice = [10, 40, 33, 20];
+let mut iter = slice.split(|num| num % 3 == 0);
+
+assert_eq!(iter.next().unwrap(), &[10, 40]);
+assert_eq!(iter.next().unwrap(), &[20]);
+assert!(iter.next().is_none());
+

If the first element is matched, an empty slice will be the first item +returned by the iterator. Similarly, if the last element in the slice +is matched, an empty slice will be the last item returned by the +iterator:

+ +
let slice = [10, 40, 33];
+let mut iter = slice.split(|num| num % 3 == 0);
+
+assert_eq!(iter.next().unwrap(), &[10, 40]);
+assert_eq!(iter.next().unwrap(), &[]);
+assert!(iter.next().is_none());
+

If two matched elements are directly adjacent, an empty slice will be +present between them:

+ +
let slice = [10, 6, 33, 20];
+let mut iter = slice.split(|num| num % 3 == 0);
+
+assert_eq!(iter.next().unwrap(), &[10]);
+assert_eq!(iter.next().unwrap(), &[]);
+assert_eq!(iter.next().unwrap(), &[20]);
+assert!(iter.next().is_none());
+
1.0.0 · source

pub fn split_mut<F>(&mut self, pred: F) -> SplitMut<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over mutable subslices separated by elements that +match pred. The matched element is not contained in the subslices.

+
Examples
+
let mut v = [10, 40, 30, 20, 60, 50];
+
+for group in v.split_mut(|num| *num % 3 == 0) {
+    group[0] = 1;
+}
+assert_eq!(v, [1, 40, 30, 1, 60, 1]);
+
1.51.0 · source

pub fn split_inclusive<F>(&self, pred: F) -> SplitInclusive<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over subslices separated by elements that match +pred. The matched element is contained in the end of the previous +subslice as a terminator.

+
Examples
+
let slice = [10, 40, 33, 20];
+let mut iter = slice.split_inclusive(|num| num % 3 == 0);
+
+assert_eq!(iter.next().unwrap(), &[10, 40, 33]);
+assert_eq!(iter.next().unwrap(), &[20]);
+assert!(iter.next().is_none());
+

If the last element of the slice is matched, +that element will be considered the terminator of the preceding slice. +That slice will be the last item returned by the iterator.

+ +
let slice = [3, 10, 40, 33];
+let mut iter = slice.split_inclusive(|num| num % 3 == 0);
+
+assert_eq!(iter.next().unwrap(), &[3]);
+assert_eq!(iter.next().unwrap(), &[10, 40, 33]);
+assert!(iter.next().is_none());
+
1.51.0 · source

pub fn split_inclusive_mut<F>(&mut self, pred: F) -> SplitInclusiveMut<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over mutable subslices separated by elements that +match pred. The matched element is contained in the previous +subslice as a terminator.

+
Examples
+
let mut v = [10, 40, 30, 20, 60, 50];
+
+for group in v.split_inclusive_mut(|num| *num % 3 == 0) {
+    let terminator_idx = group.len()-1;
+    group[terminator_idx] = 1;
+}
+assert_eq!(v, [10, 40, 1, 20, 1, 1]);
+
1.27.0 · source

pub fn rsplit<F>(&self, pred: F) -> RSplit<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over subslices separated by elements that match +pred, starting at the end of the slice and working backwards. +The matched element is not contained in the subslices.

+
Examples
+
let slice = [11, 22, 33, 0, 44, 55];
+let mut iter = slice.rsplit(|num| *num == 0);
+
+assert_eq!(iter.next().unwrap(), &[44, 55]);
+assert_eq!(iter.next().unwrap(), &[11, 22, 33]);
+assert_eq!(iter.next(), None);
+

As with split(), if the first or last element is matched, an empty +slice will be the first (or last) item returned by the iterator.

+ +
let v = &[0, 1, 1, 2, 3, 5, 8];
+let mut it = v.rsplit(|n| *n % 2 == 0);
+assert_eq!(it.next().unwrap(), &[]);
+assert_eq!(it.next().unwrap(), &[3, 5]);
+assert_eq!(it.next().unwrap(), &[1, 1]);
+assert_eq!(it.next().unwrap(), &[]);
+assert_eq!(it.next(), None);
+
1.27.0 · source

pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over mutable subslices separated by elements that +match pred, starting at the end of the slice and working +backwards. The matched element is not contained in the subslices.

+
Examples
+
let mut v = [100, 400, 300, 200, 600, 500];
+
+let mut count = 0;
+for group in v.rsplit_mut(|num| *num % 3 == 0) {
+    count += 1;
+    group[0] = count;
+}
+assert_eq!(v, [3, 400, 300, 2, 600, 1]);
+
1.0.0 · source

pub fn splitn<F>(&self, n: usize, pred: F) -> SplitN<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over subslices separated by elements that match +pred, limited to returning at most n items. The matched element is +not contained in the subslices.

+

The last element returned, if any, will contain the remainder of the +slice.

+
Examples
+

Print the slice split once by numbers divisible by 3 (i.e., [10, 40], +[20, 60, 50]):

+ +
let v = [10, 40, 30, 20, 60, 50];
+
+for group in v.splitn(2, |num| *num % 3 == 0) {
+    println!("{group:?}");
+}
+
1.0.0 · source

pub fn splitn_mut<F>(&mut self, n: usize, pred: F) -> SplitNMut<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over mutable subslices separated by elements that match +pred, limited to returning at most n items. The matched element is +not contained in the subslices.

+

The last element returned, if any, will contain the remainder of the +slice.

+
Examples
+
let mut v = [10, 40, 30, 20, 60, 50];
+
+for group in v.splitn_mut(2, |num| *num % 3 == 0) {
+    group[0] = 1;
+}
+assert_eq!(v, [1, 40, 30, 1, 60, 50]);
+
1.0.0 · source

pub fn rsplitn<F>(&self, n: usize, pred: F) -> RSplitN<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over subslices separated by elements that match +pred limited to returning at most n items. This starts at the end of +the slice and works backwards. The matched element is not contained in +the subslices.

+

The last element returned, if any, will contain the remainder of the +slice.

+
Examples
+

Print the slice split once, starting from the end, by numbers divisible +by 3 (i.e., [50], [10, 40, 30, 20]):

+ +
let v = [10, 40, 30, 20, 60, 50];
+
+for group in v.rsplitn(2, |num| *num % 3 == 0) {
+    println!("{group:?}");
+}
+
1.0.0 · source

pub fn rsplitn_mut<F>(&mut self, n: usize, pred: F) -> RSplitNMut<'_, T, F>where + F: FnMut(&T) -> bool,

Returns an iterator over subslices separated by elements that match +pred limited to returning at most n items. This starts at the end of +the slice and works backwards. The matched element is not contained in +the subslices.

+

The last element returned, if any, will contain the remainder of the +slice.

+
Examples
+
let mut s = [10, 40, 30, 20, 60, 50];
+
+for group in s.rsplitn_mut(2, |num| *num % 3 == 0) {
+    group[0] = 1;
+}
+assert_eq!(s, [1, 40, 30, 20, 60, 1]);
+
1.0.0 · source

pub fn contains(&self, x: &T) -> boolwhere + T: PartialEq<T>,

Returns true if the slice contains an element with the given value.

+

This operation is O(n).

+

Note that if you have a sorted slice, binary_search may be faster.

+
Examples
+
let v = [10, 40, 30];
+assert!(v.contains(&30));
+assert!(!v.contains(&50));
+

If you do not have a &T, but some other value that you can compare +with one (for example, String implements PartialEq<str>), you can +use iter().any:

+ +
let v = [String::from("hello"), String::from("world")]; // slice of `String`
+assert!(v.iter().any(|e| e == "hello")); // search with `&str`
+assert!(!v.iter().any(|e| e == "hi"));
+
1.0.0 · source

pub fn starts_with(&self, needle: &[T]) -> boolwhere + T: PartialEq<T>,

Returns true if needle is a prefix of the slice.

+
Examples
+
let v = [10, 40, 30];
+assert!(v.starts_with(&[10]));
+assert!(v.starts_with(&[10, 40]));
+assert!(!v.starts_with(&[50]));
+assert!(!v.starts_with(&[10, 50]));
+

Always returns true if needle is an empty slice:

+ +
let v = &[10, 40, 30];
+assert!(v.starts_with(&[]));
+let v: &[u8] = &[];
+assert!(v.starts_with(&[]));
+
1.0.0 · source

pub fn ends_with(&self, needle: &[T]) -> boolwhere + T: PartialEq<T>,

Returns true if needle is a suffix of the slice.

+
Examples
+
let v = [10, 40, 30];
+assert!(v.ends_with(&[30]));
+assert!(v.ends_with(&[40, 30]));
+assert!(!v.ends_with(&[50]));
+assert!(!v.ends_with(&[50, 30]));
+

Always returns true if needle is an empty slice:

+ +
let v = &[10, 40, 30];
+assert!(v.ends_with(&[]));
+let v: &[u8] = &[];
+assert!(v.ends_with(&[]));
+
1.51.0 · source

pub fn strip_prefix<P>(&self, prefix: &P) -> Option<&[T]>where + P: SlicePattern<Item = T> + ?Sized, + T: PartialEq<T>,

Returns a subslice with the prefix removed.

+

If the slice starts with prefix, returns the subslice after the prefix, wrapped in Some. +If prefix is empty, simply returns the original slice.

+

If the slice does not start with prefix, returns None.

+
Examples
+
let v = &[10, 40, 30];
+assert_eq!(v.strip_prefix(&[10]), Some(&[40, 30][..]));
+assert_eq!(v.strip_prefix(&[10, 40]), Some(&[30][..]));
+assert_eq!(v.strip_prefix(&[50]), None);
+assert_eq!(v.strip_prefix(&[10, 50]), None);
+
+let prefix : &str = "he";
+assert_eq!(b"hello".strip_prefix(prefix.as_bytes()),
+           Some(b"llo".as_ref()));
+
1.51.0 · source

pub fn strip_suffix<P>(&self, suffix: &P) -> Option<&[T]>where + P: SlicePattern<Item = T> + ?Sized, + T: PartialEq<T>,

Returns a subslice with the suffix removed.

+

If the slice ends with suffix, returns the subslice before the suffix, wrapped in Some. +If suffix is empty, simply returns the original slice.

+

If the slice does not end with suffix, returns None.

+
Examples
+
let v = &[10, 40, 30];
+assert_eq!(v.strip_suffix(&[30]), Some(&[10, 40][..]));
+assert_eq!(v.strip_suffix(&[40, 30]), Some(&[10][..]));
+assert_eq!(v.strip_suffix(&[50]), None);
+assert_eq!(v.strip_suffix(&[50, 30]), None);
+

Binary searches this slice for a given element. +If the slice is not sorted, the returned result is unspecified and +meaningless.

+

If the value is found then Result::Ok is returned, containing the +index of the matching element. If there are multiple matches, then any +one of the matches could be returned. The index is chosen +deterministically, but is subject to change in future versions of Rust. +If the value is not found then Result::Err is returned, containing +the index where a matching element could be inserted while maintaining +sorted order.

+

See also binary_search_by, binary_search_by_key, and partition_point.

+
Examples
+

Looks up a series of four elements. The first is found, with a +uniquely determined position; the second and third are not +found; the fourth could match any position in [1, 4].

+ +
let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
+
+assert_eq!(s.binary_search(&13),  Ok(9));
+assert_eq!(s.binary_search(&4),   Err(7));
+assert_eq!(s.binary_search(&100), Err(13));
+let r = s.binary_search(&1);
+assert!(match r { Ok(1..=4) => true, _ => false, });
+

If you want to find that whole range of matching items, rather than +an arbitrary matching one, that can be done using partition_point:

+ +
let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
+
+let low = s.partition_point(|x| x < &1);
+assert_eq!(low, 1);
+let high = s.partition_point(|x| x <= &1);
+assert_eq!(high, 5);
+let r = s.binary_search(&1);
+assert!((low..high).contains(&r.unwrap()));
+
+assert!(s[..low].iter().all(|&x| x < 1));
+assert!(s[low..high].iter().all(|&x| x == 1));
+assert!(s[high..].iter().all(|&x| x > 1));
+
+// For something not found, the "range" of equal items is empty
+assert_eq!(s.partition_point(|x| x < &11), 9);
+assert_eq!(s.partition_point(|x| x <= &11), 9);
+assert_eq!(s.binary_search(&11), Err(9));
+

If you want to insert an item to a sorted vector, while maintaining +sort order, consider using partition_point:

+ +
let mut s = vec![0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
+let num = 42;
+let idx = s.partition_point(|&x| x < num);
+// The above is equivalent to `let idx = s.binary_search(&num).unwrap_or_else(|x| x);`
+s.insert(idx, num);
+assert_eq!(s, [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
+
1.0.0 · source

pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>where + F: FnMut(&'a T) -> Ordering,

Binary searches this slice with a comparator function.

+

The comparator function should return an order code that indicates +whether its argument is Less, Equal or Greater the desired +target. +If the slice is not sorted or if the comparator function does not +implement an order consistent with the sort order of the underlying +slice, the returned result is unspecified and meaningless.

+

If the value is found then Result::Ok is returned, containing the +index of the matching element. If there are multiple matches, then any +one of the matches could be returned. The index is chosen +deterministically, but is subject to change in future versions of Rust. +If the value is not found then Result::Err is returned, containing +the index where a matching element could be inserted while maintaining +sorted order.

+

See also binary_search, binary_search_by_key, and partition_point.

+
Examples
+

Looks up a series of four elements. The first is found, with a +uniquely determined position; the second and third are not +found; the fourth could match any position in [1, 4].

+ +
let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
+
+let seek = 13;
+assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Ok(9));
+let seek = 4;
+assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Err(7));
+let seek = 100;
+assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Err(13));
+let seek = 1;
+let r = s.binary_search_by(|probe| probe.cmp(&seek));
+assert!(match r { Ok(1..=4) => true, _ => false, });
+
1.10.0 · source

pub fn binary_search_by_key<'a, B, F>( + &'a self, + b: &B, + f: F +) -> Result<usize, usize>where + F: FnMut(&'a T) -> B, + B: Ord,

Binary searches this slice with a key extraction function.

+

Assumes that the slice is sorted by the key, for instance with +sort_by_key using the same key extraction function. +If the slice is not sorted by the key, the returned result is +unspecified and meaningless.

+

If the value is found then Result::Ok is returned, containing the +index of the matching element. If there are multiple matches, then any +one of the matches could be returned. The index is chosen +deterministically, but is subject to change in future versions of Rust. +If the value is not found then Result::Err is returned, containing +the index where a matching element could be inserted while maintaining +sorted order.

+

See also binary_search, binary_search_by, and partition_point.

+
Examples
+

Looks up a series of four elements in a slice of pairs sorted by +their second elements. The first is found, with a uniquely +determined position; the second and third are not found; the +fourth could match any position in [1, 4].

+ +
let s = [(0, 0), (2, 1), (4, 1), (5, 1), (3, 1),
+         (1, 2), (2, 3), (4, 5), (5, 8), (3, 13),
+         (1, 21), (2, 34), (4, 55)];
+
+assert_eq!(s.binary_search_by_key(&13, |&(a, b)| b),  Ok(9));
+assert_eq!(s.binary_search_by_key(&4, |&(a, b)| b),   Err(7));
+assert_eq!(s.binary_search_by_key(&100, |&(a, b)| b), Err(13));
+let r = s.binary_search_by_key(&1, |&(a, b)| b);
+assert!(match r { Ok(1..=4) => true, _ => false, });
+
1.20.0 · source

pub fn sort_unstable(&mut self)where + T: Ord,

Sorts the slice, but might not preserve the order of equal elements.

+

This sort is unstable (i.e., may reorder equal elements), in-place +(i.e., does not allocate), and O(n * log(n)) worst-case.

+
Current implementation
+

The current algorithm is based on pattern-defeating quicksort by Orson Peters, +which combines the fast average case of randomized quicksort with the fast worst case of +heapsort, while achieving linear time on slices with certain patterns. It uses some +randomization to avoid degenerate cases, but with a fixed seed to always provide +deterministic behavior.

+

It is typically faster than stable sorting, except in a few special cases, e.g., when the +slice consists of several concatenated sorted sequences.

+
Examples
+
let mut v = [-5, 4, 1, -3, 2];
+
+v.sort_unstable();
+assert!(v == [-5, -3, 1, 2, 4]);
+
1.20.0 · source

pub fn sort_unstable_by<F>(&mut self, compare: F)where + F: FnMut(&T, &T) -> Ordering,

Sorts the slice with a comparator function, but might not preserve the order of equal +elements.

+

This sort is unstable (i.e., may reorder equal elements), in-place +(i.e., does not allocate), and O(n * log(n)) worst-case.

+

The comparator function must define a total ordering for the elements in the slice. If +the ordering is not total, the order of the elements is unspecified. An order is a +total order if it is (for all a, b and c):

+
    +
  • total and antisymmetric: exactly one of a < b, a == b or a > b is true, and
  • +
  • transitive, a < b and b < c implies a < c. The same must hold for both == and >.
  • +
+

For example, while f64 doesn’t implement Ord because NaN != NaN, we can use +partial_cmp as our sort function when we know the slice doesn’t contain a NaN.

+ +
let mut floats = [5f64, 4.0, 1.0, 3.0, 2.0];
+floats.sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
+assert_eq!(floats, [1.0, 2.0, 3.0, 4.0, 5.0]);
+
Current implementation
+

The current algorithm is based on pattern-defeating quicksort by Orson Peters, +which combines the fast average case of randomized quicksort with the fast worst case of +heapsort, while achieving linear time on slices with certain patterns. It uses some +randomization to avoid degenerate cases, but with a fixed seed to always provide +deterministic behavior.

+

It is typically faster than stable sorting, except in a few special cases, e.g., when the +slice consists of several concatenated sorted sequences.

+
Examples
+
let mut v = [5, 4, 1, 3, 2];
+v.sort_unstable_by(|a, b| a.cmp(b));
+assert!(v == [1, 2, 3, 4, 5]);
+
+// reverse sorting
+v.sort_unstable_by(|a, b| b.cmp(a));
+assert!(v == [5, 4, 3, 2, 1]);
+
1.20.0 · source

pub fn sort_unstable_by_key<K, F>(&mut self, f: F)where + F: FnMut(&T) -> K, + K: Ord,

Sorts the slice with a key extraction function, but might not preserve the order of equal +elements.

+

This sort is unstable (i.e., may reorder equal elements), in-place +(i.e., does not allocate), and O(m * n * log(n)) worst-case, where the key function is +O(m).

+
Current implementation
+

The current algorithm is based on pattern-defeating quicksort by Orson Peters, +which combines the fast average case of randomized quicksort with the fast worst case of +heapsort, while achieving linear time on slices with certain patterns. It uses some +randomization to avoid degenerate cases, but with a fixed seed to always provide +deterministic behavior.

+

Due to its key calling strategy, sort_unstable_by_key +is likely to be slower than sort_by_cached_key in +cases where the key function is expensive.

+
Examples
+
let mut v = [-5i32, 4, 1, -3, 2];
+
+v.sort_unstable_by_key(|k| k.abs());
+assert!(v == [1, 2, -3, 4, -5]);
+
1.49.0 · source

pub fn select_nth_unstable( + &mut self, + index: usize +) -> (&mut [T], &mut T, &mut [T])where + T: Ord,

Reorder the slice such that the element at index is at its final sorted position.

+

This reordering has the additional property that any value at position i < index will be +less than or equal to any value at a position j > index. Additionally, this reordering is +unstable (i.e. any number of equal elements may end up at position index), in-place +(i.e. does not allocate), and O(n) on average. The worst-case performance is O(n log n). +This function is also known as “kth element” in other libraries.

+

It returns a triplet of the following from the reordered slice: +the subslice prior to index, the element at index, and the subslice after index; +accordingly, the values in those two subslices will respectively all be less-than-or-equal-to +and greater-than-or-equal-to the value of the element at index.

+
Current implementation
+

The current algorithm is based on the quickselect portion of the same quicksort algorithm +used for sort_unstable.

+
Panics
+

Panics when index >= len(), meaning it always panics on empty slices.

+
Examples
+
let mut v = [-5i32, 4, 1, -3, 2];
+
+// Find the median
+v.select_nth_unstable(2);
+
+// We are only guaranteed the slice will be one of the following, based on the way we sort
+// about the specified index.
+assert!(v == [-3, -5, 1, 2, 4] ||
+        v == [-5, -3, 1, 2, 4] ||
+        v == [-3, -5, 1, 4, 2] ||
+        v == [-5, -3, 1, 4, 2]);
+
1.49.0 · source

pub fn select_nth_unstable_by<F>( + &mut self, + index: usize, + compare: F +) -> (&mut [T], &mut T, &mut [T])where + F: FnMut(&T, &T) -> Ordering,

Reorder the slice with a comparator function such that the element at index is at its +final sorted position.

+

This reordering has the additional property that any value at position i < index will be +less than or equal to any value at a position j > index using the comparator function. +Additionally, this reordering is unstable (i.e. any number of equal elements may end up at +position index), in-place (i.e. does not allocate), and O(n) on average. +The worst-case performance is O(n log n). This function is also known as +“kth element” in other libraries.

+

It returns a triplet of the following from +the slice reordered according to the provided comparator function: the subslice prior to +index, the element at index, and the subslice after index; accordingly, the values in +those two subslices will respectively all be less-than-or-equal-to and greater-than-or-equal-to +the value of the element at index.

+
Current implementation
+

The current algorithm is based on the quickselect portion of the same quicksort algorithm +used for sort_unstable.

+
Panics
+

Panics when index >= len(), meaning it always panics on empty slices.

+
Examples
+
let mut v = [-5i32, 4, 1, -3, 2];
+
+// Find the median as if the slice were sorted in descending order.
+v.select_nth_unstable_by(2, |a, b| b.cmp(a));
+
+// We are only guaranteed the slice will be one of the following, based on the way we sort
+// about the specified index.
+assert!(v == [2, 4, 1, -5, -3] ||
+        v == [2, 4, 1, -3, -5] ||
+        v == [4, 2, 1, -5, -3] ||
+        v == [4, 2, 1, -3, -5]);
+
1.49.0 · source

pub fn select_nth_unstable_by_key<K, F>( + &mut self, + index: usize, + f: F +) -> (&mut [T], &mut T, &mut [T])where + F: FnMut(&T) -> K, + K: Ord,

Reorder the slice with a key extraction function such that the element at index is at its +final sorted position.

+

This reordering has the additional property that any value at position i < index will be +less than or equal to any value at a position j > index using the key extraction function. +Additionally, this reordering is unstable (i.e. any number of equal elements may end up at +position index), in-place (i.e. does not allocate), and O(n) on average. +The worst-case performance is O(n log n). +This function is also known as “kth element” in other libraries.

+

It returns a triplet of the following from +the slice reordered according to the provided key extraction function: the subslice prior to +index, the element at index, and the subslice after index; accordingly, the values in +those two subslices will respectively all be less-than-or-equal-to and greater-than-or-equal-to +the value of the element at index.

+
Current implementation
+

The current algorithm is based on the quickselect portion of the same quicksort algorithm +used for sort_unstable.

+
Panics
+

Panics when index >= len(), meaning it always panics on empty slices.

+
Examples
+
let mut v = [-5i32, 4, 1, -3, 2];
+
+// Return the median as if the array were sorted according to absolute value.
+v.select_nth_unstable_by_key(2, |a| a.abs());
+
+// We are only guaranteed the slice will be one of the following, based on the way we sort
+// about the specified index.
+assert!(v == [1, 2, -3, 4, -5] ||
+        v == [1, 2, -3, -5, 4] ||
+        v == [2, 1, -3, 4, -5] ||
+        v == [2, 1, -3, -5, 4]);
+
source

pub fn partition_dedup(&mut self) -> (&mut [T], &mut [T])where + T: PartialEq<T>,

🔬This is a nightly-only experimental API. (slice_partition_dedup)

Moves all consecutive repeated elements to the end of the slice according to the +PartialEq trait implementation.

+

Returns two slices. The first contains no consecutive repeated elements. +The second contains all the duplicates in no specified order.

+

If the slice is sorted, the first returned slice contains no duplicates.

+
Examples
+
#![feature(slice_partition_dedup)]
+
+let mut slice = [1, 2, 2, 3, 3, 2, 1, 1];
+
+let (dedup, duplicates) = slice.partition_dedup();
+
+assert_eq!(dedup, [1, 2, 3, 2, 1]);
+assert_eq!(duplicates, [2, 3, 1]);
+
source

pub fn partition_dedup_by<F>(&mut self, same_bucket: F) -> (&mut [T], &mut [T])where + F: FnMut(&mut T, &mut T) -> bool,

🔬This is a nightly-only experimental API. (slice_partition_dedup)

Moves all but the first of consecutive elements to the end of the slice satisfying +a given equality relation.

+

Returns two slices. The first contains no consecutive repeated elements. +The second contains all the duplicates in no specified order.

+

The same_bucket function is passed references to two elements from the slice and +must determine if the elements compare equal. The elements are passed in opposite order +from their order in the slice, so if same_bucket(a, b) returns true, a is moved +at the end of the slice.

+

If the slice is sorted, the first returned slice contains no duplicates.

+
Examples
+
#![feature(slice_partition_dedup)]
+
+let mut slice = ["foo", "Foo", "BAZ", "Bar", "bar", "baz", "BAZ"];
+
+let (dedup, duplicates) = slice.partition_dedup_by(|a, b| a.eq_ignore_ascii_case(b));
+
+assert_eq!(dedup, ["foo", "BAZ", "Bar", "baz"]);
+assert_eq!(duplicates, ["bar", "Foo", "BAZ"]);
+
source

pub fn partition_dedup_by_key<K, F>(&mut self, key: F) -> (&mut [T], &mut [T])where + F: FnMut(&mut T) -> K, + K: PartialEq<K>,

🔬This is a nightly-only experimental API. (slice_partition_dedup)

Moves all but the first of consecutive elements to the end of the slice that resolve +to the same key.

+

Returns two slices. The first contains no consecutive repeated elements. +The second contains all the duplicates in no specified order.

+

If the slice is sorted, the first returned slice contains no duplicates.

+
Examples
+
#![feature(slice_partition_dedup)]
+
+let mut slice = [10, 20, 21, 30, 30, 20, 11, 13];
+
+let (dedup, duplicates) = slice.partition_dedup_by_key(|i| *i / 10);
+
+assert_eq!(dedup, [10, 20, 30, 20, 11]);
+assert_eq!(duplicates, [21, 30, 13]);
+
1.26.0 · source

pub fn rotate_left(&mut self, mid: usize)

Rotates the slice in-place such that the first mid elements of the +slice move to the end while the last self.len() - mid elements move to +the front. After calling rotate_left, the element previously at index +mid will become the first element in the slice.

+
Panics
+

This function will panic if mid is greater than the length of the +slice. Note that mid == self.len() does not panic and is a no-op +rotation.

+
Complexity
+

Takes linear (in self.len()) time.

+
Examples
+
let mut a = ['a', 'b', 'c', 'd', 'e', 'f'];
+a.rotate_left(2);
+assert_eq!(a, ['c', 'd', 'e', 'f', 'a', 'b']);
+

Rotating a subslice:

+ +
let mut a = ['a', 'b', 'c', 'd', 'e', 'f'];
+a[1..5].rotate_left(1);
+assert_eq!(a, ['a', 'c', 'd', 'e', 'b', 'f']);
+
1.26.0 · source

pub fn rotate_right(&mut self, k: usize)

Rotates the slice in-place such that the first self.len() - k +elements of the slice move to the end while the last k elements move +to the front. After calling rotate_right, the element previously at +index self.len() - k will become the first element in the slice.

+
Panics
+

This function will panic if k is greater than the length of the +slice. Note that k == self.len() does not panic and is a no-op +rotation.

+
Complexity
+

Takes linear (in self.len()) time.

+
Examples
+
let mut a = ['a', 'b', 'c', 'd', 'e', 'f'];
+a.rotate_right(2);
+assert_eq!(a, ['e', 'f', 'a', 'b', 'c', 'd']);
+

Rotate a subslice:

+ +
let mut a = ['a', 'b', 'c', 'd', 'e', 'f'];
+a[1..5].rotate_right(1);
+assert_eq!(a, ['a', 'e', 'b', 'c', 'd', 'f']);
+
1.50.0 · source

pub fn fill(&mut self, value: T)where + T: Clone,

Fills self with elements by cloning value.

+
Examples
+
let mut buf = vec![0; 10];
+buf.fill(1);
+assert_eq!(buf, vec![1; 10]);
+
1.51.0 · source

pub fn fill_with<F>(&mut self, f: F)where + F: FnMut() -> T,

Fills self with elements returned by calling a closure repeatedly.

+

This method uses a closure to create new values. If you’d rather +Clone a given value, use fill. If you want to use the Default +trait to generate values, you can pass Default::default as the +argument.

+
Examples
+
let mut buf = vec![1; 10];
+buf.fill_with(Default::default);
+assert_eq!(buf, vec![0; 10]);
+
1.7.0 · source

pub fn clone_from_slice(&mut self, src: &[T])where + T: Clone,

Copies the elements from src into self.

+

The length of src must be the same as self.

+
Panics
+

This function will panic if the two slices have different lengths.

+
Examples
+

Cloning two elements from a slice into another:

+ +
let src = [1, 2, 3, 4];
+let mut dst = [0, 0];
+
+// Because the slices have to be the same length,
+// we slice the source slice from four elements
+// to two. It will panic if we don't do this.
+dst.clone_from_slice(&src[2..]);
+
+assert_eq!(src, [1, 2, 3, 4]);
+assert_eq!(dst, [3, 4]);
+

Rust enforces that there can only be one mutable reference with no +immutable references to a particular piece of data in a particular +scope. Because of this, attempting to use clone_from_slice on a +single slice will result in a compile failure:

+ +
let mut slice = [1, 2, 3, 4, 5];
+
+slice[..2].clone_from_slice(&slice[3..]); // compile fail!
+

To work around this, we can use split_at_mut to create two distinct +sub-slices from a slice:

+ +
let mut slice = [1, 2, 3, 4, 5];
+
+{
+    let (left, right) = slice.split_at_mut(2);
+    left.clone_from_slice(&right[1..]);
+}
+
+assert_eq!(slice, [4, 5, 3, 4, 5]);
+
1.9.0 · source

pub fn copy_from_slice(&mut self, src: &[T])where + T: Copy,

Copies all elements from src into self, using a memcpy.

+

The length of src must be the same as self.

+

If T does not implement Copy, use clone_from_slice.

+
Panics
+

This function will panic if the two slices have different lengths.

+
Examples
+

Copying two elements from a slice into another:

+ +
let src = [1, 2, 3, 4];
+let mut dst = [0, 0];
+
+// Because the slices have to be the same length,
+// we slice the source slice from four elements
+// to two. It will panic if we don't do this.
+dst.copy_from_slice(&src[2..]);
+
+assert_eq!(src, [1, 2, 3, 4]);
+assert_eq!(dst, [3, 4]);
+

Rust enforces that there can only be one mutable reference with no +immutable references to a particular piece of data in a particular +scope. Because of this, attempting to use copy_from_slice on a +single slice will result in a compile failure:

+ +
let mut slice = [1, 2, 3, 4, 5];
+
+slice[..2].copy_from_slice(&slice[3..]); // compile fail!
+

To work around this, we can use split_at_mut to create two distinct +sub-slices from a slice:

+ +
let mut slice = [1, 2, 3, 4, 5];
+
+{
+    let (left, right) = slice.split_at_mut(2);
+    left.copy_from_slice(&right[1..]);
+}
+
+assert_eq!(slice, [4, 5, 3, 4, 5]);
+
1.37.0 · source

pub fn copy_within<R>(&mut self, src: R, dest: usize)where + R: RangeBounds<usize>, + T: Copy,

Copies elements from one part of the slice to another part of itself, +using a memmove.

+

src is the range within self to copy from. dest is the starting +index of the range within self to copy to, which will have the same +length as src. The two ranges may overlap. The ends of the two ranges +must be less than or equal to self.len().

+
Panics
+

This function will panic if either range exceeds the end of the slice, +or if the end of src is before the start.

+
Examples
+

Copying four bytes within a slice:

+ +
let mut bytes = *b"Hello, World!";
+
+bytes.copy_within(1..5, 8);
+
+assert_eq!(&bytes, b"Hello, Wello!");
+
1.27.0 · source

pub fn swap_with_slice(&mut self, other: &mut [T])

Swaps all elements in self with those in other.

+

The length of other must be the same as self.

+
Panics
+

This function will panic if the two slices have different lengths.

+
Example
+

Swapping two elements across slices:

+ +
let mut slice1 = [0, 0];
+let mut slice2 = [1, 2, 3, 4];
+
+slice1.swap_with_slice(&mut slice2[2..]);
+
+assert_eq!(slice1, [3, 4]);
+assert_eq!(slice2, [1, 2, 0, 0]);
+

Rust enforces that there can only be one mutable reference to a +particular piece of data in a particular scope. Because of this, +attempting to use swap_with_slice on a single slice will result in +a compile failure:

+ +
let mut slice = [1, 2, 3, 4, 5];
+slice[..2].swap_with_slice(&mut slice[3..]); // compile fail!
+

To work around this, we can use split_at_mut to create two distinct +mutable sub-slices from a slice:

+ +
let mut slice = [1, 2, 3, 4, 5];
+
+{
+    let (left, right) = slice.split_at_mut(2);
+    left.swap_with_slice(&mut right[1..]);
+}
+
+assert_eq!(slice, [4, 5, 3, 1, 2]);
+
1.30.0 · source

pub unsafe fn align_to<U>(&self) -> (&[T], &[U], &[T])

Transmute the slice to a slice of another type, ensuring alignment of the types is +maintained.

+

This method splits the slice into three distinct slices: prefix, correctly aligned middle +slice of a new type, and the suffix slice. How exactly the slice is split up is not +specified; the middle part may be smaller than necessary. However, if this fails to return a +maximal middle part, that is because code is running in a context where performance does not +matter, such as a sanitizer attempting to find alignment bugs. Regular code running +in a default (debug or release) execution will return a maximal middle part.

+

This method has no purpose when either input element T or output element U are +zero-sized and will return the original slice without splitting anything.

+
Safety
+

This method is essentially a transmute with respect to the elements in the returned +middle slice, so all the usual caveats pertaining to transmute::<T, U> also apply here.

+
Examples
+

Basic usage:

+ +
unsafe {
+    let bytes: [u8; 7] = [1, 2, 3, 4, 5, 6, 7];
+    let (prefix, shorts, suffix) = bytes.align_to::<u16>();
+    // less_efficient_algorithm_for_bytes(prefix);
+    // more_efficient_algorithm_for_aligned_shorts(shorts);
+    // less_efficient_algorithm_for_bytes(suffix);
+}
+
1.30.0 · source

pub unsafe fn align_to_mut<U>(&mut self) -> (&mut [T], &mut [U], &mut [T])

Transmute the mutable slice to a mutable slice of another type, ensuring alignment of the +types is maintained.

+

This method splits the slice into three distinct slices: prefix, correctly aligned middle +slice of a new type, and the suffix slice. How exactly the slice is split up is not +specified; the middle part may be smaller than necessary. However, if this fails to return a +maximal middle part, that is because code is running in a context where performance does not +matter, such as a sanitizer attempting to find alignment bugs. Regular code running +in a default (debug or release) execution will return a maximal middle part.

+

This method has no purpose when either input element T or output element U are +zero-sized and will return the original slice without splitting anything.

+
Safety
+

This method is essentially a transmute with respect to the elements in the returned +middle slice, so all the usual caveats pertaining to transmute::<T, U> also apply here.

+
Examples
+

Basic usage:

+ +
unsafe {
+    let mut bytes: [u8; 7] = [1, 2, 3, 4, 5, 6, 7];
+    let (prefix, shorts, suffix) = bytes.align_to_mut::<u16>();
+    // less_efficient_algorithm_for_bytes(prefix);
+    // more_efficient_algorithm_for_aligned_shorts(shorts);
+    // less_efficient_algorithm_for_bytes(suffix);
+}
+
source

pub fn as_simd<const LANES: usize>(&self) -> (&[T], &[Simd<T, LANES>], &[T])where + Simd<T, LANES>: AsRef<[T; LANES]>, + T: SimdElement, + LaneCount<LANES>: SupportedLaneCount,

🔬This is a nightly-only experimental API. (portable_simd)

Split a slice into a prefix, a middle of aligned SIMD types, and a suffix.

+

This is a safe wrapper around slice::align_to, so has the same weak +postconditions as that method. You’re only assured that +self.len() == prefix.len() + middle.len() * LANES + suffix.len().

+

Notably, all of the following are possible:

+
    +
  • prefix.len() >= LANES.
  • +
  • middle.is_empty() despite self.len() >= 3 * LANES.
  • +
  • suffix.len() >= LANES.
  • +
+

That said, this is a safe method, so if you’re only writing safe code, +then this can at most cause incorrect logic, not unsoundness.

+
Panics
+

This will panic if the size of the SIMD type is different from +LANES times that of the scalar.

+

At the time of writing, the trait restrictions on Simd<T, LANES> keeps +that from ever happening, as only power-of-two numbers of lanes are +supported. It’s possible that, in the future, those restrictions might +be lifted in a way that would make it possible to see panics from this +method for something like LANES == 3.

+
Examples
+
#![feature(portable_simd)]
+use core::simd::SimdFloat;
+
+let short = &[1, 2, 3];
+let (prefix, middle, suffix) = short.as_simd::<4>();
+assert_eq!(middle, []); // Not enough elements for anything in the middle
+
+// They might be split in any possible way between prefix and suffix
+let it = prefix.iter().chain(suffix).copied();
+assert_eq!(it.collect::<Vec<_>>(), vec![1, 2, 3]);
+
+fn basic_simd_sum(x: &[f32]) -> f32 {
+    use std::ops::Add;
+    use std::simd::f32x4;
+    let (prefix, middle, suffix) = x.as_simd();
+    let sums = f32x4::from_array([
+        prefix.iter().copied().sum(),
+        0.0,
+        0.0,
+        suffix.iter().copied().sum(),
+    ]);
+    let sums = middle.iter().copied().fold(sums, f32x4::add);
+    sums.reduce_sum()
+}
+
+let numbers: Vec<f32> = (1..101).map(|x| x as _).collect();
+assert_eq!(basic_simd_sum(&numbers[1..99]), 4949.0);
+
source

pub fn as_simd_mut<const LANES: usize>( + &mut self +) -> (&mut [T], &mut [Simd<T, LANES>], &mut [T])where + Simd<T, LANES>: AsMut<[T; LANES]>, + T: SimdElement, + LaneCount<LANES>: SupportedLaneCount,

🔬This is a nightly-only experimental API. (portable_simd)

Split a mutable slice into a mutable prefix, a middle of aligned SIMD types, +and a mutable suffix.

+

This is a safe wrapper around slice::align_to_mut, so has the same weak +postconditions as that method. You’re only assured that +self.len() == prefix.len() + middle.len() * LANES + suffix.len().

+

Notably, all of the following are possible:

+
    +
  • prefix.len() >= LANES.
  • +
  • middle.is_empty() despite self.len() >= 3 * LANES.
  • +
  • suffix.len() >= LANES.
  • +
+

That said, this is a safe method, so if you’re only writing safe code, +then this can at most cause incorrect logic, not unsoundness.

+

This is the mutable version of slice::as_simd; see that for examples.

+
Panics
+

This will panic if the size of the SIMD type is different from +LANES times that of the scalar.

+

At the time of writing, the trait restrictions on Simd<T, LANES> keeps +that from ever happening, as only power-of-two numbers of lanes are +supported. It’s possible that, in the future, those restrictions might +be lifted in a way that would make it possible to see panics from this +method for something like LANES == 3.

+
source

pub fn is_sorted(&self) -> boolwhere + T: PartialOrd<T>,

🔬This is a nightly-only experimental API. (is_sorted)

Checks if the elements of this slice are sorted.

+

That is, for each element a and its following element b, a <= b must hold. If the +slice yields exactly zero or one element, true is returned.

+

Note that if Self::Item is only PartialOrd, but not Ord, the above definition +implies that this function returns false if any two consecutive items are not +comparable.

+
Examples
+
#![feature(is_sorted)]
+let empty: [i32; 0] = [];
+
+assert!([1, 2, 2, 9].is_sorted());
+assert!(![1, 3, 2, 4].is_sorted());
+assert!([0].is_sorted());
+assert!(empty.is_sorted());
+assert!(![0.0, 1.0, f32::NAN].is_sorted());
+
source

pub fn is_sorted_by<'a, F>(&'a self, compare: F) -> boolwhere + F: FnMut(&'a T, &'a T) -> Option<Ordering>,

🔬This is a nightly-only experimental API. (is_sorted)

Checks if the elements of this slice are sorted using the given comparator function.

+

Instead of using PartialOrd::partial_cmp, this function uses the given compare +function to determine the ordering of two elements. Apart from that, it’s equivalent to +is_sorted; see its documentation for more information.

+
source

pub fn is_sorted_by_key<'a, F, K>(&'a self, f: F) -> boolwhere + F: FnMut(&'a T) -> K, + K: PartialOrd<K>,

🔬This is a nightly-only experimental API. (is_sorted)

Checks if the elements of this slice are sorted using the given key extraction function.

+

Instead of comparing the slice’s elements directly, this function compares the keys of the +elements, as determined by f. Apart from that, it’s equivalent to is_sorted; see its +documentation for more information.

+
Examples
+
#![feature(is_sorted)]
+
+assert!(["c", "bb", "aaa"].is_sorted_by_key(|s| s.len()));
+assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs()));
+
1.52.0 · source

pub fn partition_point<P>(&self, pred: P) -> usizewhere + P: FnMut(&T) -> bool,

Returns the index of the partition point according to the given predicate +(the index of the first element of the second partition).

+

The slice is assumed to be partitioned according to the given predicate. +This means that all elements for which the predicate returns true are at the start of the slice +and all elements for which the predicate returns false are at the end. +For example, [7, 15, 3, 5, 4, 12, 6] is partitioned under the predicate x % 2 != 0 +(all odd numbers are at the start, all even at the end).

+

If this slice is not partitioned, the returned result is unspecified and meaningless, +as this method performs a kind of binary search.

+

See also binary_search, binary_search_by, and binary_search_by_key.

+
Examples
+
let v = [1, 2, 3, 3, 5, 6, 7];
+let i = v.partition_point(|&x| x < 5);
+
+assert_eq!(i, 4);
+assert!(v[..i].iter().all(|&x| x < 5));
+assert!(v[i..].iter().all(|&x| !(x < 5)));
+

If all elements of the slice match the predicate, including if the slice +is empty, then the length of the slice will be returned:

+ +
let a = [2, 4, 8];
+assert_eq!(a.partition_point(|x| x < &100), a.len());
+let a: [i32; 0] = [];
+assert_eq!(a.partition_point(|x| x < &100), 0);
+

If you want to insert an item to a sorted vector, while maintaining +sort order:

+ +
let mut s = vec![0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
+let num = 42;
+let idx = s.partition_point(|&x| x < num);
+s.insert(idx, num);
+assert_eq!(s, [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 42, 55]);
+
source

pub fn take<R, 'a>(self: &mut &'a [T], range: R) -> Option<&'a [T]>where + R: OneSidedRange<usize>,

🔬This is a nightly-only experimental API. (slice_take)

Removes the subslice corresponding to the given range +and returns a reference to it.

+

Returns None and does not modify the slice if the given +range is out of bounds.

+

Note that this method only accepts one-sided ranges such as +2.. or ..6, but not 2..6.

+
Examples
+

Taking the first three elements of a slice:

+ +
#![feature(slice_take)]
+
+let mut slice: &[_] = &['a', 'b', 'c', 'd'];
+let mut first_three = slice.take(..3).unwrap();
+
+assert_eq!(slice, &['d']);
+assert_eq!(first_three, &['a', 'b', 'c']);
+

Taking the last two elements of a slice:

+ +
#![feature(slice_take)]
+
+let mut slice: &[_] = &['a', 'b', 'c', 'd'];
+let mut tail = slice.take(2..).unwrap();
+
+assert_eq!(slice, &['a', 'b']);
+assert_eq!(tail, &['c', 'd']);
+

Getting None when range is out of bounds:

+ +
#![feature(slice_take)]
+
+let mut slice: &[_] = &['a', 'b', 'c', 'd'];
+
+assert_eq!(None, slice.take(5..));
+assert_eq!(None, slice.take(..5));
+assert_eq!(None, slice.take(..=4));
+let expected: &[char] = &['a', 'b', 'c', 'd'];
+assert_eq!(Some(expected), slice.take(..4));
+
source

pub fn take_mut<R, 'a>(self: &mut &'a mut [T], range: R) -> Option<&'a mut [T]>where + R: OneSidedRange<usize>,

🔬This is a nightly-only experimental API. (slice_take)

Removes the subslice corresponding to the given range +and returns a mutable reference to it.

+

Returns None and does not modify the slice if the given +range is out of bounds.

+

Note that this method only accepts one-sided ranges such as +2.. or ..6, but not 2..6.

+
Examples
+

Taking the first three elements of a slice:

+ +
#![feature(slice_take)]
+
+let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
+let mut first_three = slice.take_mut(..3).unwrap();
+
+assert_eq!(slice, &mut ['d']);
+assert_eq!(first_three, &mut ['a', 'b', 'c']);
+

Taking the last two elements of a slice:

+ +
#![feature(slice_take)]
+
+let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
+let mut tail = slice.take_mut(2..).unwrap();
+
+assert_eq!(slice, &mut ['a', 'b']);
+assert_eq!(tail, &mut ['c', 'd']);
+

Getting None when range is out of bounds:

+ +
#![feature(slice_take)]
+
+let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
+
+assert_eq!(None, slice.take_mut(5..));
+assert_eq!(None, slice.take_mut(..5));
+assert_eq!(None, slice.take_mut(..=4));
+let expected: &mut [_] = &mut ['a', 'b', 'c', 'd'];
+assert_eq!(Some(expected), slice.take_mut(..4));
+
source

pub fn take_first<'a>(self: &mut &'a [T]) -> Option<&'a T>

🔬This is a nightly-only experimental API. (slice_take)

Removes the first element of the slice and returns a reference +to it.

+

Returns None if the slice is empty.

+
Examples
+
#![feature(slice_take)]
+
+let mut slice: &[_] = &['a', 'b', 'c'];
+let first = slice.take_first().unwrap();
+
+assert_eq!(slice, &['b', 'c']);
+assert_eq!(first, &'a');
+
source

pub fn take_first_mut<'a>(self: &mut &'a mut [T]) -> Option<&'a mut T>

🔬This is a nightly-only experimental API. (slice_take)

Removes the first element of the slice and returns a mutable +reference to it.

+

Returns None if the slice is empty.

+
Examples
+
#![feature(slice_take)]
+
+let mut slice: &mut [_] = &mut ['a', 'b', 'c'];
+let first = slice.take_first_mut().unwrap();
+*first = 'd';
+
+assert_eq!(slice, &['b', 'c']);
+assert_eq!(first, &'d');
+
source

pub fn take_last<'a>(self: &mut &'a [T]) -> Option<&'a T>

🔬This is a nightly-only experimental API. (slice_take)

Removes the last element of the slice and returns a reference +to it.

+

Returns None if the slice is empty.

+
Examples
+
#![feature(slice_take)]
+
+let mut slice: &[_] = &['a', 'b', 'c'];
+let last = slice.take_last().unwrap();
+
+assert_eq!(slice, &['a', 'b']);
+assert_eq!(last, &'c');
+
source

pub fn take_last_mut<'a>(self: &mut &'a mut [T]) -> Option<&'a mut T>

🔬This is a nightly-only experimental API. (slice_take)

Removes the last element of the slice and returns a mutable +reference to it.

+

Returns None if the slice is empty.

+
Examples
+
#![feature(slice_take)]
+
+let mut slice: &mut [_] = &mut ['a', 'b', 'c'];
+let last = slice.take_last_mut().unwrap();
+*last = 'd';
+
+assert_eq!(slice, &['a', 'b']);
+assert_eq!(last, &'d');
+
source

pub unsafe fn get_many_unchecked_mut<const N: usize>( + &mut self, + indices: [usize; N] +) -> [&mut T; N]

🔬This is a nightly-only experimental API. (get_many_mut)

Returns mutable references to many indices at once, without doing any checks.

+

For a safe alternative see get_many_mut.

+
Safety
+

Calling this method with overlapping or out-of-bounds indices is undefined behavior +even if the resulting references are not used.

+
Examples
+
#![feature(get_many_mut)]
+
+let x = &mut [1, 2, 4];
+
+unsafe {
+    let [a, b] = x.get_many_unchecked_mut([0, 2]);
+    *a *= 10;
+    *b *= 100;
+}
+assert_eq!(x, &[10, 2, 400]);
+
source

pub fn get_many_mut<const N: usize>( + &mut self, + indices: [usize; N] +) -> Result<[&mut T; N], GetManyMutError<N>>

🔬This is a nightly-only experimental API. (get_many_mut)

Returns mutable references to many indices at once.

+

Returns an error if any index is out-of-bounds, or if the same index was +passed more than once.

+
Examples
+
#![feature(get_many_mut)]
+
+let v = &mut [1, 2, 3];
+if let Ok([a, b]) = v.get_many_mut([0, 2]) {
+    *a = 413;
+    *b = 612;
+}
+assert_eq!(v, &[413, 2, 612]);
+
source

pub fn sort_floats(&mut self)

🔬This is a nightly-only experimental API. (sort_floats)

Sorts the slice of floats.

+

This sort is in-place (i.e. does not allocate), O(n * log(n)) worst-case, and uses +the ordering defined by f64::total_cmp.

+
Current implementation
+

This uses the same sorting algorithm as sort_unstable_by.

+
Examples
+
#![feature(sort_floats)]
+let mut v = [2.6, -5e-8, f64::NAN, 8.29, f64::INFINITY, -1.0, 0.0, -f64::INFINITY, -0.0];
+
+v.sort_floats();
+let sorted = [-f64::INFINITY, -1.0, -5e-8, -0.0, 0.0, 2.6, 8.29, f64::INFINITY, f64::NAN];
+assert_eq!(&v[..8], &sorted[..8]);
+assert!(v[8].is_nan());
+
source

pub fn flatten(&self) -> &[T]

🔬This is a nightly-only experimental API. (slice_flatten)

Takes a &[[T; N]], and flattens it to a &[T].

+
Panics
+

This panics if the length of the resulting slice would overflow a usize.

+

This is only possible when flattening a slice of arrays of zero-sized +types, and thus tends to be irrelevant in practice. If +size_of::<T>() > 0, this will never panic.

+
Examples
+
#![feature(slice_flatten)]
+
+assert_eq!([[1, 2, 3], [4, 5, 6]].flatten(), &[1, 2, 3, 4, 5, 6]);
+
+assert_eq!(
+    [[1, 2, 3], [4, 5, 6]].flatten(),
+    [[1, 2], [3, 4], [5, 6]].flatten(),
+);
+
+let slice_of_empty_arrays: &[[i32; 0]] = &[[], [], [], [], []];
+assert!(slice_of_empty_arrays.flatten().is_empty());
+
+let empty_slice_of_arrays: &[[u32; 10]] = &[];
+assert!(empty_slice_of_arrays.flatten().is_empty());
+
source

pub fn flatten_mut(&mut self) -> &mut [T]

🔬This is a nightly-only experimental API. (slice_flatten)

Takes a &mut [[T; N]], and flattens it to a &mut [T].

+
Panics
+

This panics if the length of the resulting slice would overflow a usize.

+

This is only possible when flattening a slice of arrays of zero-sized +types, and thus tends to be irrelevant in practice. If +size_of::<T>() > 0, this will never panic.

+
Examples
+
#![feature(slice_flatten)]
+
+fn add_5_to_all(slice: &mut [i32]) {
+    for i in slice {
+        *i += 5;
+    }
+}
+
+let mut array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
+add_5_to_all(array.flatten_mut());
+assert_eq!(array, [[6, 7, 8], [9, 10, 11], [12, 13, 14]]);
+
1.23.0 · source

pub fn is_ascii(&self) -> bool

Checks if all bytes in this slice are within the ASCII range.

+
1.23.0 · source

pub fn eq_ignore_ascii_case(&self, other: &[u8]) -> bool

Checks that two slices are an ASCII case-insensitive match.

+

Same as to_ascii_lowercase(a) == to_ascii_lowercase(b), +but without allocating and copying temporaries.

+
1.23.0 · source

pub fn make_ascii_uppercase(&mut self)

Converts this slice to its ASCII upper case equivalent in-place.

+

ASCII letters ‘a’ to ‘z’ are mapped to ‘A’ to ‘Z’, +but non-ASCII letters are unchanged.

+

To return a new uppercased value without modifying the existing one, use +to_ascii_uppercase.

+
1.23.0 · source

pub fn make_ascii_lowercase(&mut self)

Converts this slice to its ASCII lower case equivalent in-place.

+

ASCII letters ‘A’ to ‘Z’ are mapped to ‘a’ to ‘z’, +but non-ASCII letters are unchanged.

+

To return a new lowercased value without modifying the existing one, use +to_ascii_lowercase.

+
1.60.0 · source

pub fn escape_ascii(&self) -> EscapeAscii<'_>

Returns an iterator that produces an escaped version of this slice, +treating it as an ASCII string.

+
Examples
+

+let s = b"0\t\r\n'\"\\\x9d";
+let escaped = s.escape_ascii().to_string();
+assert_eq!(escaped, "0\\t\\r\\n\\'\\\"\\\\\\x9d");
+
source

pub fn trim_ascii_start(&self) -> &[u8]

🔬This is a nightly-only experimental API. (byte_slice_trim_ascii)

Returns a byte slice with leading ASCII whitespace bytes removed.

+

‘Whitespace’ refers to the definition used by +u8::is_ascii_whitespace.

+
Examples
+
#![feature(byte_slice_trim_ascii)]
+
+assert_eq!(b" \t hello world\n".trim_ascii_start(), b"hello world\n");
+assert_eq!(b"  ".trim_ascii_start(), b"");
+assert_eq!(b"".trim_ascii_start(), b"");
+
source

pub fn trim_ascii_end(&self) -> &[u8]

🔬This is a nightly-only experimental API. (byte_slice_trim_ascii)

Returns a byte slice with trailing ASCII whitespace bytes removed.

+

‘Whitespace’ refers to the definition used by +u8::is_ascii_whitespace.

+
Examples
+
#![feature(byte_slice_trim_ascii)]
+
+assert_eq!(b"\r hello world\n ".trim_ascii_end(), b"\r hello world");
+assert_eq!(b"  ".trim_ascii_end(), b"");
+assert_eq!(b"".trim_ascii_end(), b"");
+
source

pub fn trim_ascii(&self) -> &[u8]

🔬This is a nightly-only experimental API. (byte_slice_trim_ascii)

Returns a byte slice with leading and trailing ASCII whitespace bytes +removed.

+

‘Whitespace’ refers to the definition used by +u8::is_ascii_whitespace.

+
Examples
+
#![feature(byte_slice_trim_ascii)]
+
+assert_eq!(b"\r hello world\n ".trim_ascii(), b"hello world");
+assert_eq!(b"  ".trim_ascii(), b"");
+assert_eq!(b"".trim_ascii(), b"");
+
source

pub fn sort_floats(&mut self)

🔬This is a nightly-only experimental API. (sort_floats)

Sorts the slice of floats.

+

This sort is in-place (i.e. does not allocate), O(n * log(n)) worst-case, and uses +the ordering defined by f32::total_cmp.

+
Current implementation
+

This uses the same sorting algorithm as sort_unstable_by.

+
Examples
+
#![feature(sort_floats)]
+let mut v = [2.6, -5e-8, f32::NAN, 8.29, f32::INFINITY, -1.0, 0.0, -f32::INFINITY, -0.0];
+
+v.sort_floats();
+let sorted = [-f32::INFINITY, -1.0, -5e-8, -0.0, 0.0, 2.6, 8.29, f32::INFINITY, f32::NAN];
+assert_eq!(&v[..8], &sorted[..8]);
+assert!(v[8].is_nan());
+
1.0.0 · source

pub fn sort(&mut self)where + T: Ord,

Sorts the slice.

+

This sort is stable (i.e., does not reorder equal elements) and O(n * log(n)) worst-case.

+

When applicable, unstable sorting is preferred because it is generally faster than stable +sorting and it doesn’t allocate auxiliary memory. +See sort_unstable.

+
Current implementation
+

The current algorithm is an adaptive, iterative merge sort inspired by +timsort. +It is designed to be very fast in cases where the slice is nearly sorted, or consists of +two or more sorted sequences concatenated one after another.

+

Also, it allocates temporary storage half the size of self, but for short slices a +non-allocating insertion sort is used instead.

+
Examples
+
let mut v = [-5, 4, 1, -3, 2];
+
+v.sort();
+assert!(v == [-5, -3, 1, 2, 4]);
+
1.0.0 · source

pub fn sort_by<F>(&mut self, compare: F)where + F: FnMut(&T, &T) -> Ordering,

Sorts the slice with a comparator function.

+

This sort is stable (i.e., does not reorder equal elements) and O(n * log(n)) worst-case.

+

The comparator function must define a total ordering for the elements in the slice. If +the ordering is not total, the order of the elements is unspecified. An order is a +total order if it is (for all a, b and c):

+
    +
  • total and antisymmetric: exactly one of a < b, a == b or a > b is true, and
  • +
  • transitive, a < b and b < c implies a < c. The same must hold for both == and >.
  • +
+

For example, while f64 doesn’t implement Ord because NaN != NaN, we can use +partial_cmp as our sort function when we know the slice doesn’t contain a NaN.

+ +
let mut floats = [5f64, 4.0, 1.0, 3.0, 2.0];
+floats.sort_by(|a, b| a.partial_cmp(b).unwrap());
+assert_eq!(floats, [1.0, 2.0, 3.0, 4.0, 5.0]);
+

When applicable, unstable sorting is preferred because it is generally faster than stable +sorting and it doesn’t allocate auxiliary memory. +See sort_unstable_by.

+
Current implementation
+

The current algorithm is an adaptive, iterative merge sort inspired by +timsort. +It is designed to be very fast in cases where the slice is nearly sorted, or consists of +two or more sorted sequences concatenated one after another.

+

Also, it allocates temporary storage half the size of self, but for short slices a +non-allocating insertion sort is used instead.

+
Examples
+
let mut v = [5, 4, 1, 3, 2];
+v.sort_by(|a, b| a.cmp(b));
+assert!(v == [1, 2, 3, 4, 5]);
+
+// reverse sorting
+v.sort_by(|a, b| b.cmp(a));
+assert!(v == [5, 4, 3, 2, 1]);
+
1.7.0 · source

pub fn sort_by_key<K, F>(&mut self, f: F)where + F: FnMut(&T) -> K, + K: Ord,

Sorts the slice with a key extraction function.

+

This sort is stable (i.e., does not reorder equal elements) and O(m * n * log(n)) +worst-case, where the key function is O(m).

+

For expensive key functions (e.g. functions that are not simple property accesses or +basic operations), sort_by_cached_key is likely to be +significantly faster, as it does not recompute element keys.

+

When applicable, unstable sorting is preferred because it is generally faster than stable +sorting and it doesn’t allocate auxiliary memory. +See sort_unstable_by_key.

+
Current implementation
+

The current algorithm is an adaptive, iterative merge sort inspired by +timsort. +It is designed to be very fast in cases where the slice is nearly sorted, or consists of +two or more sorted sequences concatenated one after another.

+

Also, it allocates temporary storage half the size of self, but for short slices a +non-allocating insertion sort is used instead.

+
Examples
+
let mut v = [-5i32, 4, 1, -3, 2];
+
+v.sort_by_key(|k| k.abs());
+assert!(v == [1, 2, -3, 4, -5]);
+
1.34.0 · source

pub fn sort_by_cached_key<K, F>(&mut self, f: F)where + F: FnMut(&T) -> K, + K: Ord,

Sorts the slice with a key extraction function.

+

During sorting, the key function is called at most once per element, by using +temporary storage to remember the results of key evaluation. +The order of calls to the key function is unspecified and may change in future versions +of the standard library.

+

This sort is stable (i.e., does not reorder equal elements) and O(m * n + n * log(n)) +worst-case, where the key function is O(m).

+

For simple key functions (e.g., functions that are property accesses or +basic operations), sort_by_key is likely to be +faster.

+
Current implementation
+

The current algorithm is based on pattern-defeating quicksort by Orson Peters, +which combines the fast average case of randomized quicksort with the fast worst case of +heapsort, while achieving linear time on slices with certain patterns. It uses some +randomization to avoid degenerate cases, but with a fixed seed to always provide +deterministic behavior.

+

In the worst case, the algorithm allocates temporary storage in a Vec<(K, usize)> the +length of the slice.

+
Examples
+
let mut v = [-5i32, 4, 32, -3, 2];
+
+v.sort_by_cached_key(|k| k.to_string());
+assert!(v == [-3, -5, 2, 32, 4]);
+
1.0.0 · source

pub fn to_vec(&self) -> Vec<T, Global>where + T: Clone,

Copies self into a new Vec.

+
Examples
+
let s = [10, 40, 30];
+let x = s.to_vec();
+// Here, `s` and `x` can be modified independently.
+
source

pub fn to_vec_in<A>(&self, alloc: A) -> Vec<T, A>where + A: Allocator, + T: Clone,

🔬This is a nightly-only experimental API. (allocator_api)

Copies self into a new Vec with an allocator.

+
Examples
+
#![feature(allocator_api)]
+
+use std::alloc::System;
+
+let s = [10, 40, 30];
+let x = s.to_vec_in(System);
+// Here, `s` and `x` can be modified independently.
+
1.40.0 · source

pub fn repeat(&self, n: usize) -> Vec<T, Global>where + T: Copy,

Creates a vector by copying a slice n times.

+
Panics
+

This function will panic if the capacity would overflow.

+
Examples
+

Basic usage:

+ +
assert_eq!([1, 2].repeat(3), vec![1, 2, 1, 2, 1, 2]);
+

A panic upon overflow:

+ +
// this will panic at runtime
+b"0123456789abcdef".repeat(usize::MAX);
+
1.0.0 · source

pub fn concat<Item>(&self) -> <[T] as Concat<Item>>::Output where + [T]: Concat<Item>, + Item: ?Sized,

Flattens a slice of T into a single value Self::Output.

+
Examples
+
assert_eq!(["hello", "world"].concat(), "helloworld");
+assert_eq!([[1, 2], [3, 4]].concat(), [1, 2, 3, 4]);
+
1.3.0 · source

pub fn join<Separator>( + &self, + sep: Separator +) -> <[T] as Join<Separator>>::Output where + [T]: Join<Separator>,

Flattens a slice of T into a single value Self::Output, placing a +given separator between each.

+
Examples
+
assert_eq!(["hello", "world"].join(" "), "hello world");
+assert_eq!([[1, 2], [3, 4]].join(&0), [1, 2, 0, 3, 4]);
+assert_eq!([[1, 2], [3, 4]].join(&[0, 0][..]), [1, 2, 0, 0, 3, 4]);
+
1.0.0 · source

pub fn connect<Separator>( + &self, + sep: Separator +) -> <[T] as Join<Separator>>::Output where + [T]: Join<Separator>,

👎Deprecated since 1.3.0: renamed to join

Flattens a slice of T into a single value Self::Output, placing a +given separator between each.

+
Examples
+
assert_eq!(["hello", "world"].connect(" "), "hello world");
+assert_eq!([[1, 2], [3, 4]].connect(&0), [1, 2, 0, 3, 4]);
+
1.23.0 · source

pub fn to_ascii_uppercase(&self) -> Vec<u8, Global>

Returns a vector containing a copy of this slice where each byte +is mapped to its ASCII upper case equivalent.

+

ASCII letters ‘a’ to ‘z’ are mapped to ‘A’ to ‘Z’, +but non-ASCII letters are unchanged.

+

To uppercase the value in-place, use make_ascii_uppercase.

+
1.23.0 · source

pub fn to_ascii_lowercase(&self) -> Vec<u8, Global>

Returns a vector containing a copy of this slice where each byte +is mapped to its ASCII lower case equivalent.

+

ASCII letters ‘A’ to ‘Z’ are mapped to ‘a’ to ‘z’, +but non-ASCII letters are unchanged.

+

To lowercase the value in-place, use make_ascii_lowercase.

+

Trait Implementations§

source§

impl<T> Deref for LastMut<'_, T>

§

type Target = [T]

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> DerefMut for LastMut<'_, T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for LastMut<'a, T>where + T: RefUnwindSafe,

§

impl<'a, T> Send for LastMut<'a, T>where + T: Send,

§

impl<'a, T> Sync for LastMut<'a, T>where + T: Sync,

§

impl<'a, T> Unpin for LastMut<'a, T>

§

impl<'a, T> !UnwindSafe for LastMut<'a, T>

Blanket Implementations§

source§

impl<T> Any for Twhere + T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere + T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere + T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

+
source§

impl<T, U> Into<U> for Twhere + U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
source§

impl<T, U> TryFrom<U> for Twhere + U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere + U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
\ No newline at end of file diff --git a/help.html b/help.html index 8e001b3c..84dd8207 100644 --- a/help.html +++ b/help.html @@ -1,4 +1,4 @@ -Rustdoc help
Rustdoc help
-

Rustdoc help

Back
\ No newline at end of file +

Rustdoc help

Back
\ No newline at end of file diff --git a/implementors/core/clone/trait.Clone.js b/implementors/core/clone/trait.Clone.js index e656a72a..ce224434 100644 --- a/implementors/core/clone/trait.Clone.js +++ b/implementors/core/clone/trait.Clone.js @@ -24,14 +24,12 @@ "radix_heap":[["impl<T: Clone> Clone for RadixHeap<T>"]], "rational":[["impl<T: Clone + Signed> Clone for Rational<T>"]], "rbtree":[["impl<T: Clone, O: Op<Value = T>> Clone for RbTree<T, O>where\n O::Summary: Clone,"]], -"scc":[["impl Clone for Scc"]], "segbeats":[["impl<T: Clone> Clone for Segbeats<T>"]], "segbeats_task3":[["impl<T: Clone> Clone for Segbeats<T>"]], "skew_heap":[["impl<T: Clone> Clone for SkewHeap<T>"]], "snippetter":[["impl Clone for CrateMetadata"]], "splay_tree":[["impl<O: LazyOps> Clone for SplayTree<O>"]], "trie":[["impl<V: Clone> Clone for TrieMap<V>"],["impl Clone for TrieSet"]], -"two_sat":[["impl Clone for TwoSat"]], "uf_checklist":[["impl Clone for UfChecklist"]], "union_find":[["impl<O: Clone + Op> Clone for UnionFind<O>where\n O::Value: Clone,"]], "vec_lines":[["impl<T: Clone> Clone for Line<T>"],["impl<T: Clone, C: Clone> Clone for VecLines<T, C>"],["impl Clone for IncreasingTilt"],["impl Clone for DecreasingTilt"]], diff --git a/implementors/core/cmp/trait.Eq.js b/implementors/core/cmp/trait.Eq.js index 89f0ad87..228d13c9 100644 --- a/implementors/core/cmp/trait.Eq.js +++ b/implementors/core/cmp/trait.Eq.js @@ -17,11 +17,9 @@ "mincost_flow":[["impl Eq for Edge"]], "radix_heap":[["impl<T: Eq> Eq for RadixHeap<T>"]], "rational":[["impl<T: Signed> Eq for Rational<T>"]], -"scc":[["impl Eq for Scc"]], "segbeats":[["impl<T: Eq> Eq for Segbeats<T>"]], "segbeats_task3":[["impl<T: Eq> Eq for Segbeats<T>"]], "splay_tree":[["impl<O: LazyOps> Eq for SplayTree<O>where\n O::Value: Eq,"]], -"two_sat":[["impl Eq for TwoSat"]], "vec_lines":[["impl<T: Eq> Eq for Line<T>"],["impl Eq for IncreasingTilt"],["impl Eq for DecreasingTilt"],["impl<T: Eq, C: Eq> Eq for VecLines<T, C>"]], "wavelet_matrix":[["impl Eq for StaticBitVec"],["impl<'a> Eq for SpanInNode<'a>"],["impl<'a> Eq for Spans<'a>"],["impl Eq for WaveletMatrix"]] };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/cmp/trait.PartialEq.js b/implementors/core/cmp/trait.PartialEq.js index 2df949ad..b669dc89 100644 --- a/implementors/core/cmp/trait.PartialEq.js +++ b/implementors/core/cmp/trait.PartialEq.js @@ -20,14 +20,12 @@ "radix_heap":[["impl<T: PartialEq> PartialEq<RadixHeap<T>> for RadixHeap<T>"]], "rational":[["impl<T: Signed> PartialEq<Rational<T>> for Rational<T>"]], "rbtree":[["impl<T: PartialEq, O: Op<Value = T>> PartialEq<RbTree<T, O>> for RbTree<T, O>where\n O::Summary: PartialEq,"]], -"scc":[["impl PartialEq<Scc> for Scc"]], "segbeats":[["impl<T: PartialEq> PartialEq<Segbeats<T>> for Segbeats<T>"]], "segbeats_task3":[["impl<T: PartialEq> PartialEq<Segbeats<T>> for Segbeats<T>"]], "skew_heap":[["impl<T: PartialEq> PartialEq<SkewHeap<T>> for SkewHeap<T>"]], "snippetter":[["impl PartialEq<CrateMetadata> for CrateMetadata"]], "splay_tree":[["impl<O: LazyOps> PartialEq<SplayTree<O>> for SplayTree<O>where\n O::Value: PartialEq,"]], "trie":[["impl PartialEq<TrieSet> for TrieSet"],["impl<V: PartialEq> PartialEq<TrieMap<V>> for TrieMap<V>"]], -"two_sat":[["impl PartialEq<TwoSat> for TwoSat"]], "union_find":[["impl<O: PartialEq + Op> PartialEq<UnionFind<O>> for UnionFind<O>where\n O::Value: PartialEq,"]], "vec_lines":[["impl<T: PartialEq, C: PartialEq> PartialEq<VecLines<T, C>> for VecLines<T, C>"],["impl PartialEq<IncreasingTilt> for IncreasingTilt"],["impl PartialEq<DecreasingTilt> for DecreasingTilt"],["impl<T: PartialEq> PartialEq<Line<T>> for Line<T>"]], "wavelet_matrix":[["impl<'a> PartialEq<Spans<'a>> for Spans<'a>"],["impl<'a> PartialEq<SpanInNode<'a>> for SpanInNode<'a>"],["impl PartialEq<StaticBitVec> for StaticBitVec"],["impl PartialEq<WaveletMatrix> for WaveletMatrix"]] diff --git a/implementors/core/default/trait.Default.js b/implementors/core/default/trait.Default.js index df639217..948d4933 100644 --- a/implementors/core/default/trait.Default.js +++ b/implementors/core/default/trait.Default.js @@ -6,6 +6,7 @@ "dual_segtree":[["impl<O: Default + Ops> Default for DualSegtree<O>where\n O::Value: Default,"]], "erato":[["impl Default for Sieve"],["impl Default for LpdSieve"]], "gco":[["impl Default for Gco"],["impl Default for GcoResult"]], +"graph":[["impl<T> Default for Csr<T>"]], "heap_slope_trick":[["impl Default for Summary"],["impl Default for HeapSlopeTrick"]], "heap_tricks":[["impl Default for Nop"],["impl<T: Copy + Ord + Hash> Default for RemovableHeap<T>"],["impl<T> Default for DoubleHeap<T, Nop>where\n T: Copy + Ord + Hash,"],["impl<T: Default> Default for Sum<T>"]], "hopkarp":[["impl Default for HopkarpResult"]], @@ -16,12 +17,10 @@ "rational":[["impl<T: Default + Signed> Default for Rational<T>"]], "rb":[["impl<K: Ord, V> Default for Multimap<K, V>"],["impl<K: Ord> Default for Multiset<K>"],["impl<O: Op> Default for Seg<O>"],["impl<K: Ord, O: MultimapOp> Default for MultimapSeg<K, O>"]], "rbtree":[["impl<T, O: Op<Value = T>> Default for RbTree<T, O>"]], -"scc":[["impl Default for Scc"]], "skew_heap":[["impl<T: Ord> Default for SkewHeap<T>"]], "splay_tree":[["impl<O: LazyOps> Default for SplayTree<O>"]], "swag":[["impl<O: Op> Default for DequeueSwag<O>"]], "trie":[["impl Default for TrieSet"],["impl<V> Default for TrieMap<V>"]], -"two_sat":[["impl Default for TwoSat"]], "union_find":[["impl<O: Default + Op> Default for UnionFind<O>where\n O::Value: Default,"]], "vec_lines":[["impl<T: Default> Default for Line<T>"],["impl<T: Signed, C: Constraint> Default for VecLines<T, C>"]], "wavelet_matrix":[["impl Default for StaticBitVec"],["impl Default for WaveletMatrix"]] diff --git a/implementors/core/fmt/trait.Debug.js b/implementors/core/fmt/trait.Debug.js index 5d5a4536..bf9096d8 100644 --- a/implementors/core/fmt/trait.Debug.js +++ b/implementors/core/fmt/trait.Debug.js @@ -10,6 +10,7 @@ "erato":[["impl Debug for LpdSieve"],["impl Debug for Sieve"]], "fp":[["impl<const P: u64> Debug for Fp<P>"]], "gco":[["impl Debug for Gco"],["impl Debug for GcoResult"]], +"graph":[["impl<T> Debug for Csr<T>where\n T: Debug,"]], "heap_slope_trick":[["impl Debug for HeapSlopeTrick"],["impl Debug for Summary"]], "heap_tricks":[["impl<T: Debug> Debug for Sum<T>"],["impl Debug for Nop"],["impl<T, H> Debug for DoubleHeap<T, H>where\n T: Copy + Ord + Hash + Debug,\n H: Handler<T> + Debug,"],["impl<T: Copy + Ord + Hash + Debug> Debug for RemovableHeap<T>"]], "hopkarp":[["impl Debug for HopkarpResult"]], @@ -26,7 +27,6 @@ "rational":[["impl<T: Signed> Debug for Rational<T>"]], "rb":[["impl<K: Ord + Debug, V: Debug> Debug for Multimap<K, V>"],["impl<K: Ord + Debug> Debug for Multiset<K>"],["impl<O: Op> Debug for Seg<O>where\n O::Value: Debug,"]], "rbtree":[["impl<T: Debug, O: Op<Value = T>> Debug for RbTree<T, O>"]], -"scc":[["impl Debug for Scc"]], "segbeats":[["impl<T: Debug> Debug for Segbeats<T>"]], "segbeats_task3":[["impl<T: Elm> Debug for Segbeats<T>"]], "segtree":[["impl<'a, O: Op> Debug for Entry<'a, O>where\n O::Value: Debug,"],["impl<K, O: Op> Debug for SegtreeWithCompression<K, O>where\n K: Debug,\n O::Value: Debug,"],["impl<O: Op> Debug for Dense2dSegtree<O>where\n O::Value: Debug,"],["impl<K, L, O: Op> Debug for Sparse2dSegtree<K, L, O>where\n K: Debug,\n L: Debug,\n O::Value: Debug,"],["impl<O: Op> Debug for Segtree<O>where\n O::Value: Debug,"]], @@ -36,7 +36,6 @@ "splay_tree":[["impl<O: LazyOps> Debug for SplayTree<O>"]], "swag":[["impl<O: Op> Debug for DequeueSwag<O>where\n O::Value: Debug,"]], "trie":[["impl Debug for TrieSet"],["impl<V: Debug> Debug for TrieMap<V>"]], -"two_sat":[["impl Debug for TwoSat"]], "uf_checklist":[["impl<'a> Debug for Iter<'a>"],["impl Debug for UfChecklist"]], "union_find":[["impl<O: Op> Debug for UnionFind<O>where\n O::Value: Debug,"]], "veb":[["impl Debug for VebSet"],["impl<V: Debug> Debug for VebMap<V>"]], diff --git a/implementors/core/hash/trait.Hash.js b/implementors/core/hash/trait.Hash.js index d3ed8b86..3ab304a2 100644 --- a/implementors/core/hash/trait.Hash.js +++ b/implementors/core/hash/trait.Hash.js @@ -12,10 +12,8 @@ "low_link":[["impl Hash for LowLink"]], "mincost_flow":[["impl Hash for Edge"],["impl Hash for MinCostFlow"]], "rbtree":[["impl<T: Hash, O: Op<Value = T>> Hash for RbTree<T, O>where\n O::Summary: Hash,"]], -"scc":[["impl Hash for Scc"]], "skew_heap":[["impl<T: Hash> Hash for SkewHeap<T>"]], "splay_tree":[["impl<O: LazyOps> Hash for SplayTree<O>where\n O::Value: Hash,"]], -"two_sat":[["impl Hash for TwoSat"]], "union_find":[["impl<O: Hash + Op> Hash for UnionFind<O>where\n O::Value: Hash,"]], "vec_lines":[["impl<T: Hash, C: Hash> Hash for VecLines<T, C>"],["impl<T: Hash> Hash for Line<T>"],["impl Hash for IncreasingTilt"],["impl Hash for DecreasingTilt"]], "wavelet_matrix":[["impl<'a> Hash for Spans<'a>"],["impl Hash for WaveletMatrix"],["impl<'a> Hash for SpanInNode<'a>"],["impl Hash for StaticBitVec"]] diff --git a/implementors/core/iter/traits/collect/trait.FromIterator.js b/implementors/core/iter/traits/collect/trait.FromIterator.js index 2aa5192a..6ca687f9 100644 --- a/implementors/core/iter/traits/collect/trait.FromIterator.js +++ b/implementors/core/iter/traits/collect/trait.FromIterator.js @@ -2,6 +2,7 @@ "avl_tree":[["impl<T> FromIterator<T> for AvlTree<T>"]], "bitvec":[["impl FromIterator<bool> for BitVec"]], "dual_segtree":[["impl<O: Ops> FromIterator<<O as Ops>::Value> for DualSegtree<O>"]], +"graph":[["impl<T, A> FromIterator<A> for Csr<T>where\n A: IntoIterator<Item = T>,"]], "heap_tricks":[["impl<T: Copy + Ord + Hash> FromIterator<T> for RemovableHeap<T>"]], "interval_heap":[["impl<T: Ord> FromIterator<T> for IntervalHeap<T>"]], "lazy_segtree":[["impl<O: Op> FromIterator<<O as Op>::Value> for LazySegtree<O>where\n O::Value: Clone,\n O::Operator: Clone,"]], diff --git a/implementors/core/iter/traits/collect/trait.IntoIterator.js b/implementors/core/iter/traits/collect/trait.IntoIterator.js index 621efac8..34cf5a92 100644 --- a/implementors/core/iter/traits/collect/trait.IntoIterator.js +++ b/implementors/core/iter/traits/collect/trait.IntoIterator.js @@ -1,6 +1,7 @@ (function() {var implementors = { "avl_tree":[["impl<'a, T> IntoIterator for &'a AvlTree<T>"],["impl<T> IntoIterator for AvlTree<T>"]], "bitvec":[["impl<'a> IntoIterator for &'a BitVec"]], +"graph":[["impl<'a, T> IntoIterator for &'a Csr<T>"]], "interval_heap":[["impl<T: Ord> IntoIterator for IntervalHeap<T>"]], "rb":[["impl<'a, K: Ord, V> IntoIterator for &'a Multimap<K, V>"],["impl<'a, O: Op> IntoIterator for &'a Seg<O>"],["impl<'a, K: Ord> IntoIterator for &'a Multiset<K>"],["impl<'a, K: Ord, O: MultimapOp> IntoIterator for &'a MultimapSeg<K, O>"]], "rbtree":[["impl<'a, O: Op> IntoIterator for &'a RbTree<O::Value, O>"]], diff --git a/implementors/core/iter/traits/double_ended/trait.DoubleEndedIterator.js b/implementors/core/iter/traits/double_ended/trait.DoubleEndedIterator.js index c4ac6660..21156718 100644 --- a/implementors/core/iter/traits/double_ended/trait.DoubleEndedIterator.js +++ b/implementors/core/iter/traits/double_ended/trait.DoubleEndedIterator.js @@ -1,4 +1,5 @@ (function() {var implementors = { "avl_tree":[["impl<'a, T> DoubleEndedIterator for Iter<'a, T>"]], +"graph":[["impl<'a, T> DoubleEndedIterator for Iter<'a, T>"]], "splay_tree":[["impl<'a, O: LazyOps> DoubleEndedIterator for Iter<'a, O>"]] };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/iter/traits/exact_size/trait.ExactSizeIterator.js b/implementors/core/iter/traits/exact_size/trait.ExactSizeIterator.js new file mode 100644 index 00000000..573cf45d --- /dev/null +++ b/implementors/core/iter/traits/exact_size/trait.ExactSizeIterator.js @@ -0,0 +1,3 @@ +(function() {var implementors = { +"graph":[["impl<'a, T> ExactSizeIterator for Iter<'a, T>"]] +};if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/iter/traits/iterator/trait.Iterator.js b/implementors/core/iter/traits/iterator/trait.Iterator.js index 76f23d9d..f45e9a87 100644 --- a/implementors/core/iter/traits/iterator/trait.Iterator.js +++ b/implementors/core/iter/traits/iterator/trait.Iterator.js @@ -3,6 +3,7 @@ "avl_tree":[["impl<'a, T> Iterator for Iter<'a, T>"],["impl<T> Iterator for IntoIter<T>"]], "bitvec":[["impl<'a> Iterator for Iter<'a>"]], "erato":[["impl<'a, T: Int> Iterator for PrimeFactorsByLookup<'a, T>"],["impl<'a, T: Int> Iterator for PrimeFactorsByTrialDivision<'a, T>"],["impl<'a, S: SieveKind, T: Int> Iterator for PrimeNumbers<'a, S, T>"],["impl<T: Int, P: PrimeFactors<T>> Iterator for Unique<T, P>"],["impl<T: Int, P: PrimeFactors<T>> Iterator for Rle<T, P>"]], +"graph":[["impl<'a, T> Iterator for Iter<'a, T>"]], "hld":[["impl Iterator for PathSegments<'_>"]], "rbtree":[["impl<'a, T, O: Op<Value = T>> Iterator for Iter<'a, T, O>"]], "splay_tree":[["impl<'a, O: LazyOps> Iterator for Iter<'a, O>"]], diff --git a/implementors/core/marker/trait.Freeze.js b/implementors/core/marker/trait.Freeze.js index a99e9362..b785346d 100644 --- a/implementors/core/marker/trait.Freeze.js +++ b/implementors/core/marker/trait.Freeze.js @@ -10,6 +10,7 @@ "erato":[["impl<T, P> Freeze for Unique<T, P>where\n P: Freeze,\n T: Freeze,",1,["erato::converters::Unique"]],["impl<T, P> Freeze for Rle<T, P>where\n P: Freeze,\n T: Freeze,",1,["erato::converters::Rle"]],["impl Freeze for LpdSieve",1,["erato::lpd_sieve::LpdSieve"]],["impl Freeze for Sieve",1,["erato::sieve::Sieve"]],["impl<'a, S, T> Freeze for PrimeNumbers<'a, S, T>",1,["erato::sieve_base::PrimeNumbers"]],["impl<'a, T> Freeze for PrimeFactorsByTrialDivision<'a, T>where\n T: Freeze,",1,["erato::sieve_base::PrimeFactorsByTrialDivision"]],["impl<'a, T> Freeze for PrimeFactorsByLookup<'a, T>where\n T: Freeze,",1,["erato::sieve_base::PrimeFactorsByLookup"]]], "fp":[["impl<const P: u64> Freeze for Factorial<P>",1,["fp::factorial::Factorial"]],["impl<const P: u64> Freeze for Fp<P>",1,["fp::Fp"]]], "gco":[["impl Freeze for Gco",1,["gco::Gco"]],["impl Freeze for GcoResult",1,["gco::GcoResult"]]], +"graph":[["impl<T> Freeze for Csr<T>",1,["graph::csr::Csr"]],["impl<'a, T> Freeze for LastMut<'a, T>",1,["graph::csr::LastMut"]],["impl<'a, T> Freeze for Iter<'a, T>",1,["graph::csr::Iter"]]], "heap_slope_trick":[["impl Freeze for HeapSlopeTrick",1,["heap_slope_trick::HeapSlopeTrick"]],["impl Freeze for Summary",1,["heap_slope_trick::Summary"]]], "heap_tricks":[["impl Freeze for Nop",1,["heap_tricks::Nop"]],["impl<T> Freeze for Sum<T>where\n T: Freeze,",1,["heap_tricks::Sum"]],["impl<T, H> Freeze for DoubleHeap<T, H>where\n H: Freeze,",1,["heap_tricks::DoubleHeap"]],["impl<T> Freeze for RemovableHeap<T>",1,["heap_tricks::RemovableHeap"]]], "hld":[["impl Freeze for Hld",1,["hld::Hld"]],["impl<'a> Freeze for PathSegments<'a>",1,["hld::PathSegments"]]], @@ -28,7 +29,6 @@ "rational":[["impl<T> Freeze for Rational<T>where\n T: Freeze,",1,["rational::Rational"]]], "rb":[["impl<K, O> Freeze for MultimapSeg<K, O>",1,["rb::map::MultimapSeg"]],["impl<K, V> Freeze for Multimap<K, V>",1,["rb::map::Multimap"]],["impl<K> Freeze for Multiset<K>",1,["rb::map::Multiset"]],["impl<O> Freeze for Seg<O>",1,["rb::seq::Seg"]]], "rbtree":[["impl<T, O> Freeze for RbTree<T, O>where\n T: Freeze,",1,["rbtree::RbTree"]],["impl<T> Freeze for Nop<T>",1,["rbtree::Nop"]],["impl<'a, T, O> Freeze for Iter<'a, T, O>",1,["rbtree::Iter"]]], -"scc":[["impl Freeze for Scc",1,["scc::Scc"]]], "segbeats":[["impl<T> !Freeze for Segbeats<T>",1,["segbeats::Segbeats"]]], "segbeats_task3":[["impl<T> !Freeze for Segbeats<T>",1,["segbeats_task3::Segbeats"]]], "segtree":[["impl<O> Freeze for Segtree<O>",1,["segtree::Segtree"]],["impl<'a, O> Freeze for Entry<'a, O>",1,["segtree::Entry"]],["impl<K, O> Freeze for SegtreeWithCompression<K, O>",1,["segtree::SegtreeWithCompression"]],["impl<K, L, O> Freeze for Sparse2dSegtree<K, L, O>",1,["segtree::Sparse2dSegtree"]],["impl<O> Freeze for Dense2dSegtree<O>",1,["segtree::Dense2dSegtree"]],["impl<'a, O> Freeze for Dense2dEntry<'a, O>",1,["segtree::Dense2dEntry"]]], @@ -40,7 +40,6 @@ "tree_fold":[["impl<T> Freeze for TwoWayTreeFoldResult<T>",1,["tree_fold::TwoWayTreeFoldResult"]]], "trial":[["impl<T> Freeze for Divisors<T>where\n T: Freeze,",1,["trial::divisors::Divisors"]],["impl<T> Freeze for PrimeFactorsRle<T>where\n T: Freeze,",1,["trial::prime_factors::PrimeFactorsRle"]],["impl<T> Freeze for PrimeFactors<T>where\n T: Freeze,",1,["trial::prime_factors::PrimeFactors"]]], "trie":[["impl<V> Freeze for TrieMap<V>",1,["trie::trie_map::TrieMap"]],["impl Freeze for TrieSet",1,["trie::trie_set::TrieSet"]]], -"two_sat":[["impl Freeze for TwoSat",1,["two_sat::TwoSat"]]], "uf_checklist":[["impl Freeze for UfChecklist",1,["uf_checklist::UfChecklist"]],["impl<'a> Freeze for Iter<'a>",1,["uf_checklist::Iter"]]], "union_find":[["impl Freeze for EdgeCount",1,["union_find::EdgeCount"]],["impl Freeze for VertexCount",1,["union_find::VertexCount"]],["impl Freeze for HasCycle",1,["union_find::HasCycle"]],["impl<O> Freeze for UnionFind<O>",1,["union_find::UnionFind"]]], "veb":[["impl<V> Freeze for VebMap<V>",1,["veb::VebMap"]],["impl Freeze for VebSet",1,["veb::VebSet"]]], diff --git a/implementors/core/marker/trait.Send.js b/implementors/core/marker/trait.Send.js index 49ca7987..8db98466 100644 --- a/implementors/core/marker/trait.Send.js +++ b/implementors/core/marker/trait.Send.js @@ -10,6 +10,7 @@ "erato":[["impl<T, P> Send for Unique<T, P>where\n P: Send,\n T: Send,",1,["erato::converters::Unique"]],["impl<T, P> Send for Rle<T, P>where\n P: Send,\n T: Send,",1,["erato::converters::Rle"]],["impl Send for LpdSieve",1,["erato::lpd_sieve::LpdSieve"]],["impl Send for Sieve",1,["erato::sieve::Sieve"]],["impl<'a, S, T> Send for PrimeNumbers<'a, S, T>where\n T: Send,\n <S as SieveKind>::SieveValue: Send,",1,["erato::sieve_base::PrimeNumbers"]],["impl<'a, T> Send for PrimeFactorsByTrialDivision<'a, T>where\n T: Send,",1,["erato::sieve_base::PrimeFactorsByTrialDivision"]],["impl<'a, T> Send for PrimeFactorsByLookup<'a, T>where\n T: Send,",1,["erato::sieve_base::PrimeFactorsByLookup"]]], "fp":[["impl<const P: u64> Send for Factorial<P>",1,["fp::factorial::Factorial"]],["impl<const P: u64> Send for Fp<P>",1,["fp::Fp"]]], "gco":[["impl Send for Gco",1,["gco::Gco"]],["impl Send for GcoResult",1,["gco::GcoResult"]]], +"graph":[["impl<T> Send for Csr<T>where\n T: Send,",1,["graph::csr::Csr"]],["impl<'a, T> Send for LastMut<'a, T>where\n T: Send,",1,["graph::csr::LastMut"]],["impl<'a, T> Send for Iter<'a, T>where\n T: Sync,",1,["graph::csr::Iter"]]], "heap_slope_trick":[["impl Send for HeapSlopeTrick",1,["heap_slope_trick::HeapSlopeTrick"]],["impl Send for Summary",1,["heap_slope_trick::Summary"]]], "heap_tricks":[["impl Send for Nop",1,["heap_tricks::Nop"]],["impl<T> Send for Sum<T>where\n T: Send,",1,["heap_tricks::Sum"]],["impl<T, H> Send for DoubleHeap<T, H>where\n H: Send,\n T: Send,",1,["heap_tricks::DoubleHeap"]],["impl<T> Send for RemovableHeap<T>where\n T: Send,",1,["heap_tricks::RemovableHeap"]]], "hld":[["impl Send for Hld",1,["hld::Hld"]],["impl<'a> Send for PathSegments<'a>",1,["hld::PathSegments"]]], @@ -28,7 +29,6 @@ "rational":[["impl<T> Send for Rational<T>where\n T: Send,",1,["rational::Rational"]]], "rb":[["impl<K, O> !Send for MultimapSeg<K, O>",1,["rb::map::MultimapSeg"]],["impl<K, V> !Send for Multimap<K, V>",1,["rb::map::Multimap"]],["impl<K> !Send for Multiset<K>",1,["rb::map::Multiset"]],["impl<O> !Send for Seg<O>",1,["rb::seq::Seg"]]], "rbtree":[["impl<T, O> Send for RbTree<T, O>where\n T: Send,\n <O as Op>::Summary: Send,",1,["rbtree::RbTree"]],["impl<T> Send for Nop<T>",1,["rbtree::Nop"]],["impl<'a, T, O> Send for Iter<'a, T, O>where\n T: Sync,\n <O as Op>::Summary: Sync,",1,["rbtree::Iter"]]], -"scc":[["impl Send for Scc",1,["scc::Scc"]]], "segbeats":[["impl<T> Send for Segbeats<T>where\n T: Send,",1,["segbeats::Segbeats"]]], "segbeats_task3":[["impl<T> Send for Segbeats<T>where\n T: Send,",1,["segbeats_task3::Segbeats"]]], "segtree":[["impl<O> Send for Segtree<O>where\n <O as Op>::Value: Send,",1,["segtree::Segtree"]],["impl<'a, O> Send for Entry<'a, O>where\n <O as Op>::Value: Send,",1,["segtree::Entry"]],["impl<K, O> Send for SegtreeWithCompression<K, O>where\n K: Send,\n <O as Op>::Value: Send,",1,["segtree::SegtreeWithCompression"]],["impl<K, L, O> Send for Sparse2dSegtree<K, L, O>where\n K: Send,\n L: Send,\n <O as Op>::Value: Send,",1,["segtree::Sparse2dSegtree"]],["impl<O> Send for Dense2dSegtree<O>where\n <O as Op>::Value: Send,",1,["segtree::Dense2dSegtree"]],["impl<'a, O> Send for Dense2dEntry<'a, O>where\n <O as Op>::Value: Send,",1,["segtree::Dense2dEntry"]]], @@ -40,7 +40,6 @@ "tree_fold":[["impl<T> Send for TwoWayTreeFoldResult<T>where\n T: Send,",1,["tree_fold::TwoWayTreeFoldResult"]]], "trial":[["impl<T> Send for Divisors<T>where\n T: Send,",1,["trial::divisors::Divisors"]],["impl<T> Send for PrimeFactorsRle<T>where\n T: Send,",1,["trial::prime_factors::PrimeFactorsRle"]],["impl<T> Send for PrimeFactors<T>where\n T: Send,",1,["trial::prime_factors::PrimeFactors"]]], "trie":[["impl<V> Send for TrieMap<V>where\n V: Send,",1,["trie::trie_map::TrieMap"]],["impl Send for TrieSet",1,["trie::trie_set::TrieSet"]]], -"two_sat":[["impl Send for TwoSat",1,["two_sat::TwoSat"]]], "uf_checklist":[["impl Send for UfChecklist",1,["uf_checklist::UfChecklist"]],["impl<'a> Send for Iter<'a>",1,["uf_checklist::Iter"]]], "union_find":[["impl Send for EdgeCount",1,["union_find::EdgeCount"]],["impl Send for VertexCount",1,["union_find::VertexCount"]],["impl Send for HasCycle",1,["union_find::HasCycle"]],["impl<O> Send for UnionFind<O>where\n <O as Op>::Value: Send,",1,["union_find::UnionFind"]]], "veb":[["impl<V> Send for VebMap<V>where\n V: Send,",1,["veb::VebMap"]],["impl Send for VebSet",1,["veb::VebSet"]]], diff --git a/implementors/core/marker/trait.StructuralEq.js b/implementors/core/marker/trait.StructuralEq.js index 63d43b57..56ec5d98 100644 --- a/implementors/core/marker/trait.StructuralEq.js +++ b/implementors/core/marker/trait.StructuralEq.js @@ -15,10 +15,8 @@ "low_link":[["impl StructuralEq for LowLink"]], "mincost_flow":[["impl StructuralEq for Edge"]], "radix_heap":[["impl<T> StructuralEq for RadixHeap<T>"]], -"scc":[["impl StructuralEq for Scc"]], "segbeats":[["impl<T> StructuralEq for Segbeats<T>"]], "segbeats_task3":[["impl<T> StructuralEq for Segbeats<T>"]], -"two_sat":[["impl StructuralEq for TwoSat"]], "vec_lines":[["impl<T> StructuralEq for Line<T>"],["impl<T, C> StructuralEq for VecLines<T, C>"],["impl StructuralEq for DecreasingTilt"],["impl StructuralEq for IncreasingTilt"]], "wavelet_matrix":[["impl StructuralEq for StaticBitVec"],["impl<'a> StructuralEq for Spans<'a>"],["impl<'a> StructuralEq for SpanInNode<'a>"],["impl StructuralEq for WaveletMatrix"]] };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/marker/trait.StructuralPartialEq.js b/implementors/core/marker/trait.StructuralPartialEq.js index b1e6c69e..e7839a83 100644 --- a/implementors/core/marker/trait.StructuralPartialEq.js +++ b/implementors/core/marker/trait.StructuralPartialEq.js @@ -17,13 +17,11 @@ "low_link":[["impl StructuralPartialEq for LowLink"]], "mincost_flow":[["impl StructuralPartialEq for Edge"],["impl StructuralPartialEq for MinCostFlow"]], "radix_heap":[["impl<T> StructuralPartialEq for RadixHeap<T>"]], -"scc":[["impl StructuralPartialEq for Scc"]], "segbeats":[["impl<T> StructuralPartialEq for Segbeats<T>"]], "segbeats_task3":[["impl<T> StructuralPartialEq for Segbeats<T>"]], "skew_heap":[["impl<T> StructuralPartialEq for SkewHeap<T>"]], "snippetter":[["impl StructuralPartialEq for CrateMetadata"]], "trie":[["impl StructuralPartialEq for TrieSet"],["impl<V> StructuralPartialEq for TrieMap<V>"]], -"two_sat":[["impl StructuralPartialEq for TwoSat"]], "union_find":[["impl<O: Op> StructuralPartialEq for UnionFind<O>"]], "vec_lines":[["impl<T, C> StructuralPartialEq for VecLines<T, C>"],["impl<T> StructuralPartialEq for Line<T>"],["impl StructuralPartialEq for IncreasingTilt"],["impl StructuralPartialEq for DecreasingTilt"]], "wavelet_matrix":[["impl<'a> StructuralPartialEq for Spans<'a>"],["impl StructuralPartialEq for WaveletMatrix"],["impl<'a> StructuralPartialEq for SpanInNode<'a>"],["impl StructuralPartialEq for StaticBitVec"]] diff --git a/implementors/core/marker/trait.Sync.js b/implementors/core/marker/trait.Sync.js index 9d683d1b..86ca3c10 100644 --- a/implementors/core/marker/trait.Sync.js +++ b/implementors/core/marker/trait.Sync.js @@ -10,6 +10,7 @@ "erato":[["impl<T, P> Sync for Unique<T, P>where\n P: Sync,\n T: Sync,",1,["erato::converters::Unique"]],["impl<T, P> Sync for Rle<T, P>where\n P: Sync,\n T: Sync,",1,["erato::converters::Rle"]],["impl Sync for LpdSieve",1,["erato::lpd_sieve::LpdSieve"]],["impl Sync for Sieve",1,["erato::sieve::Sieve"]],["impl<'a, S, T> Sync for PrimeNumbers<'a, S, T>where\n T: Sync,\n <S as SieveKind>::SieveValue: Sync,",1,["erato::sieve_base::PrimeNumbers"]],["impl<'a, T> Sync for PrimeFactorsByTrialDivision<'a, T>where\n T: Sync,",1,["erato::sieve_base::PrimeFactorsByTrialDivision"]],["impl<'a, T> Sync for PrimeFactorsByLookup<'a, T>where\n T: Sync,",1,["erato::sieve_base::PrimeFactorsByLookup"]]], "fp":[["impl<const P: u64> Sync for Factorial<P>",1,["fp::factorial::Factorial"]],["impl<const P: u64> Sync for Fp<P>",1,["fp::Fp"]]], "gco":[["impl Sync for Gco",1,["gco::Gco"]],["impl Sync for GcoResult",1,["gco::GcoResult"]]], +"graph":[["impl<T> Sync for Csr<T>where\n T: Sync,",1,["graph::csr::Csr"]],["impl<'a, T> Sync for LastMut<'a, T>where\n T: Sync,",1,["graph::csr::LastMut"]],["impl<'a, T> Sync for Iter<'a, T>where\n T: Sync,",1,["graph::csr::Iter"]]], "heap_slope_trick":[["impl Sync for HeapSlopeTrick",1,["heap_slope_trick::HeapSlopeTrick"]],["impl Sync for Summary",1,["heap_slope_trick::Summary"]]], "heap_tricks":[["impl Sync for Nop",1,["heap_tricks::Nop"]],["impl<T> Sync for Sum<T>where\n T: Sync,",1,["heap_tricks::Sum"]],["impl<T, H> Sync for DoubleHeap<T, H>where\n H: Sync,\n T: Sync,",1,["heap_tricks::DoubleHeap"]],["impl<T> Sync for RemovableHeap<T>where\n T: Sync,",1,["heap_tricks::RemovableHeap"]]], "hld":[["impl Sync for Hld",1,["hld::Hld"]],["impl<'a> Sync for PathSegments<'a>",1,["hld::PathSegments"]]], @@ -28,7 +29,6 @@ "rational":[["impl<T> Sync for Rational<T>where\n T: Sync,",1,["rational::Rational"]]], "rb":[["impl<K, O> !Sync for MultimapSeg<K, O>",1,["rb::map::MultimapSeg"]],["impl<K, V> !Sync for Multimap<K, V>",1,["rb::map::Multimap"]],["impl<K> !Sync for Multiset<K>",1,["rb::map::Multiset"]],["impl<O> !Sync for Seg<O>",1,["rb::seq::Seg"]]], "rbtree":[["impl<T, O> Sync for RbTree<T, O>where\n T: Sync,\n <O as Op>::Summary: Sync,",1,["rbtree::RbTree"]],["impl<T> Sync for Nop<T>",1,["rbtree::Nop"]],["impl<'a, T, O> Sync for Iter<'a, T, O>where\n T: Sync,\n <O as Op>::Summary: Sync,",1,["rbtree::Iter"]]], -"scc":[["impl Sync for Scc",1,["scc::Scc"]]], "segbeats":[["impl<T> !Sync for Segbeats<T>",1,["segbeats::Segbeats"]]], "segbeats_task3":[["impl<T> !Sync for Segbeats<T>",1,["segbeats_task3::Segbeats"]]], "segtree":[["impl<O> Sync for Segtree<O>where\n <O as Op>::Value: Sync,",1,["segtree::Segtree"]],["impl<'a, O> Sync for Entry<'a, O>where\n <O as Op>::Value: Sync,",1,["segtree::Entry"]],["impl<K, O> Sync for SegtreeWithCompression<K, O>where\n K: Sync,\n <O as Op>::Value: Sync,",1,["segtree::SegtreeWithCompression"]],["impl<K, L, O> Sync for Sparse2dSegtree<K, L, O>where\n K: Sync,\n L: Sync,\n <O as Op>::Value: Sync,",1,["segtree::Sparse2dSegtree"]],["impl<O> Sync for Dense2dSegtree<O>where\n <O as Op>::Value: Sync,",1,["segtree::Dense2dSegtree"]],["impl<'a, O> Sync for Dense2dEntry<'a, O>where\n <O as Op>::Value: Sync,",1,["segtree::Dense2dEntry"]]], @@ -40,7 +40,6 @@ "tree_fold":[["impl<T> Sync for TwoWayTreeFoldResult<T>where\n T: Sync,",1,["tree_fold::TwoWayTreeFoldResult"]]], "trial":[["impl<T> Sync for Divisors<T>where\n T: Sync,",1,["trial::divisors::Divisors"]],["impl<T> Sync for PrimeFactorsRle<T>where\n T: Sync,",1,["trial::prime_factors::PrimeFactorsRle"]],["impl<T> Sync for PrimeFactors<T>where\n T: Sync,",1,["trial::prime_factors::PrimeFactors"]]], "trie":[["impl<V> Sync for TrieMap<V>where\n V: Sync,",1,["trie::trie_map::TrieMap"]],["impl Sync for TrieSet",1,["trie::trie_set::TrieSet"]]], -"two_sat":[["impl Sync for TwoSat",1,["two_sat::TwoSat"]]], "uf_checklist":[["impl Sync for UfChecklist",1,["uf_checklist::UfChecklist"]],["impl<'a> Sync for Iter<'a>",1,["uf_checklist::Iter"]]], "union_find":[["impl Sync for EdgeCount",1,["union_find::EdgeCount"]],["impl Sync for VertexCount",1,["union_find::VertexCount"]],["impl Sync for HasCycle",1,["union_find::HasCycle"]],["impl<O> Sync for UnionFind<O>where\n <O as Op>::Value: Sync,",1,["union_find::UnionFind"]]], "veb":[["impl<V> Sync for VebMap<V>where\n V: Sync,",1,["veb::VebMap"]],["impl Sync for VebSet",1,["veb::VebSet"]]], diff --git a/implementors/core/marker/trait.Unpin.js b/implementors/core/marker/trait.Unpin.js index 2151c168..b3d0c91b 100644 --- a/implementors/core/marker/trait.Unpin.js +++ b/implementors/core/marker/trait.Unpin.js @@ -10,6 +10,7 @@ "erato":[["impl<T, P> Unpin for Unique<T, P>where\n P: Unpin,\n T: Unpin,",1,["erato::converters::Unique"]],["impl<T, P> Unpin for Rle<T, P>where\n P: Unpin,\n T: Unpin,",1,["erato::converters::Rle"]],["impl Unpin for LpdSieve",1,["erato::lpd_sieve::LpdSieve"]],["impl Unpin for Sieve",1,["erato::sieve::Sieve"]],["impl<'a, S, T> Unpin for PrimeNumbers<'a, S, T>where\n T: Unpin,",1,["erato::sieve_base::PrimeNumbers"]],["impl<'a, T> Unpin for PrimeFactorsByTrialDivision<'a, T>where\n T: Unpin,",1,["erato::sieve_base::PrimeFactorsByTrialDivision"]],["impl<'a, T> Unpin for PrimeFactorsByLookup<'a, T>where\n T: Unpin,",1,["erato::sieve_base::PrimeFactorsByLookup"]]], "fp":[["impl<const P: u64> Unpin for Factorial<P>",1,["fp::factorial::Factorial"]],["impl<const P: u64> Unpin for Fp<P>",1,["fp::Fp"]]], "gco":[["impl Unpin for Gco",1,["gco::Gco"]],["impl Unpin for GcoResult",1,["gco::GcoResult"]]], +"graph":[["impl<T> Unpin for Csr<T>where\n T: Unpin,",1,["graph::csr::Csr"]],["impl<'a, T> Unpin for LastMut<'a, T>",1,["graph::csr::LastMut"]],["impl<'a, T> Unpin for Iter<'a, T>",1,["graph::csr::Iter"]]], "heap_slope_trick":[["impl Unpin for HeapSlopeTrick",1,["heap_slope_trick::HeapSlopeTrick"]],["impl Unpin for Summary",1,["heap_slope_trick::Summary"]]], "heap_tricks":[["impl Unpin for Nop",1,["heap_tricks::Nop"]],["impl<T> Unpin for Sum<T>where\n T: Unpin,",1,["heap_tricks::Sum"]],["impl<T, H> Unpin for DoubleHeap<T, H>where\n H: Unpin,\n T: Unpin,",1,["heap_tricks::DoubleHeap"]],["impl<T> Unpin for RemovableHeap<T>where\n T: Unpin,",1,["heap_tricks::RemovableHeap"]]], "hld":[["impl Unpin for Hld",1,["hld::Hld"]],["impl<'a> Unpin for PathSegments<'a>",1,["hld::PathSegments"]]], @@ -28,7 +29,6 @@ "rational":[["impl<T> Unpin for Rational<T>where\n T: Unpin,",1,["rational::Rational"]]], "rb":[["impl<K, O> Unpin for MultimapSeg<K, O>",1,["rb::map::MultimapSeg"]],["impl<K, V> Unpin for Multimap<K, V>",1,["rb::map::Multimap"]],["impl<K> Unpin for Multiset<K>",1,["rb::map::Multiset"]],["impl<O> Unpin for Seg<O>",1,["rb::seq::Seg"]]], "rbtree":[["impl<T, O> Unpin for RbTree<T, O>where\n T: Unpin,",1,["rbtree::RbTree"]],["impl<T> Unpin for Nop<T>",1,["rbtree::Nop"]],["impl<'a, T, O> Unpin for Iter<'a, T, O>",1,["rbtree::Iter"]]], -"scc":[["impl Unpin for Scc",1,["scc::Scc"]]], "segbeats":[["impl<T> Unpin for Segbeats<T>where\n T: Unpin,",1,["segbeats::Segbeats"]]], "segbeats_task3":[["impl<T> Unpin for Segbeats<T>where\n T: Unpin,",1,["segbeats_task3::Segbeats"]]], "segtree":[["impl<O> Unpin for Segtree<O>where\n <O as Op>::Value: Unpin,",1,["segtree::Segtree"]],["impl<'a, O> Unpin for Entry<'a, O>",1,["segtree::Entry"]],["impl<K, O> Unpin for SegtreeWithCompression<K, O>where\n K: Unpin,\n <O as Op>::Value: Unpin,",1,["segtree::SegtreeWithCompression"]],["impl<K, L, O> Unpin for Sparse2dSegtree<K, L, O>where\n K: Unpin,\n L: Unpin,\n <O as Op>::Value: Unpin,",1,["segtree::Sparse2dSegtree"]],["impl<O> Unpin for Dense2dSegtree<O>where\n <O as Op>::Value: Unpin,",1,["segtree::Dense2dSegtree"]],["impl<'a, O> Unpin for Dense2dEntry<'a, O>",1,["segtree::Dense2dEntry"]]], @@ -40,7 +40,6 @@ "tree_fold":[["impl<T> Unpin for TwoWayTreeFoldResult<T>where\n T: Unpin,",1,["tree_fold::TwoWayTreeFoldResult"]]], "trial":[["impl<T> Unpin for Divisors<T>where\n T: Unpin,",1,["trial::divisors::Divisors"]],["impl<T> Unpin for PrimeFactorsRle<T>where\n T: Unpin,",1,["trial::prime_factors::PrimeFactorsRle"]],["impl<T> Unpin for PrimeFactors<T>where\n T: Unpin,",1,["trial::prime_factors::PrimeFactors"]]], "trie":[["impl<V> Unpin for TrieMap<V>",1,["trie::trie_map::TrieMap"]],["impl Unpin for TrieSet",1,["trie::trie_set::TrieSet"]]], -"two_sat":[["impl Unpin for TwoSat",1,["two_sat::TwoSat"]]], "uf_checklist":[["impl Unpin for UfChecklist",1,["uf_checklist::UfChecklist"]],["impl<'a> Unpin for Iter<'a>",1,["uf_checklist::Iter"]]], "union_find":[["impl Unpin for EdgeCount",1,["union_find::EdgeCount"]],["impl Unpin for VertexCount",1,["union_find::VertexCount"]],["impl Unpin for HasCycle",1,["union_find::HasCycle"]],["impl<O> Unpin for UnionFind<O>where\n <O as Op>::Value: Unpin,",1,["union_find::UnionFind"]]], "veb":[["impl<V> Unpin for VebMap<V>where\n V: Unpin,",1,["veb::VebMap"]],["impl Unpin for VebSet",1,["veb::VebSet"]]], diff --git a/implementors/core/ops/deref/trait.Deref.js b/implementors/core/ops/deref/trait.Deref.js index ca12f9e3..692ff443 100644 --- a/implementors/core/ops/deref/trait.Deref.js +++ b/implementors/core/ops/deref/trait.Deref.js @@ -1,4 +1,5 @@ (function() {var implementors = { +"graph":[["impl<T> Deref for LastMut<'_, T>"]], "segtree":[["impl<'a, O: Op> Deref for Dense2dEntry<'a, O>"],["impl<'a, O: Op> Deref for Entry<'a, O>"]], "splay_tree":[["impl<O: LazyOps> Deref for Entry<'_, O>"]] };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/ops/deref/trait.DerefMut.js b/implementors/core/ops/deref/trait.DerefMut.js index 5bfe649b..e1422635 100644 --- a/implementors/core/ops/deref/trait.DerefMut.js +++ b/implementors/core/ops/deref/trait.DerefMut.js @@ -1,4 +1,5 @@ (function() {var implementors = { +"graph":[["impl<T> DerefMut for LastMut<'_, T>"]], "segtree":[["impl<'a, O: Op> DerefMut for Dense2dEntry<'a, O>"],["impl<'a, O: Op> DerefMut for Entry<'a, O>"]], "splay_tree":[["impl<O: LazyOps> DerefMut for Entry<'_, O>"]] };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/ops/index/trait.Index.js b/implementors/core/ops/index/trait.Index.js index 9a522663..5445ab06 100644 --- a/implementors/core/ops/index/trait.Index.js +++ b/implementors/core/ops/index/trait.Index.js @@ -1,6 +1,7 @@ (function() {var implementors = { "avl_tree":[["impl<T> Index<usize> for AvlTree<T>"]], "fp":[["impl<const P: u64> Index<usize> for Factorial<P>"]], +"graph":[["impl<T> Index<usize> for Csr<T>"]], "segtree":[["impl<O: Op> Index<usize> for Segtree<O>"],["impl<K: Ord, L: Ord, O: Op> Index<(K, L)> for Sparse2dSegtree<K, L, O>"],["impl<K: Ord, L: Ord, O: Op> Index<K> for Sparse2dSegtree<K, L, O>"],["impl<O: Op> Index<usize> for Dense2dSegtree<O>"],["impl<K: Ord, O: Op> Index<K> for SegtreeWithCompression<K, O>"]], "sparse_table":[["impl<O: Op> Index<usize> for SparseTable<O>"]], "splay_tree":[["impl<O: LazyOps> Index<usize> for SplayTree<O>"]], diff --git a/implementors/core/ops/index/trait.IndexMut.js b/implementors/core/ops/index/trait.IndexMut.js index 0d16e7f4..90ca173b 100644 --- a/implementors/core/ops/index/trait.IndexMut.js +++ b/implementors/core/ops/index/trait.IndexMut.js @@ -1,3 +1,4 @@ (function() {var implementors = { +"graph":[["impl<T> IndexMut<usize> for Csr<T>"]], "veb":[["impl<V> IndexMut<usize> for VebMap<V>"]] };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js b/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js index 88784dc8..00a17ad2 100644 --- a/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js +++ b/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js @@ -10,6 +10,7 @@ "erato":[["impl<T, P> RefUnwindSafe for Unique<T, P>where\n P: RefUnwindSafe,\n T: RefUnwindSafe,",1,["erato::converters::Unique"]],["impl<T, P> RefUnwindSafe for Rle<T, P>where\n P: RefUnwindSafe,\n T: RefUnwindSafe,",1,["erato::converters::Rle"]],["impl RefUnwindSafe for LpdSieve",1,["erato::lpd_sieve::LpdSieve"]],["impl RefUnwindSafe for Sieve",1,["erato::sieve::Sieve"]],["impl<'a, S, T> RefUnwindSafe for PrimeNumbers<'a, S, T>where\n T: RefUnwindSafe,\n <S as SieveKind>::SieveValue: RefUnwindSafe,",1,["erato::sieve_base::PrimeNumbers"]],["impl<'a, T> RefUnwindSafe for PrimeFactorsByTrialDivision<'a, T>where\n T: RefUnwindSafe,",1,["erato::sieve_base::PrimeFactorsByTrialDivision"]],["impl<'a, T> RefUnwindSafe for PrimeFactorsByLookup<'a, T>where\n T: RefUnwindSafe,",1,["erato::sieve_base::PrimeFactorsByLookup"]]], "fp":[["impl<const P: u64> RefUnwindSafe for Factorial<P>",1,["fp::factorial::Factorial"]],["impl<const P: u64> RefUnwindSafe for Fp<P>",1,["fp::Fp"]]], "gco":[["impl RefUnwindSafe for Gco",1,["gco::Gco"]],["impl RefUnwindSafe for GcoResult",1,["gco::GcoResult"]]], +"graph":[["impl<T> RefUnwindSafe for Csr<T>where\n T: RefUnwindSafe,",1,["graph::csr::Csr"]],["impl<'a, T> RefUnwindSafe for LastMut<'a, T>where\n T: RefUnwindSafe,",1,["graph::csr::LastMut"]],["impl<'a, T> RefUnwindSafe for Iter<'a, T>where\n T: RefUnwindSafe,",1,["graph::csr::Iter"]]], "heap_slope_trick":[["impl RefUnwindSafe for HeapSlopeTrick",1,["heap_slope_trick::HeapSlopeTrick"]],["impl RefUnwindSafe for Summary",1,["heap_slope_trick::Summary"]]], "heap_tricks":[["impl RefUnwindSafe for Nop",1,["heap_tricks::Nop"]],["impl<T> RefUnwindSafe for Sum<T>where\n T: RefUnwindSafe,",1,["heap_tricks::Sum"]],["impl<T, H> RefUnwindSafe for DoubleHeap<T, H>where\n H: RefUnwindSafe,\n T: RefUnwindSafe,",1,["heap_tricks::DoubleHeap"]],["impl<T> RefUnwindSafe for RemovableHeap<T>where\n T: RefUnwindSafe,",1,["heap_tricks::RemovableHeap"]]], "hld":[["impl RefUnwindSafe for Hld",1,["hld::Hld"]],["impl<'a> RefUnwindSafe for PathSegments<'a>",1,["hld::PathSegments"]]], @@ -28,7 +29,6 @@ "rational":[["impl<T> RefUnwindSafe for Rational<T>where\n T: RefUnwindSafe,",1,["rational::Rational"]]], "rb":[["impl<K, O> RefUnwindSafe for MultimapSeg<K, O>where\n K: RefUnwindSafe,\n <O as MultimapOp>::Acc: RefUnwindSafe,\n <O as MultimapOp>::Value: RefUnwindSafe,",1,["rb::map::MultimapSeg"]],["impl<K, V> RefUnwindSafe for Multimap<K, V>where\n K: RefUnwindSafe,\n V: RefUnwindSafe,",1,["rb::map::Multimap"]],["impl<K> RefUnwindSafe for Multiset<K>where\n K: RefUnwindSafe,",1,["rb::map::Multiset"]],["impl<O> RefUnwindSafe for Seg<O>where\n <O as Op>::Value: RefUnwindSafe,",1,["rb::seq::Seg"]]], "rbtree":[["impl<T, O> RefUnwindSafe for RbTree<T, O>where\n T: RefUnwindSafe,\n <O as Op>::Summary: RefUnwindSafe,",1,["rbtree::RbTree"]],["impl<T> RefUnwindSafe for Nop<T>",1,["rbtree::Nop"]],["impl<'a, T, O> RefUnwindSafe for Iter<'a, T, O>where\n T: RefUnwindSafe,\n <O as Op>::Summary: RefUnwindSafe,",1,["rbtree::Iter"]]], -"scc":[["impl RefUnwindSafe for Scc",1,["scc::Scc"]]], "segbeats":[["impl<T> !RefUnwindSafe for Segbeats<T>",1,["segbeats::Segbeats"]]], "segbeats_task3":[["impl<T> !RefUnwindSafe for Segbeats<T>",1,["segbeats_task3::Segbeats"]]], "segtree":[["impl<O> RefUnwindSafe for Segtree<O>where\n <O as Op>::Value: RefUnwindSafe,",1,["segtree::Segtree"]],["impl<'a, O> RefUnwindSafe for Entry<'a, O>where\n <O as Op>::Value: RefUnwindSafe,",1,["segtree::Entry"]],["impl<K, O> RefUnwindSafe for SegtreeWithCompression<K, O>where\n K: RefUnwindSafe,\n <O as Op>::Value: RefUnwindSafe,",1,["segtree::SegtreeWithCompression"]],["impl<K, L, O> RefUnwindSafe for Sparse2dSegtree<K, L, O>where\n K: RefUnwindSafe,\n L: RefUnwindSafe,\n <O as Op>::Value: RefUnwindSafe,",1,["segtree::Sparse2dSegtree"]],["impl<O> RefUnwindSafe for Dense2dSegtree<O>where\n <O as Op>::Value: RefUnwindSafe,",1,["segtree::Dense2dSegtree"]],["impl<'a, O> RefUnwindSafe for Dense2dEntry<'a, O>where\n <O as Op>::Value: RefUnwindSafe,",1,["segtree::Dense2dEntry"]]], @@ -40,7 +40,6 @@ "tree_fold":[["impl<T> RefUnwindSafe for TwoWayTreeFoldResult<T>where\n T: RefUnwindSafe,",1,["tree_fold::TwoWayTreeFoldResult"]]], "trial":[["impl<T> RefUnwindSafe for Divisors<T>where\n T: RefUnwindSafe,",1,["trial::divisors::Divisors"]],["impl<T> RefUnwindSafe for PrimeFactorsRle<T>where\n T: RefUnwindSafe,",1,["trial::prime_factors::PrimeFactorsRle"]],["impl<T> RefUnwindSafe for PrimeFactors<T>where\n T: RefUnwindSafe,",1,["trial::prime_factors::PrimeFactors"]]], "trie":[["impl<V> RefUnwindSafe for TrieMap<V>where\n V: RefUnwindSafe,",1,["trie::trie_map::TrieMap"]],["impl RefUnwindSafe for TrieSet",1,["trie::trie_set::TrieSet"]]], -"two_sat":[["impl RefUnwindSafe for TwoSat",1,["two_sat::TwoSat"]]], "uf_checklist":[["impl RefUnwindSafe for UfChecklist",1,["uf_checklist::UfChecklist"]],["impl<'a> RefUnwindSafe for Iter<'a>",1,["uf_checklist::Iter"]]], "union_find":[["impl RefUnwindSafe for EdgeCount",1,["union_find::EdgeCount"]],["impl RefUnwindSafe for VertexCount",1,["union_find::VertexCount"]],["impl RefUnwindSafe for HasCycle",1,["union_find::HasCycle"]],["impl<O> RefUnwindSafe for UnionFind<O>where\n <O as Op>::Value: RefUnwindSafe,",1,["union_find::UnionFind"]]], "veb":[["impl<V> RefUnwindSafe for VebMap<V>where\n V: RefUnwindSafe,",1,["veb::VebMap"]],["impl RefUnwindSafe for VebSet",1,["veb::VebSet"]]], diff --git a/implementors/core/panic/unwind_safe/trait.UnwindSafe.js b/implementors/core/panic/unwind_safe/trait.UnwindSafe.js index 8711c618..4eae4b1f 100644 --- a/implementors/core/panic/unwind_safe/trait.UnwindSafe.js +++ b/implementors/core/panic/unwind_safe/trait.UnwindSafe.js @@ -10,6 +10,7 @@ "erato":[["impl<T, P> UnwindSafe for Unique<T, P>where\n P: UnwindSafe,\n T: UnwindSafe,",1,["erato::converters::Unique"]],["impl<T, P> UnwindSafe for Rle<T, P>where\n P: UnwindSafe,\n T: UnwindSafe,",1,["erato::converters::Rle"]],["impl UnwindSafe for LpdSieve",1,["erato::lpd_sieve::LpdSieve"]],["impl UnwindSafe for Sieve",1,["erato::sieve::Sieve"]],["impl<'a, S, T> !UnwindSafe for PrimeNumbers<'a, S, T>",1,["erato::sieve_base::PrimeNumbers"]],["impl<'a, T> !UnwindSafe for PrimeFactorsByTrialDivision<'a, T>",1,["erato::sieve_base::PrimeFactorsByTrialDivision"]],["impl<'a, T> !UnwindSafe for PrimeFactorsByLookup<'a, T>",1,["erato::sieve_base::PrimeFactorsByLookup"]]], "fp":[["impl<const P: u64> UnwindSafe for Factorial<P>",1,["fp::factorial::Factorial"]],["impl<const P: u64> UnwindSafe for Fp<P>",1,["fp::Fp"]]], "gco":[["impl UnwindSafe for Gco",1,["gco::Gco"]],["impl UnwindSafe for GcoResult",1,["gco::GcoResult"]]], +"graph":[["impl<T> UnwindSafe for Csr<T>where\n T: UnwindSafe,",1,["graph::csr::Csr"]],["impl<'a, T> !UnwindSafe for LastMut<'a, T>",1,["graph::csr::LastMut"]],["impl<'a, T> UnwindSafe for Iter<'a, T>where\n T: RefUnwindSafe,",1,["graph::csr::Iter"]]], "heap_slope_trick":[["impl UnwindSafe for HeapSlopeTrick",1,["heap_slope_trick::HeapSlopeTrick"]],["impl UnwindSafe for Summary",1,["heap_slope_trick::Summary"]]], "heap_tricks":[["impl UnwindSafe for Nop",1,["heap_tricks::Nop"]],["impl<T> UnwindSafe for Sum<T>where\n T: UnwindSafe,",1,["heap_tricks::Sum"]],["impl<T, H> UnwindSafe for DoubleHeap<T, H>where\n H: UnwindSafe,\n T: UnwindSafe,",1,["heap_tricks::DoubleHeap"]],["impl<T> UnwindSafe for RemovableHeap<T>where\n T: UnwindSafe,",1,["heap_tricks::RemovableHeap"]]], "hld":[["impl UnwindSafe for Hld",1,["hld::Hld"]],["impl<'a> UnwindSafe for PathSegments<'a>",1,["hld::PathSegments"]]], @@ -28,7 +29,6 @@ "rational":[["impl<T> UnwindSafe for Rational<T>where\n T: UnwindSafe,",1,["rational::Rational"]]], "rb":[["impl<K, O> UnwindSafe for MultimapSeg<K, O>where\n K: RefUnwindSafe,\n <O as MultimapOp>::Acc: RefUnwindSafe,\n <O as MultimapOp>::Value: RefUnwindSafe,",1,["rb::map::MultimapSeg"]],["impl<K, V> UnwindSafe for Multimap<K, V>where\n K: RefUnwindSafe,\n V: RefUnwindSafe,",1,["rb::map::Multimap"]],["impl<K> UnwindSafe for Multiset<K>where\n K: RefUnwindSafe,",1,["rb::map::Multiset"]],["impl<O> UnwindSafe for Seg<O>where\n <O as Op>::Value: RefUnwindSafe,",1,["rb::seq::Seg"]]], "rbtree":[["impl<T, O> UnwindSafe for RbTree<T, O>where\n T: UnwindSafe,\n <O as Op>::Summary: UnwindSafe,",1,["rbtree::RbTree"]],["impl<T> UnwindSafe for Nop<T>",1,["rbtree::Nop"]],["impl<'a, T, O> UnwindSafe for Iter<'a, T, O>where\n T: RefUnwindSafe,\n <O as Op>::Summary: RefUnwindSafe,",1,["rbtree::Iter"]]], -"scc":[["impl UnwindSafe for Scc",1,["scc::Scc"]]], "segbeats":[["impl<T> UnwindSafe for Segbeats<T>where\n T: UnwindSafe,",1,["segbeats::Segbeats"]]], "segbeats_task3":[["impl<T> UnwindSafe for Segbeats<T>where\n T: UnwindSafe,",1,["segbeats_task3::Segbeats"]]], "segtree":[["impl<O> UnwindSafe for Segtree<O>where\n <O as Op>::Value: UnwindSafe,",1,["segtree::Segtree"]],["impl<'a, O> !UnwindSafe for Entry<'a, O>",1,["segtree::Entry"]],["impl<K, O> UnwindSafe for SegtreeWithCompression<K, O>where\n K: UnwindSafe,\n <O as Op>::Value: UnwindSafe,",1,["segtree::SegtreeWithCompression"]],["impl<K, L, O> UnwindSafe for Sparse2dSegtree<K, L, O>where\n K: UnwindSafe,\n L: UnwindSafe,\n <O as Op>::Value: UnwindSafe,",1,["segtree::Sparse2dSegtree"]],["impl<O> UnwindSafe for Dense2dSegtree<O>where\n <O as Op>::Value: UnwindSafe,",1,["segtree::Dense2dSegtree"]],["impl<'a, O> !UnwindSafe for Dense2dEntry<'a, O>",1,["segtree::Dense2dEntry"]]], @@ -40,7 +40,6 @@ "tree_fold":[["impl<T> UnwindSafe for TwoWayTreeFoldResult<T>where\n T: UnwindSafe,",1,["tree_fold::TwoWayTreeFoldResult"]]], "trial":[["impl<T> UnwindSafe for Divisors<T>where\n T: UnwindSafe,",1,["trial::divisors::Divisors"]],["impl<T> UnwindSafe for PrimeFactorsRle<T>where\n T: UnwindSafe,",1,["trial::prime_factors::PrimeFactorsRle"]],["impl<T> UnwindSafe for PrimeFactors<T>where\n T: UnwindSafe,",1,["trial::prime_factors::PrimeFactors"]]], "trie":[["impl<V> UnwindSafe for TrieMap<V>where\n V: UnwindSafe,",1,["trie::trie_map::TrieMap"]],["impl UnwindSafe for TrieSet",1,["trie::trie_set::TrieSet"]]], -"two_sat":[["impl UnwindSafe for TwoSat",1,["two_sat::TwoSat"]]], "uf_checklist":[["impl UnwindSafe for UfChecklist",1,["uf_checklist::UfChecklist"]],["impl<'a> !UnwindSafe for Iter<'a>",1,["uf_checklist::Iter"]]], "union_find":[["impl UnwindSafe for EdgeCount",1,["union_find::EdgeCount"]],["impl UnwindSafe for VertexCount",1,["union_find::VertexCount"]],["impl UnwindSafe for HasCycle",1,["union_find::HasCycle"]],["impl<O> UnwindSafe for UnionFind<O>where\n <O as Op>::Value: UnwindSafe,",1,["union_find::UnionFind"]]], "veb":[["impl<V> UnwindSafe for VebMap<V>where\n V: UnwindSafe,",1,["veb::VebMap"]],["impl UnwindSafe for VebSet",1,["veb::VebSet"]]], diff --git a/riff/fn.i2powm1.html b/riff/fn.i2powm1.html index 1a6133fa..7f4bb34e 100644 --- a/riff/fn.i2powm1.html +++ b/riff/fn.i2powm1.html @@ -32,11 +32,13 @@ }); -

Function riff::i2powm1

source ·
pub fn i2powm1<T: Unsigned>(n: u32) -> T
Expand description

Returns $2^n - 1$.

+

Function riff::i2powm1

source ·
pub fn i2powm1<T: Unsigned>(n: u32) -> T
Expand description

Returns $2^n - 1$.

Examples

-
use crate::i2powm1;
+
use riff::i2powm1;
 assert_eq!(i2powm1::<u32>(0), 0);
 assert_eq!(i2powm1::<u32>(1), 1);
 assert_eq!(i2powm1::<u32>(2), 3);
-assert_eq!(i2powm1::<u32>(3), 7);
+assert_eq!(i2powm1::<u32>(3), 7); +assert_eq!(i2powm1::<u32>(31), 0x7FFF_FFFF); +assert_eq!(i2powm1::<u32>(32), 0xFFFF_FFFF);
\ No newline at end of file diff --git a/riff/trait.Unsigned.html b/riff/trait.Unsigned.html index b0745e41..4ec20e1d 100644 --- a/riff/trait.Unsigned.html +++ b/riff/trait.Unsigned.html @@ -32,16 +32,16 @@ }); -

Trait riff::Unsigned

source ·
pub trait Unsigned: Sized + PartialEq + PartialOrd + Debug + Clone + Copy + Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign + Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign + BitAnd<Output = Self> + BitAndAssign + BitOr<Output = Self> + BitOrAssign + BitXor<Output = Self> + BitXorAssign + Shl<u32, Output = Self> + ShlAssign<u32> + Shr<u32, Output = Self> + ShrAssign<u32> + Not<Output = Self> {
+

Trait riff::Unsigned

source ·
pub trait Unsigned: Sized + PartialEq + PartialOrd + Debug + Clone + Copy + Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign + Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign + BitAnd<Output = Self> + BitAndAssign + BitOr<Output = Self> + BitOrAssign + BitXor<Output = Self> + BitXorAssign + Shl<u32, Output = Self> + ShlAssign<u32> + Shr<u32, Output = Self> + ShrAssign<u32> + Not<Output = Self> {
     const BITS: u32;
     const MAX: Self;
+    const ZERO: Self;
+    const ONE: Self;
 
-    // Required methods
-    fn zero() -> Self;
-    fn one() -> Self;
-    fn wrapping_neg(self) -> Self;
+    // Required method
+    fn wrapping_neg(self) -> Self;
 
     // Provided method
     fn bit_length() -> u32 { ... }
 }
Expand description

Unsigned integer types.

-

Required Associated Constants§

source

const BITS: u32

source

const MAX: Self

Required Methods§

source

fn zero() -> Self

source

fn one() -> Self

source

fn wrapping_neg(self) -> Self

Provided Methods§

Implementations on Foreign Types§

source§

impl Unsigned for u8

source§

const BITS: u32 = 8u32

source§

const MAX: Self = 255u8

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for u16

source§

const BITS: u32 = 16u32

source§

const MAX: Self = 65_535u16

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for u128

source§

const BITS: u32 = 128u32

source§

const MAX: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for usize

source§

const BITS: u32 = 64u32

source§

const MAX: Self = 18_446_744_073_709_551_615usize

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for u32

source§

const BITS: u32 = 32u32

source§

const MAX: Self = 4_294_967_295u32

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for u64

source§

const BITS: u32 = 64u32

source§

const MAX: Self = 18_446_744_073_709_551_615u64

source§

fn zero() -> Self

source§

fn one() -> Self

source§

fn wrapping_neg(self) -> Self

Implementors§

\ No newline at end of file +

Required Associated Constants§

source

const BITS: u32

source

const MAX: Self

source

const ZERO: Self

source

const ONE: Self

Required Methods§

source

fn wrapping_neg(self) -> Self

Provided Methods§

Implementations on Foreign Types§

source§

impl Unsigned for u8

source§

const BITS: u32 = 8u32

source§

const MAX: Self = 255u8

source§

const ZERO: Self = 0u8

source§

const ONE: Self = 1u8

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for u16

source§

const BITS: u32 = 16u32

source§

const MAX: Self = 65_535u16

source§

const ZERO: Self = 0u16

source§

const ONE: Self = 1u16

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for u128

source§

const BITS: u32 = 128u32

source§

const MAX: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

source§

const ZERO: Self = 0u128

source§

const ONE: Self = 1u128

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for usize

source§

const BITS: u32 = 64u32

source§

const MAX: Self = 18_446_744_073_709_551_615usize

source§

const ZERO: Self = 0usize

source§

const ONE: Self = 1usize

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for u32

source§

const BITS: u32 = 32u32

source§

const MAX: Self = 4_294_967_295u32

source§

const ZERO: Self = 0u32

source§

const ONE: Self = 1u32

source§

fn wrapping_neg(self) -> Self

source§

impl Unsigned for u64

source§

const BITS: u32 = 64u32

source§

const MAX: Self = 18_446_744_073_709_551_615u64

source§

const ZERO: Self = 0u64

source§

const ONE: Self = 1u64

source§

fn wrapping_neg(self) -> Self

Implementors§

\ No newline at end of file diff --git a/scc/all.html b/scc/all.html deleted file mode 100644 index bc39ee6a..00000000 --- a/scc/all.html +++ /dev/null @@ -1,35 +0,0 @@ -List of all items in this crate
- - - - - -

List of all items

Structs

\ No newline at end of file diff --git a/scc/index.html b/scc/index.html deleted file mode 100644 index c8696580..00000000 --- a/scc/index.html +++ /dev/null @@ -1,54 +0,0 @@ -scc - Rust
- - - - - -

Crate scc

source ·
Expand description

このライブラリを使える問題

- -

Structs

  • 本体です。
\ No newline at end of file diff --git a/scc/sidebar-items.js b/scc/sidebar-items.js deleted file mode 100644 index a9c18628..00000000 --- a/scc/sidebar-items.js +++ /dev/null @@ -1 +0,0 @@ -window.SIDEBAR_ITEMS = {"struct":["Scc"]}; \ No newline at end of file diff --git a/scc/struct.Scc.html b/scc/struct.Scc.html deleted file mode 100644 index bdec0d2f..00000000 --- a/scc/struct.Scc.html +++ /dev/null @@ -1,206 +0,0 @@ -Scc in scc - Rust
- - - - - -

Struct scc::Scc

source ·
pub struct Scc { /* private fields */ }
Expand description

本体です。

-

Implementations§

source§

impl Scc

source

pub fn is_empty(&self) -> bool

管理しているグラフが空グラフならば、true を返します。

-
Example
-
use scc::Scc;
-
-let scc = Scc::new(0);
-assert!(scc.is_empty());
-
-let scc = Scc::new(1);
-assert!(!scc.is_empty());
-
source

pub fn len(&self) -> usize

管理しているグラフの頂点数を返します。

-
Example
-
use scc::Scc;
-
-let scc = Scc::new(0);
-assert_eq!(scc.len(), 0);
-
-let scc = Scc::new(1);
-assert_eq!(scc.len(), 1);
-
source

pub fn new(n: usize) -> Self

頂点数 n の辺のない未ビルドのグラフを構築します。

-
Example
-
use scc::Scc;
-
-let scc = Scc::new(42);
-
source

pub fn add_edge(&mut self, from: usize, to: usize)

【Require: 未ビルド】 -辺 (from, to) を追加します。

-
Example
-
use scc::Scc;
-
-let mut scc = Scc::new(42);
-scc.add_edge(13, 18);
-scc.add_edge(13, 6);
-assert_eq!(&scc.g()[13], &[18, 6]);
-assert_eq!(&scc.g()[6], &[]);
-
source

pub fn g(&self) -> &[Vec<usize>]

正向きのグラフの隣接リストを返します。

-
Example
-
use scc::Scc;
-
-let mut scc = Scc::new(42);
-scc.add_edge(13, 18);
-scc.add_edge(13, 6);
-assert_eq!(&scc.g()[13], &[18, 6]);
-assert_eq!(&scc.g()[6], &[]);
-
source

pub fn rg(&self) -> &[Vec<usize>]

逆向きのグラフの隣接リストを返します。

-
Example
-
use scc::Scc;
-
-let mut scc = Scc::new(42);
-scc.add_edge(13, 18);
-scc.add_edge(13, 6);
-assert_eq!(&scc.rg()[13], &[]);
-assert_eq!(&scc.rg()[6], &[13]);
-
source

pub fn ord(&self) -> &[usize]

【Require: ビルド済み】 -商グラフにおけるトポロジカル順序に従って頂点番号の入ったスライスを返します。

-
Example
-
use scc::Scc;
-
-let mut scc = Scc::new(6);
-scc.add_edge(2, 0);
-scc.add_edge(1, 0);
-scc.add_edge(3, 4);
-scc.add_edge(4, 5);
-scc.add_edge(5, 4);
-scc.build();
-assert_eq!(&scc.ord(), &[3, 4, 5, 2, 1, 0]);
-
source

pub fn cmp_count(&self) -> usize

【Require: ビルド済み】 -強連結成分の個数を返します。

-
Example
-
use scc::Scc;
-
-let mut scc = Scc::new(6);
-scc.add_edge(2, 0);
-scc.add_edge(1, 0);
-scc.add_edge(3, 4);
-scc.add_edge(4, 5);
-scc.add_edge(5, 4);
-scc.build();
-assert_eq!(scc.cmp_count(), 5);
-
source

pub fn cmp_of(&self, x: usize) -> usize

【Require: ビルド済み】 -頂点 x の属する強連結成分の番号を返します。

-
Example
-
use scc::Scc;
-
-let mut scc = Scc::new(6);
-scc.add_edge(2, 0);
-scc.add_edge(1, 0);
-scc.add_edge(3, 4);
-scc.add_edge(4, 5);
-scc.add_edge(5, 4);
-scc.build();
-assert_eq!(scc.cmp_of(0), 4);
-assert_eq!(scc.cmp_of(1), 3);
-
source

pub fn cmp_ofs(&self) -> &[usize]

【Require: ビルド済み】 -頂点番号から、その属する強連結成分の番号を検索できる -スライスを返します。

-
Example
-
use scc::Scc;
-
-let mut scc = Scc::new(6);
-scc.add_edge(2, 0);
-scc.add_edge(1, 0);
-scc.add_edge(3, 4);
-scc.add_edge(4, 5);
-scc.add_edge(5, 4);
-scc.build();
-assert_eq!(scc.cmp_of(0), 4);
-assert_eq!(scc.cmp_of(1), 3);
-
source

pub fn quotient_graph(&self) -> Vec<Vec<usize>>

【Require: ビルド済み】 -辺の重複と自己辺を除いた商グラフを構築して返します。

-
計算量
-

O(N)

-
Example
-
use scc::Scc;
-
-let mut scc = Scc::new(6);
-scc.add_edge(2, 0);
-scc.add_edge(1, 0);
-scc.add_edge(3, 4);
-scc.add_edge(4, 5);
-scc.add_edge(5, 4);
-scc.build();
-
-let g = scc.quotient_graph();
-let expected = vec![vec![1], vec![], vec![4], vec![4], vec![]];
-assert_eq!(g, expected);
-
source

pub fn quotient_set(&self) -> Vec<Vec<usize>>

【Require: ビルド済み】 -各強連結成分に属する頂点全体の集合を、Self::ord() と同じ -トポロジカル順序順序で返します。

-
計算量
-

O(N)

-
Example
-
use scc::Scc;
-
-let mut scc = Scc::new(6);
-scc.add_edge(2, 0);
-scc.add_edge(1, 0);
-scc.add_edge(3, 4);
-scc.add_edge(4, 5);
-scc.add_edge(5, 4);
-scc.build();
-
-let g = scc.quotient_set();
-let expected = vec![vec![3], vec![4, 5], vec![2], vec![1], vec![0]];
-assert_eq!(g, expected);
-
source

pub fn build(&mut self)

【Require: 未ビルド】 -ビルドします。

-
Examples
-
use scc::Scc;
-
-let mut scc = Scc::new(6);
-scc.add_edge(2, 0);
-scc.add_edge(1, 0);
-scc.add_edge(3, 4);
-scc.add_edge(4, 5);
-scc.add_edge(5, 4);
-scc.build();
-

Trait Implementations§

source§

impl Clone for Scc

source§

fn clone(&self) -> Scc

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Scc

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Scc

source§

fn default() -> Scc

Returns the “default value” for a type. Read more
source§

impl Hash for Scc

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where - H: Hasher, - Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Scc> for Scc

source§

fn eq(&self, other: &Scc) -> bool

This method tests for self and other values to be equal, and is used -by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always -sufficient, and should not be overridden without very good reason.
source§

impl Eq for Scc

source§

impl StructuralEq for Scc

source§

impl StructuralPartialEq for Scc

Auto Trait Implementations§

§

impl RefUnwindSafe for Scc

§

impl Send for Scc

§

impl Sync for Scc

§

impl Unpin for Scc

§

impl UnwindSafe for Scc

Blanket Implementations§

source§

impl<T> Any for Twhere - T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere - T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere - T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

-
source§

impl<T, U> Into<U> for Twhere - U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

-

That is, this conversion is whatever the implementation of -From<T> for U chooses to do.

-
source§

impl<T> ToOwned for Twhere - T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere - U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere - U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
\ No newline at end of file diff --git a/search-index.js b/search-index.js index 4cc2d625..a5ac512a 100644 --- a/search-index.js +++ b/search-index.js @@ -19,6 +19,7 @@ var searchIndex = JSON.parse('{\ "fp":{"doc":"A library for modular arithmetic.","t":"DDISLLLLLLFLLLLLLLLLLLLLLLLLFLLOFLLLLLLLLLLLLLLLFLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL","n":["Factorial","Fp","PrimitiveRoot","VALUE","add","add","add","add","add_assign","add_assign","any_mod_fps_mul","binom","binom_signed","borrow","borrow","borrow_mut","borrow_mut","clone","clone_into","div","div","div","div","div_assign","div_assign","eq","fact","falling","fft","fmt","fmt","fp","fps_mul","from","from","from","from","from","from","from","from","from","from","from","from","from","from","hash","ifft","index","into","into","inv","inv_fact","m1pow","mul","mul","mul","mul","mul_assign","mul_assign","multinom","multiset_number","neg","new","new","pow","product","product","sign","sub","sub","sub","sub","sub_assign","sub_assign","sum","sum","to_owned","to_string","try_from","try_from","try_into","try_into","type_id","type_id","value"],"q":[[0,"fp"]],"d":["Precomputes the factorials and their inverses.","A value in $\\\\mathbb{Fp}_p$.","A primitive root of unity.","A primitive root of unity.","","","","","","","Multiplies two polynomials.","$[x^k](1 + x)^n$.","$[x^k](1 + x)^n$.","","","","","","","","","","","","","","The factorial $n!$ Index is implemented for this method.","$[x^{n-k}]D^k x^n$.","Fast Fourier transform.","","","Constructs a new instance of Fp","Multiplies two polynomials.","Returns the argument unchanged.","","Returns the argument unchanged.","","","","","","","","","","","","","Inverse fast Fourier transform.","","Calls U::from(self).","Calls U::from(self).","Returns the multiplicative inverse.","The inverse of the factorial $n!$","$(-1) ^ e$.","","","","","","","$[x^{a_1} \\\\cdot x^{a_l}](x_{a_1} + \\\\cdot x_{a_l})^n$.","$[x^k](1 - x)^{-n}$.","","Constructs a new instance.","Constructs a new instance.","Returns the $n$-th power.","","","Returns $(-1)^{\\\\text{pow}}$.","","","","","","","","","","","","","","","","","Returns the value."],"i":[0,0,0,26,1,1,1,1,1,1,0,4,4,4,1,4,1,1,1,1,1,1,1,1,1,1,4,4,0,1,1,0,0,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,4,4,1,1,4,1,1,1,1,1,1,1,4,4,1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,1,4,1,4,1,1],"f":[0,0,0,0,[[1,[2,[1]]]],[[1,1]],[[1,1]],[[1,[2,[1]]]],[[1,1]],[[1,1]],[[],[[3,[1]]]],[[4,5,5],1],[[4,5,6],1],[[]],[[]],[[]],[[]],[1,1],[[]],[[1,1]],[[1,[2,[1]]]],[[1,1]],[[1,[2,[1]]]],[[1,1]],[[1,1]],[[1,1],7],[[4,5],1],[[4,5,5],1],[[]],[[1,8],9],[[1,8],9],0,[[10,10],[[3,[1]]]],[[]],[11,1],[[]],[12,1],[5,1],[13,1],[14,1],[15,1],[6,1],[16,1],[17,1],[18,1],[19,1],[20,1],[[1,21]],[[]],[[4,5]],[[]],[[]],[1,1],[[4,5],1],[5,1],[[1,1]],[[1,[2,[1]]]],[[1,[2,[1]]]],[[1,1]],[[1,1]],[[1,1]],[4,1],[[4,5,5],1],[1],[5,4],[12,1],[[1,12],1],[22,1],[22,1],[5,1],[[1,1]],[[1,[2,[1]]]],[[1,1]],[[1,[2,[1]]]],[[1,1]],[[1,1]],[22,1],[22,1],[[]],[[],23],[[],24],[[],24],[[],24],[[],24],[[],25],[[],25],[1,12]],"c":[],"p":[[3,"Fp"],[8,"Into"],[3,"Vec"],[3,"Factorial"],[15,"usize"],[15,"isize"],[15,"bool"],[3,"Formatter"],[6,"Result"],[8,"AsRef"],[15,"u16"],[15,"u64"],[15,"u8"],[15,"i16"],[15,"u32"],[15,"i128"],[15,"u128"],[15,"i8"],[15,"i64"],[15,"i32"],[8,"Hasher"],[8,"Iterator"],[3,"String"],[4,"Result"],[3,"TypeId"],[8,"PrimitiveRoot"]]},\ "fps":{"doc":"Arithmetic of formal power series.","t":"OFFFFFFF","n":["fps","fps_deriv","fps_exp","fps_int","fps_inv","fps_log","fps_pow","fps_sqrt"],"q":[[0,"fps"]],"d":["Define a formal power series in the same way as vec!.","Returns the derivative of a formal power series.","Returns the exponential of a formal power series.","Returns the integral of a formal power series with zero …","Returns the multiplicative inverse of a formal power …","Returns the logarithm of a formal power series.","Resutns the $n$-th power of a formal power series.","Returns the square root of a formal power series."],"i":[0,0,0,0,0,0,0,0],"f":[0,[[1,2],[[4,[3]]]],[[1,2],[[4,[3]]]],[[1,2],[[4,[3]]]],[[1,2],[[4,[3]]]],[[1,2],[[4,[3]]]],[[1,2,2],[[4,[3]]]],[[1,2],[[4,[3]]]]],"c":[],"p":[[8,"AsRef"],[15,"usize"],[3,"Fp"],[3,"Vec"]]},\ "gco":{"doc":"Solve a submodular graph cut optimizaion problem of degree …","t":"DDMLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLM","n":["Gco","GcoResult","args","binary","borrow","borrow","borrow_mut","borrow_mut","clone","clone","clone_into","clone_into","default","default","eq","eq","fmt","fmt","from","from","hash","hash","into","into","new","solve","to_owned","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","unary","value"],"q":[[0,"gco"]],"d":["A solver of graph cut optimization problems.","The minimum value and and an argmin of $f$.","An argmin","Add a binary term.","","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","","","Calls U::from(self).","Calls U::from(self).","Initialize a solver with $n$ terms.","Returns the minimum value and an argmin of $f$.","","","","","","","","","Add a unary term.","The minimum value"],"i":[0,0,2,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,1,1,2,1,2,1,2,1,2,1,2],"f":[0,0,0,[1],[[]],[[]],[[]],[[]],[1,1],[2,2],[[]],[[]],[[],1],[[],2],[[1,1],3],[[2,2],3],[[1,4],5],[[2,4],5],[[]],[[]],[[1,6]],[[2,6]],[[]],[[]],[7,1],[1,2],[[]],[[]],[[],8],[[],8],[[],8],[[],8],[[],9],[[],9],[[1,7]],0],"c":[],"p":[[3,"Gco"],[3,"GcoResult"],[15,"bool"],[3,"Formatter"],[6,"Result"],[8,"Hasher"],[15,"usize"],[4,"Result"],[3,"TypeId"]]},\ +"graph":{"doc":"Kosaraju’s algorithm for strongly connected components","t":"DDDLLLLLLMMLLLLLLLLLLLLLLLLLLLLLLLFLLLLLLLLLLLLLLLLLLLLLL","n":["Csr","Iter","LastMut","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","boundary","data","default","deref","deref_mut","extend","extend_from_slice","flat_len","fmt","from","from","from","from_edges","from_edges_and_rev","from_iter","from_sections","index","index_mut","into","into","into","into_iter","into_iter","is_empty","iter","kosaraju","last_mut","len","len","new","next","next_back","push","push_empty","push_section","section","section_mut","to_vec","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id","with_capacity"],"q":[[0,"graph"]],"d":["Compressed Sparse Row format","Immutable iterator over rows.","Mutable and extendable reference to the last section.","","","","","","","$S = [s_0, s_1, \\\\dots, s_{m}]$","$X = [x_0, x_1, \\\\dots, x_{n-1}]$","","","","Extend the last section with an iterator.","Copy elements from a slice to the last section.","Get the total number of elements in $A$. (i.e. $\\\\sum_…","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Create a CSR from a list of edges.","Create CSRs of $G$ and $G^{\\\\mathrm{op}}$ from a list of …","","Create a CSR from a list of sections.","","","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","","","Check if the CSR is empty. (i.e. $A = [\\\\ ]$)","Return an iterator over the sections.","Returns the strongly connected components of a directed …","Get the mutable and extendable reference to the last …","Get the number of sections $m = |A|$.","","Create a CSR corrsponding to $A = [\\\\ ]$.","","","Push an element to the last section.","Push an empty section $A_m = [\\\\ ]$.","Clone and push a section.","Get the $i$-th section $A_i$. Alias for &self[i].","Get the mutable $i$-th section $A_i$. Alias for …","Copies self into a new Vec<Vec<T>>.","","","","","","","","","","Create a CSR corrsponding to $A = [\\\\ ]$ with preallocated …"],"i":[0,0,0,1,2,10,1,2,10,1,1,1,2,2,2,2,1,1,1,2,10,1,1,1,1,1,1,1,2,10,1,10,1,1,0,1,1,10,1,10,10,2,1,1,1,1,1,1,2,10,1,2,10,1,2,10,1],"f":[0,0,0,[[]],[[]],[[]],[[]],[[]],[[]],0,0,[[],1],[2],[2],[[2,3]],[[[2,[4]]]],[1,5],[[[1,[6]],7],8],[[]],[[]],[[]],[5,[[1,[5]]]],[5],[3,1],[[],[[1,[4]]]],[[1,5]],[[1,5]],[[]],[[]],[[]],[1],[[]],[1,9],[1,10],[5,[[1,[5]]]],[1,2],[1,5],[10,5],[[],1],[10,11],[10,11],[2],[1],[[[1,[4]]]],[[1,5]],[[1,5]],[[[1,[4]]],[[12,[[12,[4]]]]]],[[],13],[[],13],[[],13],[[],13],[[],13],[[],13],[[],14],[[],14],[[],14],[[5,5],1]],"c":[],"p":[[3,"Csr"],[3,"LastMut"],[8,"IntoIterator"],[8,"Clone"],[15,"usize"],[8,"Debug"],[3,"Formatter"],[6,"Result"],[15,"bool"],[3,"Iter"],[4,"Option"],[3,"Vec"],[4,"Result"],[3,"TypeId"]]},\ "gss":{"doc":"黄金分割探索をします。","t":"IISIKKKKFFFFKKKKKK","n":["Float","Golden","INVPHI","Int","abs","as_f64","f64_as","golden_sect","gss_by_absolute_eps","gss_by_count","gss_integer","gss_on_slice","is_finite","max","midpoint_sorted","one","two","zero"],"q":[[0,"gss"]],"d":["gss_by_count …","黄金分割をする関数 golden_sect …","1 / φ = 0.6180339887498949","gss_integer …","Self の同名メソッド","","","selfother を φ:1 …","…","回数指定バージョン。count …","整数バージョン。正確な値を返します。","…","Self の同名メソッド","Self の同名メソッド","数学的な floor((self + upper)/2) …","1","2.0","0.0"],"i":[0,0,2,0,2,6,6,3,0,0,0,0,2,2,6,6,2,2],"f":[0,0,0,0,[[]],[[],1],[1],[[]],[[[0,[2,3]],[0,[2,3]],4,[0,[2,3]]],[[0,[2,3]]]],[[[0,[2,3]],[0,[2,3]],4,5],[[0,[2,3]]]],[[[0,[6,3]],[0,[6,3]],4],[[0,[6,3]]]],[[],5],[[],7],[[]],[[]],[[]],[[]],[[]]],"c":[],"p":[[15,"f64"],[8,"Float"],[8,"Golden"],[8,"Fn"],[15,"usize"],[8,"Int"],[15,"bool"]]},\ "heap_slope_trick":{"doc":"BinaryHeap 二本で slope trick をします。","t":"DDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLFLLLLLLLLLLLL","n":["HeapSlopeTrick","Summary","add_abs","add_const","add_cutoff_anti_diagonal","add_cutoff_diagonal","articulation_points","borrow","borrow","borrow_mut","borrow_mut","clone","clone","clone_into","clone_into","cumulative_min_from_left","cumulative_min_from_right","default","default","eq","eval","fmt","fmt","from","from","get_argmin","get_minimum","get_tilt_maximum","get_tilt_minimum","hash","into","into","merge","new","shift","sliding_window_minimum","summary","to_owned","to_owned","try_from","try_from","try_into","try_into","type_id","type_id"],"q":[[0,"heap_slope_trick"]],"d":["本体です。","HeapSlopeTrick::summary() の戻り値です。","絶対値関数加算 g(x) = f(x) + |x - a|","定数関数加算 g(x) = f(x) + c","傾き -1 のカットオフ一次関数加算 g(x) = f(x) …","傾き +1 のカットオフ一次関数加算 g(x) = f(x) …","関節点(二階差分が正である点)全体の列 …","","","","","","","","","左から累積最小値 g(x) = min { f(y) | y ∈ ]-∞, x…","右から累積最小値 g(x) = min { f(y) | y ∈ [x, ∞[…","","","","一点評価 f(x)","","","Returns the argument unchanged.","Returns the argument unchanged.","最小値を取る x の集合(と [MIN, MAX] …","最小値取得 min { f(x) | x in ]-∞, ∞[ }","差分の最大値 max { f(x + 1) - f(x) | x ∈ ]-∞, ∞…","差分の最小値 min { f(x + 1) - f(x) | x ∈ ]-∞, ∞…","","Calls U::from(self).","Calls U::from(self).","足し算をします。","零関数 f(x) = 0","平行移動 g(x) = f ( x - a )","スライド最小値 g(x) = min { f(y) | y ∈ [x - b, x …","関節点と差分の範囲を返します。","","","","","","","",""],"i":[0,0,1,1,1,1,1,1,4,1,4,1,4,1,4,1,1,1,4,4,1,1,4,1,4,1,1,1,1,4,1,4,0,1,1,1,1,1,4,1,4,1,4,1,4],"f":[0,0,[[1,2]],[[1,2]],[[1,2]],[[1,2]],[1,3],[[]],[[]],[[]],[[]],[1,1],[4,4],[[]],[[]],[1],[1],[[],1],[[],4],[[4,4],5],[[1,2],2],[[1,6],7],[[4,6],7],[[]],[[]],[1],[1,2],[1,2],[1,2],[[4,8]],[[]],[[]],[[1,1],1],[[],1],[[1,2]],[[1,2,2]],[1,4],[[]],[[]],[[],9],[[],9],[[],9],[[],9],[[],10],[[],10]],"c":[],"p":[[3,"HeapSlopeTrick"],[15,"i64"],[3,"Vec"],[3,"Summary"],[15,"bool"],[3,"Formatter"],[6,"Result"],[8,"Hasher"],[4,"Result"],[3,"TypeId"]]},\ "heap_tricks":{"doc":"remove_unchecked のできるヒープです。","t":"DIDDDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLMLLLLLLLLLLLKLLLKLLLLKLLLKLLLLLLMLLLLLLLLLLLLLLLLLL","n":["DoubleHeap","Handler","Nop","RemovableHeap","Sum","balance_left","balance_right","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","clone","clone","clone","clone","clone_into","clone_into","clone_into","clone_into","collect_left_sorted_vec","collect_right_sorted_vec","collect_sorted_vec","collect_sorted_vec","default","default","default","default","eq","eq","fmt","fmt","fmt","fmt","from","from","from","from","from_iter","handler","hash","hash","into","into","into","into","is_empty","is_empty","left","left_len","len","len","move_left","move_right","new","new","peek","peek_left","peek_right","pop","pop_left","pop_left","pop_left","pop_left","pop_right","pop_right","pop_right","pop_right","push","push_left","push_left","push_left","push_left","push_right","push_right","push_right","push_right","remove_left_unchecked","remove_right_unchecked","remove_unchecked","right","right_len","to_owned","to_owned","to_owned","to_owned","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","with_handler"],"q":[[0,"heap_tricks"]],"d":["…","集約操作を指定するためのトレイトです。 …","何も集約しないことを表す型です。 Handler …","論理削除のできるヒープです。","総和を集約するための型です。 Handler …","左側ヒープの要素が k …","右側ヒープの要素が k …","","","","","","","","","","","","","","","","","…","…","…","…","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","","ハンドラへの参照を返します。","","","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","ヒープが空ならば true を返します。","ヒープが空ならば true を返します。","","左側ヒープの要素数を返します。","全体の要素数を返します。","ヒープの長さを返します。","…","…","","空のヒープを構築します。","…","左側ヒープの最大要素があれば返します。","右側ヒープの最大要素があれば返します。","…","左側から削除するときのコールバック関数","","","…","右側から削除するときのコールバック関数","","","…","ヒープに新しい要素 x を追加します。","左側に挿入するときのコールバック関数","","","…","右側に挿入するときのコールバック関数","","","…","…","…","ヒープに含まれる要素 x を削除します。 …","","右側ヒープの要素数を返します。","","","","","","","","","","","","","","","","","Handler を指定して構築します。"],"i":[0,0,0,0,0,5,5,7,9,5,10,7,9,5,10,7,9,5,10,7,9,5,10,5,5,5,10,7,9,5,10,7,9,7,9,5,10,7,9,5,10,10,5,7,9,7,9,5,10,5,10,9,5,5,10,5,5,5,10,10,5,5,10,4,7,9,5,4,7,9,5,10,4,7,9,5,4,7,9,5,5,5,10,9,5,7,9,5,10,7,9,5,10,7,9,5,10,7,9,5,10,5],"f":[0,0,0,0,0,[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]],6]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]],6]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[7,7],[[[9,[8]]],[[9,[8]]]],[[[5,[8,8]]],[[5,[8,8]]]],[[[10,[8]]],[[10,[8]]]],[[]],[[]],[[]],[[]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],[[11,[[0,[1,2,3]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],[[11,[[0,[1,2,3]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],[[11,[[0,[1,2,3]]]]]],[[[10,[[0,[1,2,3]]]]],[[11,[[0,[1,2,3]]]]]],[[],7],[[],[[9,[12]]]],[[],[[5,[[0,[1,2,3]],7]]]],[[],[[10,[[0,[1,2,3]]]]]],[[7,7],13],[[[9,[14]],[9,[14]]],13],[[7,15],16],[[[9,[17]],15],16],[[[5,[[0,[1,2,3,17]],[0,[[4,[[0,[1,2,3,17]]]],17]]]],15],16],[[[10,[[0,[1,2,3,17]]]],15],16],[[]],[[]],[[]],[[]],[18,[[10,[[0,[1,2,3]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],[[4,[[0,[1,2,3]]]]]],[[7,19]],[[[9,[3]],19]],[[]],[[]],[[]],[[]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],13],[[[10,[[0,[1,2,3]]]]],13],0,[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],6],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],6],[[[10,[[0,[1,2,3]]]]],6],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]]],[[],[[5,[[0,[1,2,3]],7]]]],[[],[[10,[[0,[1,2,3]]]]]],[[[10,[[0,[1,2,3]]]]],[[20,[[0,[1,2,3]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],[[20,[[0,[1,2,3]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],[[20,[[0,[1,2,3]]]]]],[[[10,[[0,[1,2,3]]]]],[[20,[[0,[1,2,3]]]]]],[[]],[7],[[[9,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]],[0,[[21,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],[[20,[[0,[1,2,3]]]]]],[[]],[7],[[[9,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]],[0,[[21,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],[[20,[[0,[1,2,3]]]]]],[[[10,[[0,[1,2,3]]]],[0,[1,2,3]]]],[[]],[7],[[[9,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]],[0,[[21,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]],[0,[1,2,3]]]],[[]],[7],[[[9,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]],[0,[[21,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]],[22,[[0,[[21,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]],[22,[[0,[[21,[[0,[21,22]]]],[22,[[0,[21,22]]]]]]]]]]]]]]]]]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]],[0,[1,2,3]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]],[0,[1,2,3]]]],[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]],[0,[1,2,3]]]],[[[10,[[0,[1,2,3]]]],[0,[1,2,3]]]],0,[[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]],6],[[]],[[]],[[]],[[]],[[],23],[[],23],[[],23],[[],23],[[],23],[[],23],[[],23],[[],23],[[],24],[[],24],[[],24],[[],24],[[[4,[[0,[1,2,3]]]]],[[5,[[0,[1,2,3]],[4,[[0,[1,2,3]]]]]]]]],"c":[],"p":[[8,"Copy"],[8,"Ord"],[8,"Hash"],[8,"Handler"],[3,"DoubleHeap"],[15,"usize"],[3,"Nop"],[8,"Clone"],[3,"Sum"],[3,"RemovableHeap"],[3,"Vec"],[8,"Default"],[15,"bool"],[8,"PartialEq"],[3,"Formatter"],[6,"Result"],[8,"Debug"],[8,"IntoIterator"],[8,"Hasher"],[4,"Option"],[8,"AddAssign"],[8,"SubAssign"],[4,"Result"],[3,"TypeId"]]},\ @@ -48,8 +49,7 @@ var searchIndex = JSON.parse('{\ "rational":{"doc":"","t":"DILLLLLLLLLLLLLLLLLLLLLKKLLLLLLLLLKLLLLLLLLLLLLLLK","n":["Rational","Signed","add","add","add","add","add_assign","borrow","borrow_mut","clone","clone_into","cmp","decompose","default","div","div","div","div","div_assign","eq","fmt","from","from_str","generic_abs","generic_signum","into","into_f64","mul","mul","mul","mul","mul_assign","neg","new","one","partial_cmp","product","product","sub","sub","sub","sub","sub_assign","sum","sum","to_owned","try_from","try_into","type_id","zero"],"q":[[0,"rational"]],"d":["","","","","","","","","","","","","","","","","","","","","","Returns the argument unchanged.","","","","Calls U::from(self).","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1],"f":[0,0,[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]],[[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]]],[[]],[[]],[[[2,[[0,[3,1]]]]],[[2,[[0,[3,1]]]]]],[[]],[[[2,[1]],[2,[1]]],4],[[[2,[1]]]],[[],[[2,[[0,[5,1]]]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]],[[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]],6],[[[2,[1]],7],8],[[]],[9,[[10,[[2,[1]]]]]],[[]],[[]],[[]],[[[2,[1]]],11],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]],[[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]]]],[[1,1],[[2,[1]]]],[[]],[[[2,[1]],[2,[1]]],[[12,[4]]]],[13,[[2,[1]]]],[13,[[2,[1]]]],[[[2,[1]],[2,[1]]],[[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]]],[[[2,[1]],[2,[1]]]],[13,[[2,[1]]]],[13,[[2,[1]]]],[[]],[[],10],[[],10],[[],14],[[]]],"c":[],"p":[[8,"Signed"],[3,"Rational"],[8,"Clone"],[4,"Ordering"],[8,"Default"],[15,"bool"],[3,"Formatter"],[6,"Result"],[15,"str"],[4,"Result"],[15,"f64"],[4,"Option"],[8,"Iterator"],[3,"TypeId"]]},\ "rb":{"doc":"Containers for storing data in a red-black tree.","t":"QDIDDIDQQLLLLLLLLLLLLLLLLLLLLLLLLLLLKLLLLLLLLLLLLLLLLLLLLKLLLLLLLKLLLLLLLLLLLLLLLLLLLLLLKLLLLLLLLLLLLLLL","n":["Acc","Multimap","MultimapOp","MultimapSeg","Multiset","Op","Seg","Value","Value","append","binary_search","binary_search","binary_search","binary_search_ptr","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","default","default","default","default","display","fmt","fmt","fmt","fold","from","from","from","from","from_iter","identity","insert","insert","insert","insert","into","into","into","into","into_iter","into_iter","into_iter","into_iter","is_empty","is_empty","is_empty","is_empty","iter","iter","iter","iter","join","len","len","len","len","lower_bound","lower_bound","lower_bound","mul","new","new","new","new","nth","nth","nth","nth","nth_mut","nth_mut","partition_point","partition_point","partition_point","remove","remove","remove","remove","remove_nth","remove_nth","remove_nth","split_off","table","to_acc","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","upper_bound","upper_bound","upper_bound"],"q":[[0,"rb"]],"d":["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","","","","","","","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[6,0,0,0,0,0,0,6,1,2,7,10,11,7,7,10,11,2,7,10,11,2,7,10,11,2,2,10,11,2,2,7,10,11,2,2,1,7,10,11,2,7,10,11,2,7,10,11,2,7,10,11,2,7,10,11,2,6,7,10,11,2,7,10,11,1,7,10,11,2,7,10,11,2,7,2,7,10,11,7,10,11,2,7,10,11,2,2,6,7,10,11,2,7,10,11,2,7,10,11,2,7,10,11],"f":[0,0,0,0,0,0,0,0,0,[[[2,[1]],[2,[1]]]],[[[7,[[0,[3,[5,[[0,[3,4]]]]]],3,6]],[0,[3,4]]],[[9,[8]]]],[[[10,[[0,[3,[5,[[0,[3,4]]]]]],3]],[0,[3,4]]],[[9,[8]]]],[[[11,[[0,[3,[5,[[0,[3,4]]]]]],3]],[0,[3,4]]],[[9,[8,8]]]],[[[7,[[0,[3,[5,[[0,[3,4]]]]]],3,6]],[0,[3,4]]],[[9,[8]]]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],[[7,[3,6]]]],[[],[[10,[3]]]],[[],[[11,[3]]]],[[],[[2,[1]]]],[[[2,[1]]],[[0,[1]]]],[[[10,[[0,[3,12]],12]],13],14],[[[11,[[0,[3,12]]]],13],14],[[[2,[1]],13],14],[[[2,[1]],[15,[8]]]],[[]],[[]],[[]],[[]],[16,[[2,[1]]]],[[]],[[[7,[3,6]],3]],[[[10,[3]],3]],[[[11,[3]],3]],[[[2,[1]],8]],[[]],[[]],[[]],[[]],[[[7,[3,6]]]],[[[10,[3]]]],[[[11,[3]]]],[[[2,[1]]]],[[[7,[3,6]]],17],[[[10,[3]]],17],[[[11,[3]]],17],[[[2,[1]]],17],[[[7,[3,6]]],[[0,[3,6]]]],[[[10,[3]]],[[0,[3]]]],[[[11,[3]]],[[0,[3]]]],[[[2,[1]]],[[0,[1]]]],[[18,18]],[[[7,[3,6]]],8],[[[10,[3]]],8],[[[11,[3]]],8],[[[2,[1]]],8],[[[7,[3,6]],3],8],[[[10,[3]],3],8],[[[11,[3]],3],8],[[]],[[],[[7,[3,6]]]],[[],[[10,[3]]]],[[],[[11,[3]]]],[[],[[2,[1]]]],[[[7,[3,6]],8]],[[[10,[3]],8]],[[[11,[3]],8],3],[[[2,[1]],8]],[[[7,[3,6]],8]],[[[2,[1]],8],[[0,[1]]]],[[[7,[3,6]],19],8],[[[10,[3]],19],8],[[[11,[3]],19],8],[[[7,[[0,[3,[5,[[0,[3,4]]]]]],3,6]],[0,[3,4]]],18],[[[10,[[0,[3,[5,[[0,[3,4]]]]]],3]],[0,[3,4]]],18],[[[11,[[0,[3,[5,[[0,[3,4]]]]]],3]],[0,[3,4]]],[[18,[[0,[3,[5,[[0,[3,4]]]]]],3]]]],[[[2,[1]],8]],[[[7,[3,6]],8]],[[[10,[3]],8]],[[[11,[3]],8],3],[[[2,[1]],8],[[2,[1]]]],[[[2,[1]]],[[0,[1]]]],[[]],[[],9],[[],9],[[],9],[[],9],[[],9],[[],9],[[],9],[[],9],[[],20],[[],20],[[],20],[[],20],[[[7,[3,6]],3],8],[[[10,[3]],3],8],[[[11,[3]],3],8]],"c":[],"p":[[8,"Op"],[3,"Seg"],[8,"Ord"],[8,"Sized"],[8,"Borrow"],[8,"MultimapOp"],[3,"MultimapSeg"],[15,"usize"],[4,"Result"],[3,"Multimap"],[3,"Multiset"],[8,"Debug"],[3,"Formatter"],[6,"Result"],[8,"RangeBounds"],[8,"IntoIterator"],[15,"bool"],[4,"Option"],[8,"FnMut"],[3,"TypeId"]]},\ "rbtree":{"doc":"赤黒木","t":"DDIDQQLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLKLLLLLLLKLLLLLLLLLLL","n":["Iter","Nop","Op","RbTree","Summary","Value","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","clone","clone_into","default","delete","eq","fmt","fold","from","from","from","from_iter","get","hash","insert","into","into","into","into_iter","into_iter","is_empty","iter","len","merge","merge3","new","next","op","op","partition_point","push_back","push_front","singleton","split","split3","summarize","summarize","to_owned","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id"],"q":[[0,"rbtree"]],"d":["iter の返す型","…","…","赤黒木です。","中間ノードに持たせる値","葉に持たせる値","","","","","","","","","","i 番目の Nil …","","","range の範囲で畳み込みます。","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","…","i 番目の要素をコピーして返します。","","i 番目に新しい Nil ノードを挿入します。","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","","","空ならば true、さもなくば false …","…","長さ、すなわち Nil …","2 つの赤黒木をマージします。","3 つの赤黒木をマージします。","空の赤黒木を生成します。","","演算","","中間ノードの情報で二分探索します。","新しいノードを末尾に挿入します。","新しいノードを先頭に挿入します。","Nil …","i 番目で分割します。","l, r 番目で 3 つに分割します。","葉の値から中間ノードの値への変換","","","","","","","","","","",""],"i":[0,0,0,0,2,2,3,20,16,3,20,16,3,3,3,3,3,3,3,3,20,16,3,3,3,3,3,20,16,3,16,3,3,3,3,3,3,16,2,20,3,3,3,3,3,3,2,20,3,3,20,16,3,20,16,3,20,16],"f":[0,0,0,0,0,0,[[]],[[]],[[]],[[]],[[]],[[]],[[[3,[1,2]]],[[3,[1,2]]]],[[]],[[],[[3,[2]]]],[[[3,[2]],4]],[[[3,[5,2]],[3,[5,2]]],6],[[[3,[7,2]],8],9],[[[3,[2]],[10,[4]]],11],[[]],[[]],[[]],[12,[[3,[2]]]],[[[3,[13,2]],4],13],[[[3,[14,2]],15]],[[[3,[2]],4]],[[]],[[]],[[]],[[[3,[2]]]],[[]],[[[3,[2]]],6],[[[3,[2]]],[[16,[2]]]],[[[3,[2]]],4],[[[3,[2]],[3,[2]]],[[3,[2]]]],[[[3,[2]],[3,[2]],[3,[2]]],[[3,[2]]]],[[],[[3,[2]]]],[[[16,[2]]],11],[[]],[[]],[[[3,[2]],17],4],[[[3,[2]]]],[[[3,[2]]]],[[],[[3,[2]]]],[[[3,[2]],4]],[[[3,[2]],4,4]],[[]],[[]],[[]],[[],18],[[],18],[[],18],[[],18],[[],18],[[],18],[[],19],[[],19],[[],19]],"c":[],"p":[[8,"Clone"],[8,"Op"],[3,"RbTree"],[15,"usize"],[8,"PartialEq"],[15,"bool"],[8,"Debug"],[3,"Formatter"],[6,"Result"],[8,"RangeBounds"],[4,"Option"],[8,"IntoIterator"],[8,"Copy"],[8,"Hash"],[8,"Hasher"],[3,"Iter"],[8,"Fn"],[4,"Result"],[3,"TypeId"],[3,"Nop"]]},\ -"riff":{"doc":"Future and otherworldly Rust features.","t":"SIISIIQLLFFLLLLFLLLLLLLLLLLLKKKKLLLLLLLLLLLLKK","n":["BITS","BinarySearch","ChangeMinMax","MAX","PopIf","Unsigned","Value","bit_length","bit_length","bitmask_combinations","bitmask_subsets","change_max","change_max","change_min","change_min","i2powm1","lower_bound","lower_bound","lower_bound_by","lower_bound_by","lower_bound_by_key","lower_bound_by_key","lower_bound_value","lower_bound_value","lower_bound_value_by","lower_bound_value_by","lower_bound_value_by_key","lower_bound_value_by_key","one","partition_point","partition_point_value","pop_if","upper_bound","upper_bound","upper_bound_by","upper_bound_by","upper_bound_by_key","upper_bound_by_key","upper_bound_value","upper_bound_value","upper_bound_value_by","upper_bound_value_by","upper_bound_value_by_key","upper_bound_value_by_key","wrapping_neg","zero"],"q":[[0,"riff"]],"d":["","{lower,upper}_bound, etc","change_min and change_max","","Conditional pop function.","Unsigned integer types.","","","","Generates all the $k$-subsets of $[0, N[$","Generates all the subsets of bs.","","","","","Returns $2^n - 1$.","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[2,0,0,2,0,0,8,2,2,0,0,9,9,9,9,0,10,10,10,10,10,10,10,10,10,10,10,10,2,10,10,8,10,10,10,10,10,10,10,10,10,10,10,10,2,2],"f":[0,0,0,0,0,0,0,[[],1],[[],1],[[1,1],[[0,[2]]]],[2,[[0,[2]]]],[[]],[[]],[[]],[[]],[1,2],[3,4],[3,4],[5,4],[5,4],[[3,5],4],[[3,5],4],[3,[[6,[3]]]],[3,[[6,[3]]]],[5,6],[5,6],[[3,5],6],[[3,5],6],[[]],[5,4],[5,6],[7,6],[3,4],[3,4],[5,4],[5,4],[[3,5],4],[[3,5],4],[3,[[6,[3]]]],[3,[[6,[3]]]],[5,6],[5,6],[[3,5],6],[[3,5],6],[[]],[[]]],"c":[],"p":[[15,"u32"],[8,"Unsigned"],[8,"Ord"],[15,"usize"],[8,"FnMut"],[4,"Option"],[8,"FnOnce"],[8,"PopIf"],[8,"ChangeMinMax"],[8,"BinarySearch"]]},\ -"scc":{"doc":"このライブラリを使える問題","t":"DLLLLLLLLLLLLLLLLLLLLLLLLLLL","n":["Scc","add_edge","borrow","borrow_mut","build","clone","clone_into","cmp_count","cmp_of","cmp_ofs","default","eq","fmt","from","g","hash","into","is_empty","len","new","ord","quotient_graph","quotient_set","rg","to_owned","try_from","try_into","type_id"],"q":[[0,"scc"]],"d":["本体です。","【Require: 未ビルド】 辺 (from, to) …","","","【Require: 未ビルド】 ビルドします。","","","【Require: ビルド済み】 …","【Require: ビルド済み】 頂点 x …","【Require: ビルド済み】 …","","","","Returns the argument unchanged.","正向きのグラフの隣接リストを返します。","","Calls U::from(self).","管理しているグラフが空グラフならば、true …","管理しているグラフの頂点数を返します。","頂点数 n …","【Require: ビルド済み】 …","【Require: ビルド済み】 …","【Require: ビルド済み】 …","逆向きのグラフの隣接リストを返します。","","","",""],"i":[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],"f":[0,[[1,2,2]],[[]],[[]],[1],[1,1],[[]],[1,2],[[1,2],2],[1],[[],1],[[1,1],3],[[1,4],5],[[]],[1],[[1,6]],[[]],[1,3],[1,2],[2,1],[1],[1,[[7,[[7,[2]]]]]],[1,[[7,[[7,[2]]]]]],[1],[[]],[[],8],[[],8],[[],9]],"c":[],"p":[[3,"Scc"],[15,"usize"],[15,"bool"],[3,"Formatter"],[6,"Result"],[8,"Hasher"],[3,"Vec"],[4,"Result"],[3,"TypeId"]]},\ +"riff":{"doc":"Future and otherworldly Rust features.","t":"SIISSIIQSLLFFLLLLFLLLLLLLLLLLLKKKLLLLLLLLLLLLK","n":["BITS","BinarySearch","ChangeMinMax","MAX","ONE","PopIf","Unsigned","Value","ZERO","bit_length","bit_length","bitmask_combinations","bitmask_subsets","change_max","change_max","change_min","change_min","i2powm1","lower_bound","lower_bound","lower_bound_by","lower_bound_by","lower_bound_by_key","lower_bound_by_key","lower_bound_value","lower_bound_value","lower_bound_value_by","lower_bound_value_by","lower_bound_value_by_key","lower_bound_value_by_key","partition_point","partition_point_value","pop_if","upper_bound","upper_bound","upper_bound_by","upper_bound_by","upper_bound_by_key","upper_bound_by_key","upper_bound_value","upper_bound_value","upper_bound_value_by","upper_bound_value_by","upper_bound_value_by_key","upper_bound_value_by_key","wrapping_neg"],"q":[[0,"riff"]],"d":["","{lower,upper}_bound, etc","change_min and change_max","","","Conditional pop function.","Unsigned integer types.","","","","","Generates all the $k$-subsets of $[0, N[$","Generates all the subsets of bs.","","","","","Returns $2^n - 1$.","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[2,0,0,2,2,0,0,8,2,2,2,0,0,9,9,9,9,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,8,10,10,10,10,10,10,10,10,10,10,10,10,2],"f":[0,0,0,0,0,0,0,0,0,[[],1],[[],1],[[1,1],[[0,[2]]]],[2,[[0,[2]]]],[[]],[[]],[[]],[[]],[1,2],[3,4],[3,4],[5,4],[5,4],[[3,5],4],[[3,5],4],[3,[[6,[3]]]],[3,[[6,[3]]]],[5,6],[5,6],[[3,5],6],[[3,5],6],[5,4],[5,6],[7,6],[3,4],[3,4],[5,4],[5,4],[[3,5],4],[[3,5],4],[3,[[6,[3]]]],[3,[[6,[3]]]],[5,6],[5,6],[[3,5],6],[[3,5],6],[[]]],"c":[],"p":[[15,"u32"],[8,"Unsigned"],[8,"Ord"],[15,"usize"],[8,"FnMut"],[4,"Option"],[8,"FnOnce"],[8,"PopIf"],[8,"ChangeMinMax"],[8,"BinarySearch"]]},\ "segbeats":{"doc":"","t":"IDLLLLLLLLLLKKKLFLLLLLLLK","n":["Elm","Segbeats","borrow","borrow_mut","change_max","change_min","clone","clone_into","eq","fmt","from","into","max_value","min_value","mul_u32","new","open","query_max","query_min","query_sum","to_owned","try_from","try_into","type_id","zero"],"q":[[0,"segbeats"]],"d":["","","","","","","","","","","Returns the argument unchanged.","Calls U::from(self).","","","","","","","","","","","","",""],"i":[0,0,2,2,2,2,2,2,2,2,2,2,1,1,1,2,0,2,2,2,2,2,2,2,1],"f":[0,0,[[]],[[]],[[[2,[1]],[0,[3,[5,[4]]]],1]],[[[2,[1]],[0,[3,[5,[4]]]],1]],[[[2,[3]]],[[2,[3]]]],[[]],[[[2,[6]],[2,[6]]],7],[[[2,[8]],9],10],[[]],[[]],[[]],[[]],[11],[[],[[2,[1]]]],[[4,[5,[4]]],[[12,[4]]]],[[[2,[1]],[5,[4]]],1],[[[2,[1]],[5,[4]]],1],[[[2,[1]],[5,[4]]],1],[[]],[[],13],[[],13],[[],14],[[]]],"c":[],"p":[[8,"Elm"],[3,"Segbeats"],[8,"Clone"],[15,"usize"],[8,"RangeBounds"],[8,"PartialEq"],[15,"bool"],[8,"Debug"],[3,"Formatter"],[6,"Result"],[15,"u32"],[3,"Range"],[4,"Result"],[3,"TypeId"]]},\ "segbeats_task3":{"doc":"","t":"IDLLLLLLLLLLLKKKLFLLLLLLLLK","n":["Elm","Segbeats","borrow","borrow_mut","change_max","change_min","clone","clone_into","count_changes","eq","fmt","from","into","max_value","min_value","mul_u32","new","open","query_max","query_min","query_sum","range_add","to_owned","try_from","try_into","type_id","zero"],"q":[[0,"segbeats_task3"]],"d":["","","","","","","","","","","","Returns the argument unchanged.","Calls U::from(self).","","","","","","","","","","","","","",""],"i":[0,0,2,2,2,2,2,2,2,2,2,2,2,1,1,1,2,0,2,2,2,2,2,2,2,2,1],"f":[0,0,[[]],[[]],[[[2,[1]],[0,[3,[5,[4]]]],1]],[[[2,[1]],[0,[3,[5,[4]]]],1]],[[[2,[3]]],[[2,[3]]]],[[]],[[[2,[1]],[5,[4]]],6],[[[2,[7]],[2,[7]]],8],[[[2,[1]],9],10],[[]],[[]],[[]],[[]],[11],[[],[[2,[1]]]],[[4,[5,[4]]],[[12,[4]]]],[[[2,[1]],[5,[4]]],1],[[[2,[1]],[5,[4]]],1],[[[2,[1]],[5,[4]]],1],[[[2,[1]],[0,[3,[5,[4]]]],1]],[[]],[[],13],[[],13],[[],14],[[]]],"c":[],"p":[[8,"Elm"],[3,"Segbeats"],[8,"Clone"],[15,"usize"],[8,"RangeBounds"],[15,"u64"],[8,"PartialEq"],[15,"bool"],[3,"Formatter"],[6,"Result"],[15,"u32"],[3,"Range"],[4,"Result"],[3,"TypeId"]]},\ "segtree":{"doc":"Segment tree and its variants.","t":"DDDIDDDQLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLKLLLLLLLLLLLLLLLLLLKLLLLLLLLLLLLLLLLLLLLLL","n":["Dense2dEntry","Dense2dSegtree","Entry","Op","Segtree","SegtreeWithCompression","Sparse2dSegtree","Value","apply","as_slice","borrow","borrow","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","collect_map","collect_map","collect_vec","deref","deref","deref_mut","deref_mut","drop","drop","entry","entry","entry","fmt","fmt","fmt","fmt","fmt","fold","fold","fold","fold","from","from","from","from","from","from","from_iter","from_iter","from_iter","from_len","identity","index","index","index","index","index","into","into","into","into","into","into","iter","iter","iter","iter","keys","max_right","min_left","mul","new","new","new","new","try_from","try_from","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","type_id","type_id"],"q":[[0,"segtree"]],"d":["The result of Dense2dSegtree::entry.","A dense 2D segment tree.","The result of Segtree::entry.","A trait for segment tree operations.","A segment tree. Use as_slice() to debug.","A sparse (compressed) segment tree. Use collect_map() to …","A segment tree of segment trees (2D segment tree). The …","The value type.","Apply a function to $x_{k, l}$.","Returns a slice of $x_0, x_1, \\\\ldots, x_{n-1}$.","","","","","","","","","","","","","Collects the key-value pairs into a BTreeMap.","Collects the key-value pairs into a BTreeMap.","Collect to a $2$-dimensional vector.","","","","","","","Returns the entry of $x_i$.","Returns the entry of $x_k$. If $k$ is not found, it panics.","Returns the entry of $x_{i, j}$.","","","","","","Returns $x_l \\\\cdot x_{l+1} \\\\cdot \\\\ldots \\\\cdot x_{r-1}$.","Folds $\\\\left \\\\lbrace x_k \\\\mid k \\\\in \\\\text{{range}} \\\\right …","Folds $\\\\left \\\\lbrace x_{k, l} \\\\mid (k, l) \\\\in …","Fold $\\\\left \\\\lbrace x_{i, j} \\\\mid i \\\\in \\\\text{{range}}_i, …","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","","","","Constructs a new segment tree with the specified length.","Returns the identity value $e$.","","","","","","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Returns an iterator of $x_0, x_1, \\\\ldots, x_{n-1}$.","Returns an iterator of $(k, x_k)$.","Returns the iterator of $(k, l, x_{k, l})$.","Returns an iterator that returns the rows $(x_{i, 0}, x_…","Returns the keys.","Returns the maximum $r$ s.t. $f(x _ l \\\\cdot \\\\dots \\\\cdot x …","Returns the minimum $l$ s.t. $f(x _ l \\\\cdot \\\\dots \\\\cdot x …","Multiplies two values: $x \\\\cdot y$.","Constructs with the specified values.","Constructs with the specified key-value pairs.","Constructs with the specified key-value pairs.","Constructs with the specified values.","","","","","","","","","","","","","","","","","",""],"i":[0,0,0,0,0,0,0,3,4,6,6,11,7,4,9,12,6,11,7,4,9,12,7,4,9,11,12,11,12,11,12,6,7,9,6,11,7,4,9,6,7,4,9,6,11,7,4,9,12,6,7,4,6,3,6,7,4,4,9,6,11,7,4,9,12,6,7,4,9,7,6,6,3,6,7,4,9,6,11,7,4,9,12,6,11,7,4,9,12,6,11,7,4,9,12],"f":[0,0,0,0,0,0,0,0,[[[4,[[0,[1,2]],[0,[1,2]],3]],[0,[1,2]],[0,[1,2]],5]],[[[6,[3]]]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[[7,[2,1,3]]],[[8,[2,1]]]],[[[4,[2,[0,[1,2]],2,[0,[1,2]],3]]],8],[[[9,[3]]],[[10,[10]]]],[[[11,[3]]]],[[[12,[3]]]],[[[11,[3]]]],[[[12,[3]]]],[[[11,[3]]]],[[[12,[3]]]],[[[6,[3]],13],[[11,[3]]]],[[[7,[1,3]],1],[[11,[3]]]],[[[9,[3]],13,13],[[12,[3]]]],[[[6,[3]],14],15],[[[11,[3]],14],15],[[[7,[16,3]],14],15],[[[4,[16,16,3]],14],15],[[[9,[3]],14],15],[[[6,[3]],[17,[13]]]],[[[7,[1,3]],[17,[1]]]],[[[4,[[0,[1,2]],[0,[1,2]],3]],[17,[[0,[1,2]]]],[0,[[17,[[0,[1,2]]]],2]]]],[[[9,[3]],[17,[13]],[17,[13]]]],[[]],[[]],[[]],[[]],[[]],[[]],[18,[[6,[3]]]],[18,[[7,[[0,[2,1]],3]]]],[18,[[4,[[0,[1,2]],[0,[1,2]],3]]]],[13,[[6,[3]]]],[[]],[[[6,[3]],13]],[[[7,[1,3]],1]],[[[4,[1,1,3]]]],[[[4,[1,1,3]],1]],[[[9,[3]],13]],[[]],[[]],[[]],[[]],[[]],[[]],[[[6,[3]]],19],[[[7,[1,3]]],20],[[[4,[[0,[1,2]],[0,[1,2]],3]]],20],[[[9,[3]]],20],[[[7,[1,3]]]],[[[6,[3]],13,5],13],[[[6,[3]],13,5],13],[[]],[[],[[6,[3]]]],[[],[[7,[2,1,3]]]],[[],[[4,[[0,[1,2]],[0,[1,2]],3]]]],[[],[[9,[3]]]],[[],21],[[],21],[[],21],[[],21],[[],21],[[],21],[[],21],[[],21],[[],21],[[],21],[[],21],[[],21],[[],22],[[],22],[[],22],[[],22],[[],22],[[],22]],"c":[],"p":[[8,"Ord"],[8,"Clone"],[8,"Op"],[3,"Sparse2dSegtree"],[8,"FnMut"],[3,"Segtree"],[3,"SegtreeWithCompression"],[3,"BTreeMap"],[3,"Dense2dSegtree"],[3,"Vec"],[3,"Entry"],[3,"Dense2dEntry"],[15,"usize"],[3,"Formatter"],[6,"Result"],[8,"Debug"],[8,"RangeBounds"],[8,"IntoIterator"],[3,"Iter"],[8,"Iterator"],[4,"Result"],[3,"TypeId"]]},\ @@ -62,7 +62,6 @@ var searchIndex = JSON.parse('{\ "tree_fold":{"doc":"2-way tree DP","t":"IDQLLMLKLMKLLFLLKM","n":["Op","TwoWayTreeFoldResult","Value","borrow","borrow_mut","branch","from","identity","into","lower","mul","try_from","try_into","two_way_tree_fold","two_way_tree_fold","type_id","up","upper"],"q":[[0,"tree_fold"]],"d":["Operations","The return value of Op::two_way_tree_fold() ans …","A monoid $M$.","","","$f(\\\\phi(T_i^\\\\blacktriangledown))$","Returns the argument unchanged.","$* \\\\to F$: empty forest","Calls U::from(self).","$\\\\prod_{j \\\\lessdot i} f(\\\\phi(T_j^\\\\blacktriangledown))$","$F \\\\times F \\\\to F$: concatenate two forests","","","Performs 2-way tree DP","Performs 2-way tree DP","","$F \\\\times V \\\\to T \\\\to F$: join by a root","$f(\\\\phi(T_i^\\\\triangle))$"],"i":[0,0,2,3,3,3,3,2,3,3,2,3,3,0,2,3,2,3],"f":[0,0,0,[[]],[[]],0,[[]],[[]],[[]],0,[[]],[[],1],[[],1],[2,3],[[],3],[[],4],[5],0],"c":[],"p":[[4,"Result"],[8,"Op"],[3,"TwoWayTreeFoldResult"],[3,"TypeId"],[15,"usize"]]},\ "trial":{"doc":"Execute the trial-division algorithm.","t":"DDDILLLLLLLFFLLLKLLLLLLLLLKFFLLLLLLLLLK","n":["Divisors","PrimeFactors","PrimeFactorsRle","Value","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","divides","divisors","divisors_unordered","from","from","from","increment","into","into","into","into_iter","into_iter","into_iter","next","next","next","one","prime_factors","prime_factors_rle","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id","zero"],"q":[[0,"trial"]],"d":["See the document of a function divisors_unordered","See the document of a function prime_factors","See the document of a function prime_factors_rle","Abstraction of unsigned integers.","","","","","","","Returns true if and only if self divides n.","Returns a Vec of the divisors. The divisors is guaranteed …","Takes an unsigned integer and returns an iterator to yield …","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Increment self.","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","","","","","","","Returns 1.","Takes an unsigned integer and returns an iterator to yield …","Takes an unsigned integer and returns an iterator to yield …","","","","","","","","","","Returns 0."],"i":[0,0,0,0,4,6,7,4,6,7,2,0,0,4,6,7,2,4,6,7,4,6,7,4,6,7,2,0,0,4,6,7,4,6,7,4,6,7,2],"f":[0,0,0,0,[[]],[[]],[[]],[[]],[[]],[[]],[[],1],[2,[[3,[2]]]],[2,[[4,[2]]]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[[4,[2]]],5],[[[6,[2]]],5],[[[7,[2]]],5],[[]],[2,[[7,[2]]]],[2,[[6,[2]]]],[[],8],[[],8],[[],8],[[],8],[[],8],[[],8],[[],9],[[],9],[[],9],[[]]],"c":[],"p":[[15,"bool"],[8,"Value"],[3,"Vec"],[3,"Divisors"],[4,"Option"],[3,"PrimeFactorsRle"],[3,"PrimeFactors"],[4,"Result"],[3,"TypeId"]]},\ "trie":{"doc":"A set and map data structure on trie.","t":"RDDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL","n":["DEGREE","TrieMap","TrieSet","borrow","borrow","borrow_mut","borrow_mut","clone","clone","clone_into","clone_into","contains","default","default","eq","eq","fmt","fmt","for_each","for_each_kv","for_each_prefix","for_each_prefix","from","from","get","get_mut","get_or_insert","get_or_insert_with","insert","insert","into","into","new","new","remove","remove","to_owned","to_owned","try_from","try_from","try_into","try_into","type_id","type_id"],"q":[[0,"trie"]],"d":["Tries here have the fixed branching number 26.","A map base on a trie.","A set base on a trie.","","","","","","","","","Returns true if the set contains a value.","","","","","","","Visits all the values of a values in the trie, in …","Visits all the pairs of a key of a values in the trie, in …","Visits all the “existing” nodes corresponding to the …","Visits all the “existing” nodes corresponding to the …","Returns the argument unchanged.","Returns the argument unchanged.","Returns a reference to the value corresponding to the key.","Returns a mutable reference to the value corresponding to …","Inserts a value at key if it is None, then returns a …","Inserts a value computed from f at key if it is None, then …","Inserts a key-value pair into the map.","Adds a value to the set.","Calls U::from(self).","Calls U::from(self).","Makes a new empty TrieMap.","Makes a new empty TrieMap.","Removes a key from the map, returning the stored key and …","Removes a value from the set. Returns whether the value was","","","","","","","",""],"i":[0,0,0,2,3,2,3,2,3,2,3,3,2,3,2,3,2,3,3,2,2,3,2,3,2,2,2,2,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3],"f":[0,0,0,[[]],[[]],[[]],[[]],[[[2,[1]]],[[2,[1]]]],[3,3],[[]],[[]],[[3,4],5],[[],2],[[],3],[[[2,[6]],[2,[6]]],5],[[3,3],5],[[[2,[7]],8],9],[[3,8],9],[[3,10]],[[2,10]],[[2,4,10]],[[3,4,10]],[[]],[[]],[[2,4],11],[[2,4],11],[[2,4]],[[2,4,12]],[[2,4],11],[[3,4],5],[[]],[[]],[[],2],[[],3],[[2,4],11],[[3,4],5],[[]],[[]],[[],13],[[],13],[[],13],[[],13],[[],14],[[],14]],"c":[],"p":[[8,"Clone"],[3,"TrieMap"],[3,"TrieSet"],[8,"IntoIterator"],[15,"bool"],[8,"PartialEq"],[8,"Debug"],[3,"Formatter"],[6,"Result"],[8,"FnMut"],[4,"Option"],[8,"FnOnce"],[4,"Result"],[3,"TypeId"]]},\ -"two_sat":{"doc":"2-SAT を解きます。","t":"DLLLLLLLLLLLLLLLLLL","n":["TwoSat","borrow","borrow_mut","build","clone","clone_into","default","eq","fmt","from","hash","implies","into","new","solve","to_owned","try_from","try_into","type_id"],"q":[[0,"two_sat"]],"d":["2-SAT の本体です。","","","","","","","","","Returns the argument unchanged.","","(x == a) -> (y == b) をかつでつなぎます。","Calls U::from(self).","n 個の不定元を持つ Always true を作ります。","充足する割り当てがあれば返し、なければ …","","","",""],"i":[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],"f":[0,[[]],[[]],[1],[1,1],[[]],[[],1],[[1,1],2],[[1,3],4],[[]],[[1,5]],[[1,6,2,6,2]],[[]],[6,1],[1,[[8,[[7,[2]]]]]],[[]],[[],9],[[],9],[[],10]],"c":[],"p":[[3,"TwoSat"],[15,"bool"],[3,"Formatter"],[6,"Result"],[8,"Hasher"],[15,"usize"],[3,"Vec"],[4,"Option"],[4,"Result"],[3,"TypeId"]]},\ "uf_checklist":{"doc":"Union-find …","t":"DDLLLLLLLLLLLLLLLLLLLLLLLLLL","n":["Iter","UfChecklist","borrow","borrow","borrow_mut","borrow_mut","check","clone","clone_into","fmt","fmt","from","from","into","into","into_iter","is_checked","lower_bound","new","next","range_check","to_owned","try_from","try_from","try_into","try_into","type_id","type_id"],"q":[[0,"uf_checklist"]],"d":["UfChecklist::range_check が返すイテレータです。","…","","","","","指定した場所をチェックします。","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Calls U::from(self).","Calls U::from(self).","","指定した場所がチェック済みならば true …","…","区間 [0, n[ …","","区間 range …","","","","","","",""],"i":[0,0,1,6,1,6,1,1,1,1,6,1,6,1,6,6,1,1,1,6,1,1,1,6,1,6,1,6],"f":[0,0,[[]],[[]],[[]],[[]],[[1,2],3],[1,1],[[]],[[1,4],5],[[6,4],5],[[]],[[]],[[]],[[]],[[]],[[1,2],3],[[1,2],[[7,[2]]]],[2,1],[6,7],[[1,[8,[2]]],6],[[]],[[],9],[[],9],[[],9],[[],9],[[],10],[[],10]],"c":[],"p":[[3,"UfChecklist"],[15,"usize"],[15,"bool"],[3,"Formatter"],[6,"Result"],[3,"Iter"],[4,"Option"],[8,"RangeBounds"],[4,"Result"],[3,"TypeId"]]},\ "union_find":{"doc":"Union Find です。","t":"EEIDQEKLLLLLLLLLLLLLLLLLLLLLLLLKLLLLLLLLLLLKLLLLLLLLLLLLLLLLLLL","n":["EdgeCount","HasCycle","Op","UnionFind","Value","VertexCount","add_edge","add_edge","add_edge","add_edge","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","clone","clone_into","default","eq","find","find_mut","fmt","from","from","from","from","from_values","get_value","graft","graft","graft","graft","hash","into","into","into","into","is_root","new","same","singleton","singleton","singleton","singleton","to_owned","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","union","value","value_mut"],"q":[[0,"union_find"]],"d":["辺の本数","サイクルがあるとき、true","…","","頂点重み型","頂点の個数","連結成分に辺を1本追加したとき","","","","","","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","","","…","","","","","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","","","","UnionFind::new() で構築したときのデフォルト値","","","","","","","","","","","","","","","","","","",""],"i":[0,0,0,0,2,0,2,15,16,17,15,16,17,3,15,16,17,3,3,3,3,3,3,3,3,15,16,17,3,3,3,2,15,16,17,3,15,16,17,3,3,3,3,2,15,16,17,3,15,16,17,3,15,16,17,3,15,16,17,3,3,3,3],"f":[0,0,0,0,0,0,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[[3,[[0,[1,2]]]]],[[3,[[0,[1,2]]]]]],[[]],[[],[[3,[[0,[4,2]]]]]],[[[3,[[0,[5,2]]]],[3,[[0,[5,2]]]]],6],[[[3,[2]],7],7],[[[3,[2]],7],7],[[[3,[2]],8],9],[[]],[[]],[[]],[[]],[10,[[3,[2]]]],[[[3,[2]],7]],[[]],[[]],[[]],[[]],[[[3,[[0,[11,2]]]],12]],[[]],[[]],[[]],[[]],[[[3,[2]],7],6],[7,[[3,[2]]]],[[[3,[2]],7,7],6],[[]],[[]],[[]],[[]],[[]],[[],13],[[],13],[[],13],[[],13],[[],13],[[],13],[[],13],[[],13],[[],14],[[],14],[[],14],[[],14],[[[3,[2]],7,7],6],[[[3,[2]],7]],[[[3,[2]],7]]],"c":[],"p":[[8,"Clone"],[8,"Op"],[3,"UnionFind"],[8,"Default"],[8,"PartialEq"],[15,"bool"],[15,"usize"],[3,"Formatter"],[6,"Result"],[3,"Vec"],[8,"Hash"],[8,"Hasher"],[4,"Result"],[3,"TypeId"],[4,"EdgeCount"],[4,"VertexCount"],[4,"HasCycle"]]},\ "veb":{"doc":"A predecessor data structure based on van Emde Boas trees.","t":"NNDELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLMMMMMM","n":["Internal","Leaf","VebMap","VebSet","borrow","borrow","borrow_mut","borrow_mut","collect","collect","contains","contains_key","fmt","fmt","from","from","from_iter","from_iter","get","get_mut","index","index_mut","insert","insert","into","into","is_empty","is_empty","len","len","max","max","max_key","max_value","min","min","min_key","min_value","new","new","pred","pred","pred_eq","pred_eq","pred_eq_key","pred_eq_value","pred_key","pred_value","remove","remove","succ","succ","succ_eq","succ_eq_key","succ_eq_value","succ_key","succ_value","try_from","try_from","try_into","try_into","type_id","type_id","chunks","csize","len","max","min","summary"],"q":[[0,"veb"],[63,"veb::VebSet"]],"d":["","","A van Emde Boas tree-based map. The map is implemented as …","A van Emde Boas tree.","","","","","Returns the elements in the map in ascending order. The …","Returns the elements in the set in ascending order. The …","Returns true if the set contains the given element. …","Returns true if the map contains the given key.","","","Returns the argument unchanged.","Returns the argument unchanged.","","","Returns the value corresponding to the key.","Returns a mutable reference to the value corresponding to …","","","Inserts an element into the map. Returns the previous …","Inserts an element into the set. Returns true if the …","Calls U::from(self).","Calls U::from(self).","Returns true if the map is empty.","Returns true if the set is empty. Returns false if the set …","Returns $|S|$.","Returns the number of elements in the set.","Returns the entry at $\\\\max \\\\left( S \\\\right)$.","Returns the maximum element in the set. Returns None if …","Returns the key $\\\\max \\\\left( S \\\\right)$.","Returns the value at $\\\\max \\\\left( S \\\\right)$.","Returns the entry at $\\\\min \\\\left( S \\\\right)$.","Returns the minimum element in the set. Returns None if …","Returns the key $\\\\min \\\\left( S \\\\right)$.","Returns the value at $\\\\min \\\\left( S \\\\right)$.","Creates a new van Emde Boas tree-based map with the given …","Creates a new van Emde Boas tree with the given capacity.","Returns the entry at $\\\\max \\\\left (i^▽ \\\\right)$.","Returns $\\\\min{j \\\\in S \\\\mid j \\\\le i}$.","Returns the entry at $\\\\max \\\\left (i^▲ \\\\right)$.","Returns $\\\\max{j \\\\in S \\\\mid j \\\\leq i}$.","Returns the key $\\\\max \\\\left (i^▲ \\\\right)$.","Returns the value at $\\\\max \\\\left (i^▲ \\\\right)$.","Returns the key $\\\\max \\\\left (i^▽ \\\\right)$.","Returns the value at $\\\\max \\\\left (i^▽ \\\\right)$.","Returns the value at $i$.","Removes an element from the set. Returns true if the …","Returns the entry at $\\\\min \\\\left (i^△ \\\\right)$.","Returns the minimum element greater than given element. …","Returns the entry at $\\\\min \\\\left (i^▲ \\\\right)$.","Returns the key $\\\\min \\\\left (i^▲ \\\\right)$.","Returns the value at $\\\\min \\\\left (i^▲ \\\\right)$.","Returns the key $\\\\min \\\\left (i^△ \\\\right)$.","Returns the value at $\\\\min \\\\left (i^△ \\\\right)$.","","","","","","","","","","","",""],"i":[3,3,0,0,1,3,1,3,1,3,3,1,1,3,1,3,1,3,1,1,1,1,1,3,1,3,1,3,1,3,1,3,1,1,1,3,1,1,1,3,1,3,1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,3,1,3,1,3,13,13,13,13,13,13],"f":[0,0,0,0,[[]],[[]],[[]],[[]],[1,2],[3,[[2,[4]]]],[[3,4],5],[[1,4],5],[[[1,[6]],7],8],[[3,7],8],[[]],[[]],[9,1],[9,3],[[1,4],10],[[1,4],10],[[1,4]],[[1,4]],[[1,4],10],[[3,4],5],[[]],[[]],[1,5],[3,5],[1,4],[3,4],[1,10],[3,[[10,[4]]]],[1,[[10,[4]]]],[1,10],[1,10],[3,[[10,[4]]]],[1,[[10,[4]]]],[1,10],[4,1],[4,3],[[1,4],10],[[3,4],[[10,[4]]]],[[1,4],10],[[3,4],[[10,[4]]]],[[1,4],[[10,[4]]]],[[1,4],10],[[1,4],[[10,[4]]]],[[1,4],10],[[1,4],10],[[3,4],5],[[1,4],10],[[3,4],[[10,[4]]]],[[1,4],10],[[1,4],[[10,[4]]]],[[1,4],10],[[1,4],[[10,[4]]]],[[1,4],10],[[],11],[[],11],[[],11],[[],11],[[],12],[[],12],0,0,0,0,0,0],"c":[],"p":[[3,"VebMap"],[3,"Vec"],[4,"VebSet"],[15,"usize"],[15,"bool"],[8,"Debug"],[3,"Formatter"],[6,"Result"],[8,"IntoIterator"],[4,"Option"],[4,"Result"],[3,"TypeId"],[13,"Internal"]]},\ diff --git a/settings.html b/settings.html index c2310db5..cb045a36 100644 --- a/settings.html +++ b/settings.html @@ -1,4 +1,4 @@ -Rustdoc settings
Rustdoc settings
-

Rustdoc settings

Back
\ No newline at end of file +

Rustdoc settings

Back
\ No newline at end of file diff --git a/source-files.js b/source-files.js index b778dc8b..6c1dad47 100644 --- a/source-files.js +++ b/source-files.js @@ -19,6 +19,7 @@ var sourcesIndex = JSON.parse('{\ "fp":["",[],["ext_gcd.rs","factorial.rs","fourier.rs","lib.rs"]],\ "fps":["",[],["lib.rs"]],\ "gco":["",[],["lib.rs"]],\ +"graph":["",[],["csr.rs","lib.rs"]],\ "gss":["",[],["lib.rs"]],\ "heap_slope_trick":["",[],["lib.rs"]],\ "heap_tricks":["",[],["lib.rs"]],\ @@ -49,7 +50,6 @@ var sourcesIndex = JSON.parse('{\ "rb":["",[],["balance.rs","lib.rs","map.rs","seq.rs"]],\ "rbtree":["",[],["lib.rs","nonempty.rs"]],\ "riff":["",[],["binary_search.rs","bitmask_iterators.rs","bitmask_operations.rs","change_min_max.rs","lib.rs","numeric_traits.rs","pop_if.rs"]],\ -"scc":["",[],["lib.rs"]],\ "segbeats":["",[],["lib.rs"]],\ "segbeats_task3":["",[],["lib.rs"]],\ "segtree":["",[],["lib.rs"]],\ @@ -62,7 +62,6 @@ var sourcesIndex = JSON.parse('{\ "tree_fold":["",[],["lib.rs"]],\ "trial":["",[],["divisors.rs","lib.rs","prime_factors.rs"]],\ "trie":["",[],["lib.rs","trie_map.rs","trie_set.rs"]],\ -"two_sat":["",[],["lib.rs"]],\ "uf_checklist":["",[],["lib.rs"]],\ "union_find":["",[],["lib.rs"]],\ "veb":["",[],["lib.rs"]],\ diff --git a/src/graph/csr.rs.html b/src/graph/csr.rs.html new file mode 100644 index 00000000..c1ac6f2a --- /dev/null +++ b/src/graph/csr.rs.html @@ -0,0 +1,845 @@ +csr.rs - source
+ + + + + +
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+
use std::fmt::Debug;
+use std::ops::Deref;
+use std::ops::DerefMut;
+use std::ops::Index;
+use std::ops::IndexMut;
+
+/// Compressed Sparse Row format
+///
+/// # Notation
+///
+/// - $X = [x_0, x_1, \dots, x_{n-1}]$: `data`
+/// - $S = [s_0, s_1, \dots, s_{m}]$: `boundaries`
+///
+/// # Invariants
+///
+/// - $0 = s_0 \leq s_1 \leq \dots \leq s_m = n$
+///
+/// # Semantics
+///
+/// This struct represents a list of lists $A$ of elements of type `T`.
+///
+/// $$
+/// A_{i, j} = X[s_i + j]
+/// $$
+///
+pub struct Csr<T> {
+    /// $X = [x_0, x_1, \dots, x_{n-1}]$
+    pub data: Vec<T>,
+    /// $S = [s_0, s_1, \dots, s_{m}]$
+    pub boundary: Vec<usize>,
+}
+
+impl<T> Csr<T> {
+    /// Create a CSR corrsponding to $A = [\ ]$.
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// use graph::Csr;
+    /// let csr: Csr<usize> = Csr::new();
+    /// assert!(csr.is_empty());
+    /// ```
+    pub fn new() -> Self {
+        Csr {
+            data: Vec::new(),
+            boundary: vec![0],
+        }
+    }
+    /// Create a CSR corrsponding to $A = [\ ]$ with preallocated memory.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let csr: Csr<usize> = Csr::with_capacity(10, 5);
+    /// assert!(csr.is_empty());
+    /// ```
+    pub fn with_capacity(data_capacity: usize, sections_capacity: usize) -> Self {
+        let data = Vec::with_capacity(data_capacity);
+        let mut boundary = Vec::with_capacity(sections_capacity + 1);
+        boundary.push(0);
+        Csr { data, boundary }
+    }
+    /// Create a CSR from a list of sections.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// assert_eq!(csr.section(0), &[1, 2, 3]);
+    /// assert_eq!(csr.section(1), &[4, 5]);
+    /// ```
+    pub fn from_sections<A>(rows: &[A]) -> Self
+    where
+        A: AsRef<[T]>,
+        T: Clone,
+    {
+        let mut csr = Csr::new();
+        for row in rows {
+            csr.push_section(row.as_ref());
+        }
+        csr
+    }
+    /// Get the $i$-th section $A_i$. Alias for `&self[i]`.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// assert_eq!(csr.section(0), &[1, 2, 3]);
+    /// ```
+    pub fn section(&self, i: usize) -> &[T] {
+        &self.data[self.boundary[i]..self.boundary[i + 1]]
+    }
+    /// Get the mutable $i$-th section $A_i$. Alias for `&mut self[i]`.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// csr.section_mut(0)[0] = 42;
+    /// assert_eq!(csr.section(0), &[42, 2, 3]);
+    /// ```
+    pub fn section_mut(&mut self, i: usize) -> &mut [T] {
+        &mut self.data[self.boundary[i]..self.boundary[i + 1]]
+    }
+    /// Check if the CSR is empty. (i.e. $A = [\ ]$)
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let csr = Csr::<()>::new();
+    /// assert!(csr.is_empty());
+    /// ```
+    pub fn is_empty(&self) -> bool {
+        self.boundary.len() == 1
+    }
+    /// Get the number of sections $m = |A|$.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// assert_eq!(csr.len(), 2);
+    /// ```
+    pub fn len(&self) -> usize {
+        self.boundary.len() - 1
+    }
+    /// Get the total number of elements in $A$. (i.e. $\sum_{i=0}^{m-1} |A_i|$)
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// assert_eq!(csr.flat_len(), 5);
+    /// ```
+    pub fn flat_len(&self) -> usize {
+        self.data.len()
+    }
+    /// Get the mutable and extendable reference to the last section.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// csr.last_mut().push(42);
+    /// assert_eq!(csr.section(1), &[4, 5, 42]);
+    /// ```
+    pub fn last_mut(&mut self) -> LastMut<T> {
+        LastMut { csr: self }
+    }
+    /// Push an empty section $A_m = [\ ]$.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let mut csr = Csr::<()>::new();
+    /// csr.push_empty();
+    /// assert_eq!(csr.section(0), &[]);
+    /// ```
+    pub fn push_empty(&mut self) {
+        self.boundary.push(self.data.len());
+    }
+    /// Clone and push a section.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let mut csr = Csr::new();
+    /// csr.push_section(&[1, 2, 3]);
+    /// assert_eq!(csr.section(0), &[1, 2, 3]);
+    /// ```
+    pub fn push_section(&mut self, section: &[T])
+    where
+        T: Clone,
+    {
+        self.data.extend_from_slice(section);
+        self.boundary.push(self.data.len());
+    }
+    /// Return an iterator over the sections.
+    ///
+    pub fn iter(&self) -> Iter<T> {
+        Iter {
+            data: &self.data,
+            boundary: &self.boundary,
+        }
+    }
+    /// Copies `self` into a new `Vec<Vec<T>>`.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// assert_eq!(csr.to_vec(), vec![vec![1, 2, 3], vec![4, 5]]);
+    /// ```
+    pub fn to_vec(&self) -> Vec<Vec<T>>
+    where
+        T: Clone,
+    {
+        self.iter().map(<[T]>::to_vec).collect()
+    }
+}
+
+/// Mutable and extendable reference to the last section.
+pub struct LastMut<'a, T> {
+    csr: &'a mut Csr<T>,
+}
+impl<'a, T> LastMut<'a, T> {
+    /// Push an element to the last section.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// csr.last_mut().push(42);
+    /// assert_eq!(csr.section(1), &[4, 5, 42]);
+    /// ```
+    pub fn push(self, x: T) {
+        self.csr.data.push(x);
+        *self.csr.boundary.last_mut().unwrap() = self.csr.data.len();
+    }
+    /// Extend the last section with an iterator.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// csr.last_mut().extend(vec![42, 43]);
+    /// assert_eq!(csr.section(1), &[4, 5, 42, 43]);
+    /// ```
+    pub fn extend<I: IntoIterator<Item = T>>(self, iter: I) {
+        self.csr.data.extend(iter);
+        *self.csr.boundary.last_mut().unwrap() = self.csr.data.len();
+    }
+
+    /// Copy elements from a slice to the last section.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let mut csr = Csr::from_sections(&[vec![1, 2, 3], vec![4, 5]]);
+    /// csr.last_mut().extend_from_slice(&[42, 43]);
+    /// assert_eq!(csr.section(1), &[4, 5, 42, 43]);
+    pub fn extend_from_slice(&mut self, slice: &[T])
+    where
+        T: Clone,
+    {
+        self.csr.data.extend_from_slice(slice);
+        *self.csr.boundary.last_mut().unwrap() = self.csr.data.len();
+    }
+}
+impl<T> Deref for LastMut<'_, T> {
+    type Target = [T];
+    fn deref(&self) -> &Self::Target {
+        &self.csr.data[self.csr.boundary[self.csr.boundary.len() - 2]..]
+    }
+}
+impl<T> DerefMut for LastMut<'_, T> {
+    fn deref_mut(&mut self) -> &mut Self::Target {
+        &mut self.csr.data[self.csr.boundary[self.csr.boundary.len() - 2]..]
+    }
+}
+
+impl<T, A> FromIterator<A> for Csr<T>
+where
+    A: IntoIterator<Item = T>,
+{
+    fn from_iter<I: IntoIterator<Item = A>>(iter: I) -> Self {
+        let mut csr = Csr::new();
+        for section in iter {
+            csr.push_empty();
+            for x in section {
+                csr.last_mut().push(x);
+            }
+        }
+        csr
+    }
+}
+
+impl Csr<usize> {
+    /// Create a CSR from a list of edges.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let csr = Csr::from_edges(3, &[(0, 1), (1, 2), (2, 0)]);
+    /// assert_eq!(csr.to_vec(), vec![vec![1], vec![2], vec![0]]);
+    /// ```
+    pub fn from_edges(n: usize, edges: &[(usize, usize)]) -> Self {
+        let mut csr = Csr {
+            data: vec![usize::MAX; edges.len()],
+            boundary: vec![0; n + 1],
+        };
+        for &(i, _) in edges {
+            csr.boundary[i] += 1;
+        }
+        for i in 1..=n {
+            csr.boundary[i] += csr.boundary[i - 1];
+        }
+        for &(i, j) in edges {
+            csr.boundary[i] -= 1;
+            csr.data[csr.boundary[i]] = j;
+        }
+        csr
+    }
+    /// Create CSRs of $G$ and $G^{\mathrm{op}}$ from a list of edges.
+    ///
+    /// # Example
+    /// ```
+    /// use graph::Csr;
+    /// let (g, rg) = Csr::from_edges_and_rev(3, &[(0, 1), (1, 2), (2, 0)]);
+    /// assert_eq!(g.to_vec(), vec![vec![1], vec![2], vec![0]]);
+    /// assert_eq!(rg.to_vec(), vec![vec![2], vec![0], vec![1]]);
+    /// ```
+    pub fn from_edges_and_rev(n: usize, edges: &[(usize, usize)]) -> (Self, Self) {
+        let mut forward = Csr {
+            data: vec![usize::MAX; edges.len()],
+            boundary: vec![0; n + 1],
+        };
+        let mut backward = Csr {
+            data: vec![usize::MAX; edges.len()],
+            boundary: vec![0; n + 1],
+        };
+        for &(i, j) in edges {
+            forward.boundary[i] += 1;
+            backward.boundary[j] += 1;
+        }
+        for i in 1..=n {
+            forward.boundary[i] += forward.boundary[i - 1];
+            backward.boundary[i] += backward.boundary[i - 1];
+        }
+        for &(i, j) in edges {
+            forward.boundary[i] -= 1;
+            forward.data[forward.boundary[i]] = j;
+            backward.boundary[j] -= 1;
+            backward.data[backward.boundary[j]] = i;
+        }
+        (forward, backward)
+    }
+}
+
+impl<T> Default for Csr<T> {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl<T> Debug for Csr<T>
+where
+    T: Debug,
+{
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        f.debug_list().entries(self.iter()).finish()
+    }
+}
+
+/// Immutable iterator over rows.
+pub struct Iter<'a, T> {
+    pub(crate) data: &'a [T],
+    pub(crate) boundary: &'a [usize],
+}
+impl<'a, T> Iterator for Iter<'a, T> {
+    type Item = &'a [T];
+    fn next(&mut self) -> Option<Self::Item> {
+        if self.boundary.len() <= 1 {
+            return None;
+        }
+        let &[l, r] = &self.boundary[..2] else { unreachable!() };
+        self.boundary = &self.boundary[1..];
+        Some(&self.data[l..r])
+    }
+}
+impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
+    fn next_back(&mut self) -> Option<Self::Item> {
+        if self.boundary.len() <= 1 {
+            return None;
+        }
+        let &[l, r] = &self.boundary[self.boundary.len() - 2..] else { unreachable!() };
+        self.boundary = &self.boundary[..self.boundary.len() - 1];
+        Some(&self.data[l..r])
+    }
+}
+impl<'a, T> ExactSizeIterator for Iter<'a, T> {
+    fn len(&self) -> usize {
+        self.boundary.len() - 1
+    }
+}
+impl<'a, T> IntoIterator for &'a Csr<T> {
+    type Item = &'a [T];
+    type IntoIter = Iter<'a, T>;
+    fn into_iter(self) -> Self::IntoIter {
+        self.iter()
+    }
+}
+
+impl<T> Index<usize> for Csr<T> {
+    type Output = [T];
+    fn index(&self, i: usize) -> &[T] {
+        self.section(i)
+    }
+}
+impl<T> IndexMut<usize> for Csr<T> {
+    fn index_mut(&mut self, i: usize) -> &mut [T] {
+        self.section_mut(i)
+    }
+}
+
\ No newline at end of file diff --git a/src/graph/lib.rs.html b/src/graph/lib.rs.html new file mode 100644 index 00000000..599f67ad --- /dev/null +++ b/src/graph/lib.rs.html @@ -0,0 +1,189 @@ +lib.rs - source
+ + + + + +
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+
//! Kosaraju's algorithm for strongly connected components
+//!
+//! # Note: CSR (Compressed Sparse Row)
+//!
+//! Graphs and set partitions are represented in CSR format [`Csr`].
+//!
+//!
+//! # Examples
+//! ```
+//! use graph::kosaraju;
+//! let n = 6;
+//! let edges = [ (1, 4), (5, 2), (3, 0), (5, 5), (4, 1), (0, 3), (4, 2)];
+//! let scc = kosaraju(n, &edges);
+//! assert_eq!(scc.len(), 4);
+//! assert_eq!(scc[0], [5]);
+//! assert_eq!(scc[1], [1, 4]);
+//! assert_eq!(scc[2], [2]);
+//! assert_eq!(scc[3], [0, 3]);
+//! ```
+mod csr;
+
+pub use csr::Csr;
+pub use csr::Iter;
+pub use csr::LastMut;
+
+/// Returns the strongly connected components of a directed graph.
+///
+/// # Examples
+/// ```
+/// use graph::kosaraju;
+/// let n = 6;
+/// let edges = [ (1, 4), (5, 2), (3, 0), (5, 5), (4, 1), (0, 3), (4, 2)];
+/// let scc = kosaraju(n, &edges);
+/// assert_eq!(scc.len(), 4);
+/// assert_eq!(scc[0], [5]);
+/// assert_eq!(scc[1], [1, 4]);
+/// assert_eq!(scc[2], [2]);
+/// assert_eq!(scc[3], [0, 3]);
+/// ```
+pub fn kosaraju(n: usize, edges: &[(usize, usize)]) -> Csr<usize> {
+    let (g, rg) = Csr::from_edges_and_rev(n, edges);
+    let mut sorted = Vec::with_capacity(n);
+    let mut cmp = vec![0; n];
+    for i in 0..n {
+        if cmp[i] == 0 {
+            dfs1(i, &g, &mut sorted, &mut cmp);
+        }
+    }
+    let mut out = Csr::with_capacity(n, n);
+    for &i in sorted.iter().rev() {
+        if cmp[i] == usize::MAX {
+            out.push_empty();
+            dfs2(i, &rg, &mut out, &mut cmp);
+        }
+    }
+    out
+}
+
+fn dfs1(i: usize, g: &Csr<usize>, sorted: &mut Vec<usize>, cmp: &mut [usize]) {
+    cmp[i] = usize::MAX;
+    for &y in &g[i] {
+        if cmp[y] == 0 {
+            dfs1(y, g, sorted, cmp);
+        }
+    }
+    sorted.push(i);
+}
+
+fn dfs2(i: usize, rg: &Csr<usize>, out: &mut Csr<usize>, cmp: &mut [usize]) {
+    cmp[i] = out.len();
+    out.last_mut().push(i);
+    for &y in &rg[i] {
+        if cmp[y] == usize::MAX {
+            dfs2(y, rg, out, cmp);
+        }
+    }
+}
+
\ No newline at end of file diff --git a/src/riff/bitmask_iterators.rs.html b/src/riff/bitmask_iterators.rs.html index 4c0f67a2..ff8b92d4 100644 --- a/src/riff/bitmask_iterators.rs.html +++ b/src/riff/bitmask_iterators.rs.html @@ -139,7 +139,7 @@ assert!(k < T::bit_length() && k < T::bit_length()); BitmaskCombinations { n, - bs: (T::one() << k) - T::one(), + bs: (T::ONE << k) - T::ONE, } } @@ -152,12 +152,12 @@ type Item = T; fn next(&mut self) -> Option<Self::Item> { - if (T::one() << self.n) <= self.bs { + if (T::ONE << self.n) <= self.bs { return None; } let res = Some(self.bs); - self.bs = if self.bs == T::zero() { - T::one() << self.n + self.bs = if self.bs == T::ZERO { + T::ONE << self.n } else { let x = self.bs & self.bs.wrapping_neg(); let y = self.bs + x; @@ -201,10 +201,10 @@ return None; } let res = Some(self.bs ^ self.full); - if self.bs == T::zero() { + if self.bs == T::ZERO { self.finished = true; } else { - self.bs -= T::one(); + self.bs -= T::ONE; self.bs &= self.full; } res diff --git a/src/riff/bitmask_operations.rs.html b/src/riff/bitmask_operations.rs.html index 90b3effa..16917d8a 100644 --- a/src/riff/bitmask_operations.rs.html +++ b/src/riff/bitmask_operations.rs.html @@ -47,19 +47,31 @@ 13 14 15 +16 +17 +18 +19 +20 +21
use crate::Unsigned;
 
 /// Returns $2^n - 1$.
 ///
 /// # Examples
 /// ```
-/// use crate::i2powm1;
+/// use riff::i2powm1;
 /// assert_eq!(i2powm1::<u32>(0), 0);
 /// assert_eq!(i2powm1::<u32>(1), 1);
 /// assert_eq!(i2powm1::<u32>(2), 3);
 /// assert_eq!(i2powm1::<u32>(3), 7);
+/// assert_eq!(i2powm1::<u32>(31), 0x7FFF_FFFF);
+/// assert_eq!(i2powm1::<u32>(32), 0xFFFF_FFFF);
 /// ```
 pub fn i2powm1<T: Unsigned>(n: u32) -> T {
-    T::MAX >> (T::BITS - n)
+    if n == T::bit_length() {
+        T::MAX
+    } else {
+        (T::ONE << n) - T::ONE
+    }
 }
 
\ No newline at end of file diff --git a/src/riff/numeric_traits.rs.html b/src/riff/numeric_traits.rs.html index 374a0313..0c88e4f8 100644 --- a/src/riff/numeric_traits.rs.html +++ b/src/riff/numeric_traits.rs.html @@ -157,8 +157,8 @@ { const BITS: u32; const MAX: Self; - fn zero() -> Self; - fn one() -> Self; + const ZERO: Self; + const ONE: Self; fn wrapping_neg(self) -> Self; fn bit_length() -> u32 { size_of::<Self>() as u32 * 8 @@ -170,8 +170,8 @@ impl Unsigned for $T { const BITS: u32 = <$T>::BITS; const MAX: Self = <$T>::MAX; - fn zero() -> Self { 0 } - fn one() -> Self { 1 } + const ZERO: Self = 0; + const ONE: Self = 1; fn wrapping_neg(self) -> Self { self.wrapping_neg() } } )*} diff --git a/src/scc/lib.rs.html b/src/scc/lib.rs.html deleted file mode 100644 index cdbea206..00000000 --- a/src/scc/lib.rs.html +++ /dev/null @@ -1,851 +0,0 @@ -lib.rs - source
- - - - - -
1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
-97
-98
-99
-100
-101
-102
-103
-104
-105
-106
-107
-108
-109
-110
-111
-112
-113
-114
-115
-116
-117
-118
-119
-120
-121
-122
-123
-124
-125
-126
-127
-128
-129
-130
-131
-132
-133
-134
-135
-136
-137
-138
-139
-140
-141
-142
-143
-144
-145
-146
-147
-148
-149
-150
-151
-152
-153
-154
-155
-156
-157
-158
-159
-160
-161
-162
-163
-164
-165
-166
-167
-168
-169
-170
-171
-172
-173
-174
-175
-176
-177
-178
-179
-180
-181
-182
-183
-184
-185
-186
-187
-188
-189
-190
-191
-192
-193
-194
-195
-196
-197
-198
-199
-200
-201
-202
-203
-204
-205
-206
-207
-208
-209
-210
-211
-212
-213
-214
-215
-216
-217
-218
-219
-220
-221
-222
-223
-224
-225
-226
-227
-228
-229
-230
-231
-232
-233
-234
-235
-236
-237
-238
-239
-240
-241
-242
-243
-244
-245
-246
-247
-248
-249
-250
-251
-252
-253
-254
-255
-256
-257
-258
-259
-260
-261
-262
-263
-264
-265
-266
-267
-268
-269
-270
-271
-272
-273
-274
-275
-276
-277
-278
-279
-280
-281
-282
-283
-284
-285
-286
-287
-288
-289
-290
-291
-292
-293
-294
-295
-296
-297
-298
-299
-300
-301
-302
-303
-304
-305
-306
-307
-308
-309
-310
-311
-312
-313
-314
-315
-316
-317
-318
-319
-320
-321
-322
-323
-324
-325
-326
-327
-328
-329
-330
-331
-332
-333
-334
-335
-336
-337
-338
-339
-340
-341
-342
-343
-344
-345
-346
-347
-348
-349
-350
-351
-352
-353
-354
-355
-356
-357
-358
-359
-360
-361
-362
-363
-364
-365
-366
-367
-368
-369
-370
-371
-372
-373
-374
-375
-376
-377
-378
-379
-380
-381
-382
-383
-384
-385
-386
-387
-388
-389
-390
-391
-392
-393
-394
-395
-396
-397
-398
-399
-400
-401
-402
-403
-404
-405
-406
-407
-408
-
//!
-//! # このライブラリを使える問題
-//!
-//! - AOJ GRL_3_C - 強連結成分分解
-//!   - 問題: <https://onlinejudge.u-aizu.ac.jp/problems/GRL_3_C>
-//!   - 提出 (8 ms):
-//!   <https://onlinejudge.u-aizu.ac.jp/status/users/ngtkana/submissions/1/GRL_3_C/judge/6179065/Rust>
-//!   - 出題日: 2016-09-04
-//!   - 難易度: 易しめ。
-//!   - 制約:
-//!     - N ≤ 10,000
-//!     - M ≤ 30,000
-//!     - Q ≤ 100,000
-use std::collections::HashSet;
-use std::mem::replace;
-
-/// 本体です。
-#[derive(Clone, Debug, Default, Hash, PartialEq, Eq)]
-pub struct Scc {
-    g: Vec<Vec<usize>>,
-    rg: Vec<Vec<usize>>,
-    ord: Vec<usize>,    // トポロジカル順序に従って頂点番号が入ります。
-    cmp_of: Vec<usize>, // 各頂点の属する強連結成分番号が入ります
-    cmp_count: usize,   // 強連結成分の総数が入ります。
-    built: bool,
-}
-impl Scc {
-    /// 管理しているグラフが空グラフならば、`true` を返します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let scc = Scc::new(0);
-    /// assert!(scc.is_empty());
-    ///
-    /// let scc = Scc::new(1);
-    /// assert!(!scc.is_empty());
-    /// ```
-    pub fn is_empty(&self) -> bool {
-        self.g.is_empty()
-    }
-
-    /// 管理しているグラフの頂点数を返します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let scc = Scc::new(0);
-    /// assert_eq!(scc.len(), 0);
-    ///
-    /// let scc = Scc::new(1);
-    /// assert_eq!(scc.len(), 1);
-    /// ```
-    pub fn len(&self) -> usize {
-        self.g.len()
-    }
-
-    /// 頂点数 `n` の辺のない未ビルドのグラフを構築します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let scc = Scc::new(42);
-    /// ```
-    pub fn new(n: usize) -> Self {
-        Self {
-            g: vec![Vec::new(); n],
-            rg: vec![Vec::new(); n],
-            ord: Vec::new(),
-            cmp_of: Vec::new(),
-            cmp_count: 0,
-            built: false,
-        }
-    }
-
-    /// 【Require: 未ビルド】
-    /// 辺 (from, to) を追加します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(42);
-    /// scc.add_edge(13, 18);
-    /// scc.add_edge(13, 6);
-    /// assert_eq!(&scc.g()[13], &[18, 6]);
-    /// assert_eq!(&scc.g()[6], &[]);
-    /// ```
-    pub fn add_edge(&mut self, from: usize, to: usize) {
-        assert!(!self.built);
-        self.g[from].push(to);
-        self.rg[to].push(from);
-    }
-
-    /// 正向きのグラフの隣接リストを返します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(42);
-    /// scc.add_edge(13, 18);
-    /// scc.add_edge(13, 6);
-    /// assert_eq!(&scc.g()[13], &[18, 6]);
-    /// assert_eq!(&scc.g()[6], &[]);
-    /// ```
-    pub fn g(&self) -> &[Vec<usize>] {
-        &self.g
-    }
-
-    /// 逆向きのグラフの隣接リストを返します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(42);
-    /// scc.add_edge(13, 18);
-    /// scc.add_edge(13, 6);
-    /// assert_eq!(&scc.rg()[13], &[]);
-    /// assert_eq!(&scc.rg()[6], &[13]);
-    /// ```
-    pub fn rg(&self) -> &[Vec<usize>] {
-        &self.rg
-    }
-
-    /// 【Require: ビルド済み】
-    /// 商グラフにおけるトポロジカル順序に従って頂点番号の入ったスライスを返します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(6);
-    /// scc.add_edge(2, 0);
-    /// scc.add_edge(1, 0);
-    /// scc.add_edge(3, 4);
-    /// scc.add_edge(4, 5);
-    /// scc.add_edge(5, 4);
-    /// scc.build();
-    /// assert_eq!(&scc.ord(), &[3, 4, 5, 2, 1, 0]);
-    /// ```
-    pub fn ord(&self) -> &[usize] {
-        assert!(self.built);
-        &self.ord
-    }
-
-    /// 【Require: ビルド済み】
-    /// 強連結成分の個数を返します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(6);
-    /// scc.add_edge(2, 0);
-    /// scc.add_edge(1, 0);
-    /// scc.add_edge(3, 4);
-    /// scc.add_edge(4, 5);
-    /// scc.add_edge(5, 4);
-    /// scc.build();
-    /// assert_eq!(scc.cmp_count(), 5);
-    /// ```
-    pub fn cmp_count(&self) -> usize {
-        assert!(self.built);
-        self.cmp_count
-    }
-
-    /// 【Require: ビルド済み】
-    /// 頂点 `x` の属する強連結成分の番号を返します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(6);
-    /// scc.add_edge(2, 0);
-    /// scc.add_edge(1, 0);
-    /// scc.add_edge(3, 4);
-    /// scc.add_edge(4, 5);
-    /// scc.add_edge(5, 4);
-    /// scc.build();
-    /// assert_eq!(scc.cmp_of(0), 4);
-    /// assert_eq!(scc.cmp_of(1), 3);
-    /// ```
-    pub fn cmp_of(&self, x: usize) -> usize {
-        assert!(self.built);
-        self.cmp_of[x]
-    }
-
-    /// 【Require: ビルド済み】
-    /// 頂点番号から、その属する強連結成分の番号を検索できる
-    /// スライスを返します。
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(6);
-    /// scc.add_edge(2, 0);
-    /// scc.add_edge(1, 0);
-    /// scc.add_edge(3, 4);
-    /// scc.add_edge(4, 5);
-    /// scc.add_edge(5, 4);
-    /// scc.build();
-    /// assert_eq!(scc.cmp_of(0), 4);
-    /// assert_eq!(scc.cmp_of(1), 3);
-    /// ```
-    pub fn cmp_ofs(&self) -> &[usize] {
-        assert!(self.built);
-        &self.cmp_of
-    }
-
-    /// 【Require: ビルド済み】
-    /// 辺の重複と自己辺を除いた商グラフを構築して返します。
-    ///
-    /// # 計算量
-    ///
-    /// O(N)
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(6);
-    /// scc.add_edge(2, 0);
-    /// scc.add_edge(1, 0);
-    /// scc.add_edge(3, 4);
-    /// scc.add_edge(4, 5);
-    /// scc.add_edge(5, 4);
-    /// scc.build();
-    ///
-    /// let g = scc.quotient_graph();
-    /// let expected = vec![vec![1], vec![], vec![4], vec![4], vec![]];
-    /// assert_eq!(g, expected);
-    /// ```
-    pub fn quotient_graph(&self) -> Vec<Vec<usize>> {
-        assert!(self.built);
-        let mut ans = vec![Vec::new(); self.cmp_count];
-        let mut used = HashSet::new();
-        for x in 0..self.len() {
-            for &y in &self.g[x] {
-                let x = self.cmp_of[x];
-                let y = self.cmp_of[y];
-                if x != y && used.insert((x, y)) {
-                    ans[x].push(y);
-                }
-            }
-        }
-        ans
-    }
-
-    /// 【Require: ビルド済み】
-    /// 各強連結成分に属する頂点全体の集合を、[`Self::ord()`]  と同じ
-    /// トポロジカル順序順序で返します。
-    ///
-    /// # 計算量
-    ///
-    /// O(N)
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(6);
-    /// scc.add_edge(2, 0);
-    /// scc.add_edge(1, 0);
-    /// scc.add_edge(3, 4);
-    /// scc.add_edge(4, 5);
-    /// scc.add_edge(5, 4);
-    /// scc.build();
-    ///
-    /// let g = scc.quotient_set();
-    /// let expected = vec![vec![3], vec![4, 5], vec![2], vec![1], vec![0]];
-    /// assert_eq!(g, expected);
-    /// ```
-    pub fn quotient_set(&self) -> Vec<Vec<usize>> {
-        assert!(self.built);
-        let mut ans = vec![Vec::new(); self.cmp_count];
-        for &x in &self.ord {
-            ans[self.cmp_of(x)].push(x);
-        }
-        ans
-    }
-
-    /// 【Require: 未ビルド】
-    /// ビルドします。
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// use scc::Scc;
-    ///
-    /// let mut scc = Scc::new(6);
-    /// scc.add_edge(2, 0);
-    /// scc.add_edge(1, 0);
-    /// scc.add_edge(3, 4);
-    /// scc.add_edge(4, 5);
-    /// scc.add_edge(5, 4);
-    /// scc.build();
-    /// ```
-    pub fn build(&mut self) {
-        assert!(!self.built);
-        self.built = true;
-        let mut cmp_of = vec![0; self.len()];
-        let mut ord = Vec::new();
-        (0..self.len()).for_each(|i| self.dfs1(i, &mut cmp_of, &mut ord));
-        ord.reverse();
-        for &i in &ord {
-            if cmp_of[i] == !0 {
-                self.dfs2(i, &mut cmp_of);
-                self.cmp_count += 1;
-            }
-        }
-        self.cmp_of = cmp_of;
-        self.ord = ord;
-    }
-
-    fn dfs1(&self, x: usize, cmp_of: &mut [usize], ord: &mut Vec<usize>) {
-        if replace(&mut cmp_of[x], !0) == 0 {
-            self.g[x].iter().for_each(|&y| self.dfs1(y, cmp_of, ord));
-            ord.push(x);
-        }
-    }
-
-    fn dfs2(&self, x: usize, cmp_of: &mut [usize]) {
-        cmp_of[x] = self.cmp_count;
-        for &y in &self.rg[x] {
-            if cmp_of[y] == !0 {
-                self.dfs2(y, cmp_of);
-            }
-        }
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-    use rand::prelude::StdRng;
-    use rand::Rng;
-    use rand::SeedableRng;
-
-    #[test]
-    fn test_scc() {
-        let mut rng = StdRng::seed_from_u64(42);
-        for _ in 0..20 {
-            let n = rng.gen_range(1..20);
-            let m = rng.gen_range(0..20);
-            let mut g = vec![vec![false; n]; n];
-            (0..n).for_each(|i| g[i][i] = true);
-            let mut scc = Scc::new(n);
-            for _ in 0..m {
-                let u = rng.gen_range(0..n);
-                let v = rng.gen_range(0..n);
-                g[u][v] = true;
-                scc.add_edge(u, v);
-            }
-            scc.build();
-            for k in 0..n {
-                for i in 0..n {
-                    for j in 0..n {
-                        g[i][j] |= g[i][k] && g[k][j];
-                    }
-                }
-            }
-
-            // equiv クエリ
-            for i in 0..n {
-                for j in 0..n {
-                    let result = scc.cmp_of(i) == scc.cmp_of(j);
-                    let expected = g[i][j] && g[j][i];
-                    assert_eq!(result, expected);
-                }
-            }
-            // その他整合性
-            let qset = scc.quotient_set();
-            assert_eq!(qset.iter().map(std::vec::Vec::len).sum::<usize>(), n);
-            assert_eq!(qset.len(), scc.cmp_count());
-            let mut used = vec![false; n];
-            for (i, qset) in qset.iter().enumerate() {
-                assert!(!qset.is_empty());
-                for &j in qset {
-                    assert_eq!(scc.cmp_of(j), i);
-                    assert!(!used[j]);
-                    used[j] = true;
-                }
-            }
-            for (i, &j) in scc.cmp_ofs().iter().enumerate() {
-                assert_eq!(j, scc.cmp_of(i));
-            }
-        }
-    }
-}
-
\ No newline at end of file diff --git a/src/two_sat/lib.rs.html b/src/two_sat/lib.rs.html deleted file mode 100644 index a95cb73e..00000000 --- a/src/two_sat/lib.rs.html +++ /dev/null @@ -1,337 +0,0 @@ -lib.rs - source
- - - - - -
1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
-97
-98
-99
-100
-101
-102
-103
-104
-105
-106
-107
-108
-109
-110
-111
-112
-113
-114
-115
-116
-117
-118
-119
-120
-121
-122
-123
-124
-125
-126
-127
-128
-129
-130
-131
-132
-133
-134
-135
-136
-137
-138
-139
-140
-141
-142
-143
-144
-145
-146
-147
-148
-149
-150
-151
-
//! 2-SAT を解きます。
-//!
-//! # 依存ライブラリ
-//!
-//! - `scc`
-//!
-//!
-//! # Examples
-//!
-//! ```
-//! # use two_sat::TwoSat;
-//! let mut two_sat = TwoSat::new(3);
-//!
-//! two_sat.implies(0, true, 1, true);
-//! two_sat.implies(1, true, 2, true);
-//! two_sat.implies(2, true, 0, false);
-//! two_sat.implies(2, true, 1, false);
-//! two_sat.build();
-//!
-//! // Debug がきれいです。
-//! let expected = "[0→1, 0→¬2, ¬1→¬0, 1→2, 1→¬2, ¬2→¬1, 2→¬0, 2→¬1]";
-//! assert_eq!(format!("{:?}", &two_sat).as_str(), expected);
-//!
-//! // 解きます。
-//! assert_eq!(Some(vec![false, false, true]), two_sat.solve());
-//! ```
-
-use scc::Scc;
-use std::cmp::Ordering;
-use std::fmt::Debug;
-
-/// 2-SAT の本体です。
-#[derive(Clone, Default, Hash, PartialEq, Eq)]
-pub struct TwoSat {
-    scc: Scc,
-}
-impl TwoSat {
-    /// `n` 個の不定元を持つ Always true を作ります。
-    pub fn new(n: usize) -> Self {
-        Self {
-            scc: Scc::new(2 * n),
-        }
-    }
-
-    /// `(x == a) -> (y == b)` をかつでつなぎます。
-    pub fn implies(&mut self, x: usize, a: bool, y: usize, b: bool) {
-        let x = 2 * x + usize::from(a);
-        let y = 2 * y + usize::from(b);
-        self.scc.add_edge(x, y);
-        self.scc.add_edge(y ^ 1, x ^ 1);
-    }
-
-    /// 充足する割り当てがあれば返し、なければ `None` を返します。
-    pub fn solve(&self) -> Option<Vec<bool>> {
-        self.scc
-            .cmp_ofs()
-            .chunks(2)
-            .map(|v| match v[0].cmp(&v[1]) {
-                Ordering::Less => Some(true),
-                Ordering::Equal => None,
-                Ordering::Greater => Some(false),
-            })
-            .collect()
-    }
-
-    pub fn build(&mut self) {
-        self.scc.build();
-    }
-}
-impl Debug for TwoSat {
-    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        f.debug_list()
-            .entries(
-                self.scc
-                    .g()
-                    .iter()
-                    .enumerate()
-                    .flat_map(|(i, gi)| gi.iter().map(move |&j| (i, j)))
-                    .map(|(x, y)| DebugImplication { x, y }),
-            )
-            .finish()
-    }
-}
-struct DebugImplication {
-    x: usize,
-    y: usize,
-}
-impl Debug for DebugImplication {
-    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        write!(
-            f,
-            "{}{}→{}{}",
-            "¬".repeat(1 - self.x % 2),
-            self.x / 2,
-            "¬".repeat(1 - self.y % 2),
-            self.y / 2
-        )
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use super::TwoSat;
-    use rand::prelude::StdRng;
-    use rand::Rng;
-    use rand::SeedableRng;
-    use std::iter::repeat_with;
-
-    #[test]
-    fn test_rand() {
-        let mut rng = StdRng::seed_from_u64(42);
-        for _ in 0..60 {
-            let n = rng.gen_range(1..=20);
-            let m = rng.gen_range(1..=20);
-            let implications = repeat_with(|| {
-                (
-                    rng.gen_range(0..n),
-                    rng.gen_ratio(1, 2),
-                    rng.gen_range(0..n),
-                    rng.gen_ratio(1, 2),
-                )
-            })
-            .take(m)
-            .collect::<Vec<_>>();
-
-            let mut two_sat = TwoSat::new(n);
-            implications
-                .iter()
-                .for_each(|&(x, a, y, b)| two_sat.implies(x, a, y, b));
-            two_sat.build();
-            let result = two_sat.solve();
-
-            if let Some(result) = result {
-                assert!(feasible(&result, &implications));
-            } else {
-                assert!((0..1 << n).all(|bs| {
-                    !feasible(
-                        &(0..n).map(|i| bs >> i & 1 == 1).collect::<Vec<_>>(),
-                        &implications,
-                    )
-                }));
-            }
-        }
-    }
-
-    fn feasible(result: &[bool], implications: &[(usize, bool, usize, bool)]) -> bool {
-        implications
-            .iter()
-            .all(|&(x, a, y, b)| (result[x] != a) || (result[y] == b))
-    }
-}
-
\ No newline at end of file diff --git a/two_sat/all.html b/two_sat/all.html deleted file mode 100644 index e31b8159..00000000 --- a/two_sat/all.html +++ /dev/null @@ -1,35 +0,0 @@ -List of all items in this crate
- - - - - -

List of all items

Structs

\ No newline at end of file diff --git a/two_sat/index.html b/two_sat/index.html deleted file mode 100644 index 066047eb..00000000 --- a/two_sat/index.html +++ /dev/null @@ -1,55 +0,0 @@ -two_sat - Rust
- - - - - -

Crate two_sat

source ·
Expand description

2-SAT を解きます。

-

依存ライブラリ

-
    -
  • scc
  • -
-

Examples

-
let mut two_sat = TwoSat::new(3);
-
-two_sat.implies(0, true, 1, true);
-two_sat.implies(1, true, 2, true);
-two_sat.implies(2, true, 0, false);
-two_sat.implies(2, true, 1, false);
-two_sat.build();
-
-// Debug がきれいです。
-let expected = "[0→1, 0→¬2, ¬1→¬0, 1→2, 1→¬2, ¬2→¬1, 2→¬0, 2→¬1]";
-assert_eq!(format!("{:?}", &two_sat).as_str(), expected);
-
-// 解きます。
-assert_eq!(Some(vec![false, false, true]), two_sat.solve());
-

Structs

  • 2-SAT の本体です。
\ No newline at end of file diff --git a/two_sat/sidebar-items.js b/two_sat/sidebar-items.js deleted file mode 100644 index b3ef9fb4..00000000 --- a/two_sat/sidebar-items.js +++ /dev/null @@ -1 +0,0 @@ -window.SIDEBAR_ITEMS = {"struct":["TwoSat"]}; \ No newline at end of file diff --git a/two_sat/struct.TwoSat.html b/two_sat/struct.TwoSat.html deleted file mode 100644 index f11e799a..00000000 --- a/two_sat/struct.TwoSat.html +++ /dev/null @@ -1,54 +0,0 @@ -TwoSat in two_sat - Rust
- - - - - -

Struct two_sat::TwoSat

source ·
pub struct TwoSat { /* private fields */ }
Expand description

2-SAT の本体です。

-

Implementations§

source§

impl TwoSat

source

pub fn new(n: usize) -> Self

n 個の不定元を持つ Always true を作ります。

-
source

pub fn implies(&mut self, x: usize, a: bool, y: usize, b: bool)

(x == a) -> (y == b) をかつでつなぎます。

-
source

pub fn solve(&self) -> Option<Vec<bool>>

充足する割り当てがあれば返し、なければ None を返します。

-
source

pub fn build(&mut self)

Trait Implementations§

source§

impl Clone for TwoSat

source§

fn clone(&self) -> TwoSat

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TwoSat

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for TwoSat

source§

fn default() -> TwoSat

Returns the “default value” for a type. Read more
source§

impl Hash for TwoSat

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where - H: Hasher, - Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<TwoSat> for TwoSat

source§

fn eq(&self, other: &TwoSat) -> bool

This method tests for self and other values to be equal, and is used -by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always -sufficient, and should not be overridden without very good reason.
source§

impl Eq for TwoSat

source§

impl StructuralEq for TwoSat

source§

impl StructuralPartialEq for TwoSat

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere - T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere - T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere - T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

-
source§

impl<T, U> Into<U> for Twhere - U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

-

That is, this conversion is whatever the implementation of -From<T> for U chooses to do.

-
source§

impl<T> ToOwned for Twhere - T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere - U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere - U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
\ No newline at end of file