Expand description
🤸♀️ More iterator adaptors.
This crate provides some useful iterator adaptors and functions. Unlike
itertools
this crate provides a separate
extension trait for each adaptor. Additionally, each type of adaptor is
feature flagged so you only have to compile the features you need.
Getting started
Add the crate to Cargo manifest.
cargo add itermore --features full
And bring the extension traits into scope.
use itermore::prelude::*;
Now you can use extension methods like array_windows
on any iterator.
for [a, b, c] in iter.array_windows() {
println!("{} {} {}", a, b, c)
}
// Outputs
// 1 2 3
// 2 3 4
// 3 4 5
It is recommended to only enable the features that you need. For example if
you only want the array_combinations
adaptor you would add the following
to your Cargo manifest.
[dependencies]
itermore = { version = "*", features = ["array_combinations"]}
Provided functionality
Methods
collect_array
: Collects an iterator into an array.min_max
and friends: Returns the minimum and maximum element of an iterator.next_chunk
: Returns the nextN
elements of the iterator as an array.sorted
and friends: Returns a new iterator with all elements sorted.
Adaptors
array_chunks
returns an iterator overN
elements of the iterator at a time.array_windows
returns an iterator over all contiguous windows of lengthN
.array_combinations
returns an iterator overK
length combinations of all the elements in the underlying iterator.array_combinations_with_reps
returns an iterator overK
length combinations with repetitions/replacements of all the elements in the underlying iterator.cartesian_product
returns an iterator over the cartesian product of the element sets of two iterators.circular_array_windows
returns an iterator over all contiguous windows of lengthN
that wraps around at the end.combinations
returns an iterator overk
length combinations of all the elements in the underlying iterator.combinations_with_reps
returns an iterator overk
length combinations with repetitions/replacements of all the elements in the underlying iterator.
Modules
- Re-exports all iterator extension traits.
Macros
- cartesian_product
cartesian_product
Returns an iterator over the cartesian product of the element sets of multiple iterators (up to 12).
Structs
- ArrayChunks
array_chunks
An iterator overN
elements of the iterator at a time. - ArrayCombinations
array_combinations
An iterator that iterates overK
length combinations of all the elements in the underlying iterator. - ArrayCombinationsWithReps
array_combinations_with_reps
An iterator that iterates overK
length combinations with repetitions/replacements of all the elements in the underlying iterator. - ArrayWindows
array_windows
An iterator over all contiguous windows of lengthN
. - CartesianProduct
cartesian_product
An iterator over the cartesian product of the element sets of two iteratorsI
andJ
. - CircularArrayWindows
circular_array_windows
An iterator over all contiguous windows of lengthN
wrapping back to the first elements when the window would otherwise exceed the length of the iterator. - Combinations
combinations
An iterator that iterates overk
length combinations of all the elements in the underlying iterator. - CombinationsWithReps
combinations_with_reps
An iterator that iterates overK
length combinations with repetitions/replacements of all the elements in the underlying iterator.
Traits
- IterArrayChunks
array_chunks
An extension trait that provides thearray_chunks
method for iterators. - IterArrayCombinations
array_combinations
An extension trait that provides thearray_combinations
method for iterators. - IterArrayCombinationsWithReps
array_combinations_with_reps
An extension trait that provides thearray_combinations_with_reps
method for iterators. - IterArrayWindows
array_windows
An extension trait that provides thearray_windows
method for iterators. - IterCartesianProduct
cartesian_product
An extension trait that provides thecartesian_product
method for iterators. - IterCircularArrayWindows
circular_array_windows
- IterCollectArray
collect_array
An extension trait that provides thecollect_array
method for iterators. - IterCombinations
combinations
An extension trait that provides thecombinations
method for iterators. - IterCombinationsWithReps
combinations_with_reps
An extension trait that provides thecombinations_with_reps
method for iterators. - IterMinMax
min_max
An extension trait that provides themin_max
method and friends for iterators. - IterNextChunk
next_chunk
An extension trait that provides thenext_chunk
method for iterators. - IterSorted
sorted
An extension trait that provides thesorted
method and friends for iterators.