mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-03 23:33:40 -07:00
computer: convert vecs functions to iterators
This commit is contained in:
@@ -8,47 +8,28 @@ pub struct AddressGroups<T> {
|
||||
}
|
||||
|
||||
impl<T> AddressGroups<T> {
|
||||
pub fn as_boxed_mut_vecs(&mut self) -> Vec<Box<[&mut T]>> {
|
||||
vec![
|
||||
Box::new(self.ge_amount.as_mut_vec()),
|
||||
Box::new(self.amount_range.as_mut_vec()),
|
||||
Box::new(self.lt_amount.as_mut_vec()),
|
||||
]
|
||||
}
|
||||
|
||||
pub fn as_mut_vecs(&mut self) -> Vec<&mut T> {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
self.ge_amount
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.chain(self.amount_range.as_mut_vec())
|
||||
.chain(self.lt_amount.as_mut_vec())
|
||||
.collect::<Vec<_>>()
|
||||
.iter_mut()
|
||||
.chain(self.amount_range.iter_mut())
|
||||
.chain(self.lt_amount.iter_mut())
|
||||
}
|
||||
|
||||
pub fn as_mut_separate_vecs(&mut self) -> Vec<&mut T> {
|
||||
self.amount_range
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>()
|
||||
pub fn iter_separate_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
self.amount_range.iter_mut()
|
||||
}
|
||||
|
||||
pub fn as_mut_overlapping_vecs(&mut self) -> Vec<&mut T> {
|
||||
self.lt_amount
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.chain(self.ge_amount.as_mut_vec())
|
||||
.collect::<Vec<_>>()
|
||||
pub fn iter_overlapping_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
self.lt_amount.iter_mut().chain(self.ge_amount.iter_mut())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> AddressGroups<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> Vec<&T> {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
self.amount_range
|
||||
.vecs()
|
||||
.into_iter()
|
||||
.chain(self.lt_amount.vecs())
|
||||
.chain(self.ge_amount.vecs())
|
||||
.collect::<Vec<_>>()
|
||||
.iter_right()
|
||||
.chain(self.lt_amount.iter_right())
|
||||
.chain(self.ge_amount.iter_right())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
use std::{
|
||||
mem,
|
||||
ops::{Add, AddAssign},
|
||||
};
|
||||
use std::ops::{Add, AddAssign};
|
||||
|
||||
use super::GroupFilter;
|
||||
use crate::OutputType;
|
||||
@@ -51,7 +48,21 @@ impl<T> ByAddressType<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 8] {
|
||||
pub fn iter(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self.p2pk65,
|
||||
&self.p2pk33,
|
||||
&self.p2pkh,
|
||||
&self.p2sh,
|
||||
&self.p2wpkh,
|
||||
&self.p2wsh,
|
||||
&self.p2tr,
|
||||
&self.p2a,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[
|
||||
&mut self.p2pk65,
|
||||
&mut self.p2pk33,
|
||||
@@ -62,9 +73,10 @@ impl<T> ByAddressType<T> {
|
||||
&mut self.p2tr,
|
||||
&mut self.p2a,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn as_typed_vec(&self) -> [(OutputType, &T); 8] {
|
||||
pub fn iter_typed(&self) -> impl Iterator<Item = (OutputType, &T)> {
|
||||
[
|
||||
(OutputType::P2PK65, &self.p2pk65),
|
||||
(OutputType::P2PK33, &self.p2pk33),
|
||||
@@ -75,9 +87,24 @@ impl<T> ByAddressType<T> {
|
||||
(OutputType::P2TR, &self.p2tr),
|
||||
(OutputType::P2A, &self.p2a),
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn as_mut_typed_vec(&mut self) -> [(OutputType, &mut T); 8] {
|
||||
pub fn into_iter_typed(self) -> impl Iterator<Item = (OutputType, T)> {
|
||||
[
|
||||
(OutputType::P2PK65, self.p2pk65),
|
||||
(OutputType::P2PK33, self.p2pk33),
|
||||
(OutputType::P2PKH, self.p2pkh),
|
||||
(OutputType::P2SH, self.p2sh),
|
||||
(OutputType::P2WPKH, self.p2wpkh),
|
||||
(OutputType::P2WSH, self.p2wsh),
|
||||
(OutputType::P2TR, self.p2tr),
|
||||
(OutputType::P2A, self.p2a),
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn iter_typed_mut(&mut self) -> impl Iterator<Item = (OutputType, &mut T)> {
|
||||
[
|
||||
(OutputType::P2PK65, &mut self.p2pk65),
|
||||
(OutputType::P2PK33, &mut self.p2pk33),
|
||||
@@ -88,27 +115,12 @@ impl<T> ByAddressType<T> {
|
||||
(OutputType::P2TR, &mut self.p2tr),
|
||||
(OutputType::P2A, &mut self.p2a),
|
||||
]
|
||||
}
|
||||
|
||||
pub fn into_typed_vec(&mut self) -> [(OutputType, T); 8]
|
||||
where
|
||||
T: Default,
|
||||
{
|
||||
[
|
||||
(OutputType::P2PK65, mem::take(&mut self.p2pk65)),
|
||||
(OutputType::P2PK33, mem::take(&mut self.p2pk33)),
|
||||
(OutputType::P2PKH, mem::take(&mut self.p2pkh)),
|
||||
(OutputType::P2SH, mem::take(&mut self.p2sh)),
|
||||
(OutputType::P2WPKH, mem::take(&mut self.p2wpkh)),
|
||||
(OutputType::P2WSH, mem::take(&mut self.p2wsh)),
|
||||
(OutputType::P2TR, mem::take(&mut self.p2tr)),
|
||||
(OutputType::P2A, mem::take(&mut self.p2a)),
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ByAddressType<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 8] {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self.p2pk65.1,
|
||||
&self.p2pk33.1,
|
||||
@@ -119,6 +131,7 @@ impl<T> ByAddressType<(GroupFilter, T)> {
|
||||
&self.p2tr.1,
|
||||
&self.p2a.1,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +187,7 @@ where
|
||||
|
||||
impl<T> ByAddressType<Option<T>> {
|
||||
pub fn take(&mut self) {
|
||||
self.as_mut_vec().into_iter().for_each(|opt| {
|
||||
self.iter_mut().for_each(|opt| {
|
||||
opt.take();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ impl<T> From<ByAgeRange<T>> for ByAgeRange<(GroupFilter, T)> {
|
||||
}
|
||||
|
||||
impl<T> ByAgeRange<T> {
|
||||
pub fn as_vec(&mut self) -> [&T; 20] {
|
||||
pub fn iter(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self.up_to_1d,
|
||||
&self._1d_to_1w,
|
||||
@@ -75,9 +75,10 @@ impl<T> ByAgeRange<T> {
|
||||
&self._12y_to_15y,
|
||||
&self.from_15y,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 20] {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[
|
||||
&mut self.up_to_1d,
|
||||
&mut self._1d_to_1w,
|
||||
@@ -100,11 +101,12 @@ impl<T> ByAgeRange<T> {
|
||||
&mut self._12y_to_15y,
|
||||
&mut self.from_15y,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ByAgeRange<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 20] {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self.up_to_1d.1,
|
||||
&self._1d_to_1w.1,
|
||||
@@ -127,5 +129,6 @@ impl<T> ByAgeRange<(GroupFilter, T)> {
|
||||
&self._12y_to_15y.1,
|
||||
&self.from_15y.1,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ impl<T> ByAmountRange<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_vec(&self) -> [&T; 15] {
|
||||
pub fn iter(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self._0sats,
|
||||
&self._1sat_to_10sats,
|
||||
@@ -142,9 +142,10 @@ impl<T> ByAmountRange<T> {
|
||||
&self._10k_btc_to_100k_btc,
|
||||
&self._100k_btc_or_more,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn as_typed_vec(&self) -> [(Sats, &T); 15] {
|
||||
pub fn iter_typed(&self) -> impl Iterator<Item = (Sats, &T)> {
|
||||
[
|
||||
(Sats::ZERO, &self._0sats),
|
||||
(Sats::_1, &self._1sat_to_10sats),
|
||||
@@ -162,9 +163,10 @@ impl<T> ByAmountRange<T> {
|
||||
(Sats::_10K_BTC, &self._10k_btc_to_100k_btc),
|
||||
(Sats::_100K_BTC, &self._100k_btc_or_more),
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 15] {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[
|
||||
&mut self._0sats,
|
||||
&mut self._1sat_to_10sats,
|
||||
@@ -182,11 +184,12 @@ impl<T> ByAmountRange<T> {
|
||||
&mut self._10k_btc_to_100k_btc,
|
||||
&mut self._100k_btc_or_more,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ByAmountRange<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 15] {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self._0sats.1,
|
||||
&self._1sat_to_10sats.1,
|
||||
@@ -204,6 +207,7 @@ impl<T> ByAmountRange<(GroupFilter, T)> {
|
||||
&self._10k_btc_to_100k_btc.1,
|
||||
&self._100k_btc_or_more.1,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ impl<T> From<ByEpoch<T>> for ByEpoch<(GroupFilter, T)> {
|
||||
}
|
||||
|
||||
impl<T> ByEpoch<T> {
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 5] {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[
|
||||
&mut self._0,
|
||||
&mut self._1,
|
||||
@@ -32,6 +32,7 @@ impl<T> ByEpoch<T> {
|
||||
&mut self._3,
|
||||
&mut self._4,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn mut_vec_from_height(&mut self, height: Height) -> &mut T {
|
||||
@@ -53,7 +54,7 @@ impl<T> ByEpoch<T> {
|
||||
}
|
||||
|
||||
impl<T> ByEpoch<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 5] {
|
||||
[&self._0.1, &self._1.1, &self._2.1, &self._3.1, &self._4.1]
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[&self._0.1, &self._1.1, &self._2.1, &self._3.1, &self._4.1].into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct ByGreatEqualAmount<T> {
|
||||
}
|
||||
|
||||
impl<T> ByGreatEqualAmount<T> {
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 13] {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[
|
||||
&mut self._1sat,
|
||||
&mut self._10sats,
|
||||
@@ -36,11 +36,12 @@ impl<T> ByGreatEqualAmount<T> {
|
||||
&mut self._1k_btc,
|
||||
&mut self._10k_btc,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ByGreatEqualAmount<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 13] {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self._1sat.1,
|
||||
&self._10sats.1,
|
||||
@@ -56,6 +57,7 @@ impl<T> ByGreatEqualAmount<(GroupFilter, T)> {
|
||||
&self._1k_btc.1,
|
||||
&self._10k_btc.1,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct ByLowerThanAmount<T> {
|
||||
}
|
||||
|
||||
impl<T> ByLowerThanAmount<T> {
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 13] {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[
|
||||
&mut self._10sats,
|
||||
&mut self._100sats,
|
||||
@@ -36,11 +36,12 @@ impl<T> ByLowerThanAmount<T> {
|
||||
&mut self._10k_btc,
|
||||
&mut self._100k_btc,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ByLowerThanAmount<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 13] {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self._10sats.1,
|
||||
&self._100sats.1,
|
||||
@@ -56,6 +57,7 @@ impl<T> ByLowerThanAmount<(GroupFilter, T)> {
|
||||
&self._10k_btc.1,
|
||||
&self._100k_btc.1,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct ByMaxAge<T> {
|
||||
}
|
||||
|
||||
impl<T> ByMaxAge<T> {
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 18] {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[
|
||||
&mut self._1w,
|
||||
&mut self._1m,
|
||||
@@ -44,11 +44,12 @@ impl<T> ByMaxAge<T> {
|
||||
&mut self._12y,
|
||||
&mut self._15y,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ByMaxAge<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 18] {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self._1w.1,
|
||||
&self._1m.1,
|
||||
@@ -69,6 +70,7 @@ impl<T> ByMaxAge<(GroupFilter, T)> {
|
||||
&self._12y.1,
|
||||
&self._15y.1,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct ByMinAge<T> {
|
||||
}
|
||||
|
||||
impl<T> ByMinAge<T> {
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 18] {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[
|
||||
&mut self._1d,
|
||||
&mut self._1w,
|
||||
@@ -44,11 +44,12 @@ impl<T> ByMinAge<T> {
|
||||
&mut self._10y,
|
||||
&mut self._12y,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ByMinAge<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 18] {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self._1d.1,
|
||||
&self._1w.1,
|
||||
@@ -69,6 +70,7 @@ impl<T> ByMinAge<(GroupFilter, T)> {
|
||||
&self._10y.1,
|
||||
&self._12y.1,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ impl<T> BySpendableType<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 11] {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[
|
||||
&mut self.p2pk65,
|
||||
&mut self.p2pk33,
|
||||
@@ -51,9 +51,10 @@ impl<T> BySpendableType<T> {
|
||||
&mut self.unknown,
|
||||
&mut self.empty,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
||||
pub fn as_typed_vec(&self) -> [(OutputType, &T); 11] {
|
||||
pub fn iter_typed(&self) -> impl Iterator<Item = (OutputType, &T)> {
|
||||
[
|
||||
(OutputType::P2PK65, &self.p2pk65),
|
||||
(OutputType::P2PK33, &self.p2pk33),
|
||||
@@ -67,11 +68,12 @@ impl<T> BySpendableType<T> {
|
||||
(OutputType::Unknown, &self.unknown),
|
||||
(OutputType::Empty, &self.empty),
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> BySpendableType<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 11] {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[
|
||||
&self.p2pk65.1,
|
||||
&self.p2pk33.1,
|
||||
@@ -85,6 +87,7 @@ impl<T> BySpendableType<(GroupFilter, T)> {
|
||||
&self.unknown.1,
|
||||
&self.empty.1,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ pub struct ByTerm<T> {
|
||||
}
|
||||
|
||||
impl<T> ByTerm<T> {
|
||||
pub fn as_mut_vec(&mut self) -> [&mut T; 2] {
|
||||
[&mut self.short, &mut self.long]
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[&mut self.short, &mut self.long].into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ByTerm<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> [&T; 2] {
|
||||
[&self.short.1, &self.long.1]
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[&self.short.1, &self.long.1].into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,72 +18,52 @@ pub struct UTXOGroups<T> {
|
||||
}
|
||||
|
||||
impl<T> UTXOGroups<T> {
|
||||
pub fn as_boxed_mut_vecs(&mut self) -> Vec<Box<[&mut T]>> {
|
||||
vec![
|
||||
Box::new([&mut self.all]),
|
||||
Box::new(self.term.as_mut_vec()),
|
||||
Box::new(self.max_age.as_mut_vec()),
|
||||
Box::new(self.min_age.as_mut_vec()),
|
||||
Box::new(self.ge_amount.as_mut_vec()),
|
||||
Box::new(self.age_range.as_mut_vec()),
|
||||
Box::new(self.epoch.as_mut_vec()),
|
||||
Box::new(self.amount_range.as_mut_vec()),
|
||||
Box::new(self.lt_amount.as_mut_vec()),
|
||||
Box::new(self._type.as_mut_vec()),
|
||||
]
|
||||
}
|
||||
|
||||
pub fn as_mut_vecs(&mut self) -> Vec<&mut T> {
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[&mut self.all]
|
||||
.into_iter()
|
||||
.chain(self.term.as_mut_vec())
|
||||
.chain(self.max_age.as_mut_vec())
|
||||
.chain(self.min_age.as_mut_vec())
|
||||
.chain(self.ge_amount.as_mut_vec())
|
||||
.chain(self.age_range.as_mut_vec())
|
||||
.chain(self.epoch.as_mut_vec())
|
||||
.chain(self.amount_range.as_mut_vec())
|
||||
.chain(self.lt_amount.as_mut_vec())
|
||||
.chain(self._type.as_mut_vec())
|
||||
.collect::<Vec<_>>()
|
||||
.chain(self.term.iter_mut())
|
||||
.chain(self.max_age.iter_mut())
|
||||
.chain(self.min_age.iter_mut())
|
||||
.chain(self.ge_amount.iter_mut())
|
||||
.chain(self.age_range.iter_mut())
|
||||
.chain(self.epoch.iter_mut())
|
||||
.chain(self.amount_range.iter_mut())
|
||||
.chain(self.lt_amount.iter_mut())
|
||||
.chain(self._type.iter_mut())
|
||||
}
|
||||
|
||||
pub fn as_mut_separate_vecs(&mut self) -> Vec<&mut T> {
|
||||
pub fn iter_separate_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
self.age_range
|
||||
.as_mut_vec()
|
||||
.into_iter()
|
||||
.chain(self.epoch.as_mut_vec())
|
||||
.chain(self.amount_range.as_mut_vec())
|
||||
.chain(self._type.as_mut_vec())
|
||||
.collect::<Vec<_>>()
|
||||
.iter_mut()
|
||||
.chain(self.epoch.iter_mut())
|
||||
.chain(self.amount_range.iter_mut())
|
||||
.chain(self._type.iter_mut())
|
||||
}
|
||||
|
||||
pub fn as_mut_overlapping_vecs(&mut self) -> Vec<&mut T> {
|
||||
pub fn iter_overlapping_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
[&mut self.all]
|
||||
.into_iter()
|
||||
.chain(self.term.as_mut_vec())
|
||||
.chain(self.max_age.as_mut_vec())
|
||||
.chain(self.min_age.as_mut_vec())
|
||||
.chain(self.lt_amount.as_mut_vec())
|
||||
.chain(self.ge_amount.as_mut_vec())
|
||||
.collect::<Vec<_>>()
|
||||
.chain(self.term.iter_mut())
|
||||
.chain(self.max_age.iter_mut())
|
||||
.chain(self.min_age.iter_mut())
|
||||
.chain(self.lt_amount.iter_mut())
|
||||
.chain(self.ge_amount.iter_mut())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> UTXOGroups<(GroupFilter, T)> {
|
||||
pub fn vecs(&self) -> Vec<&T> {
|
||||
pub fn iter_right(&self) -> impl Iterator<Item = &T> {
|
||||
[&self.all.1]
|
||||
.into_iter()
|
||||
.chain(self.term.vecs())
|
||||
.chain(self.max_age.vecs())
|
||||
.chain(self.min_age.vecs())
|
||||
.chain(self.age_range.vecs())
|
||||
.chain(self.epoch.vecs())
|
||||
.chain(self.amount_range.vecs())
|
||||
.chain(self._type.vecs())
|
||||
.chain(self.lt_amount.vecs())
|
||||
.chain(self.ge_amount.vecs())
|
||||
.collect::<Vec<_>>()
|
||||
.chain(self.term.iter_right())
|
||||
.chain(self.max_age.iter_right())
|
||||
.chain(self.min_age.iter_right())
|
||||
.chain(self.age_range.iter_right())
|
||||
.chain(self.epoch.iter_right())
|
||||
.chain(self.amount_range.iter_right())
|
||||
.chain(self._type.iter_right())
|
||||
.chain(self.lt_amount.iter_right())
|
||||
.chain(self.ge_amount.iter_right())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user