pub struct Column<T, V, R: GetBeginEnd<T>, S: RangeBounds<T>, F: GetBeginEndOption<T, R>, I: Iterator<Item = S>, C: IncDecCpCmp<T, V>> { /* private fields */ }Expand description
Represents a column in an instance of OverlapIter in which the Column itself is an Iterator.
Implementations§
Source§impl<T, V, R: GetBeginEnd<T>, S: RangeBounds<T>, F: GetBeginEndOption<T, R>, I: Iterator<Item = S>, C: IncDecCpCmp<T, V>> Column<T, V, R, S, F, I, C>
impl<T, V, R: GetBeginEnd<T>, S: RangeBounds<T>, F: GetBeginEndOption<T, R>, I: Iterator<Item = S>, C: IncDecCpCmp<T, V>> Column<T, V, R, S, F, I, C>
pub fn update_column<Q: GetBeginEnd<T>, X: GetBeginEndOption<T, Q>>(
&mut self,
last: &Q,
iter: &mut OverlapIter<T, V, C, Q, X>,
reset: bool,
) -> boolwhere
C: IncDecCpCmp<T, V>,
pub fn filter_column<Q: GetBeginEnd<T>>( &self, next: &Q, ) -> Result<Vec<Rc<ConsolidateMrsP<T, R, S>>>, &'static str>
pub fn in_err(&self) -> bool
pub fn get_column(&self) -> Result<usize, &'static str>
Sourcepub fn get_rows<'a>(&self) -> &'a Vec<Rc<ConsolidateMrsP<T, R, S>>>
pub fn get_rows<'a>(&self) -> &'a Vec<Rc<ConsolidateMrsP<T, R, S>>>
Examples found in repository?
examples/columns.rs (line 109)
3fn main() {
4 // We create all of our column data unsorted
5 let mut col_a = vec![0..=11, 2..=3, 7..=9, 22..=33, 34..=39];
6 let mut col_b = vec![6..=9, 6..=9, 6..=7, 11..=22, 7..=11, 9..=9];
7 let mut col_c = vec![3..=4, 3..=9, 4..=6, 30..=41];
8
9 // ** Full Sort Example here! **
10 // We will use this to drive the internals of the sort function
11 let t = NumberIncDecCpCmp::defaults();
12
13 // We create our sort function here
14 let sort_by = |a: &std::ops::RangeInclusive<i32>, b: &std::ops::RangeInclusive<i32>| {
15 sort_forward(a, b, &t.default_rebound(), &t)
16 };
17
18 // Sort all of our rows and force them to exist in the correct order!
19 col_a.sort_by(sort_by);
20 col_b.sort_by(sort_by);
21 col_c.sort_by(sort_by);
22 // ** End Full Sort Example **
23
24 // Create our Columns instance using number defaults.
25 let cols = Columns::num_defaults();
26
27 // give up if we fail to add a column!
28 assert!(cols.add_column(col_a.into_iter()).is_ok());
29 assert!(cols.add_column(col_b.into_iter()).is_ok());
30 assert!(cols.add_column(col_c.into_iter()).is_ok());
31
32 // Just pretty printing our text table border
33 println!(
34 "+---------+-----------+{:-<35}+{:-<61}+{:-<35}+",
35 "", "", ""
36 );
37
38 // Pretty preint our text table header
39 println!(
40 "| Overlap | State(id) |{:^35}|{:^61}|{:^35}|",
41 "Column(A)", "Column(B)", "Column(C)"
42 );
43
44 // In order to access the iter.get_column(column_id) method, the iter instance must remain in scope.
45 // If access to the causal ranges is not required, then a standard for lopp iterator will work.
46 let mut iter = cols.into_iter();
47 let mut id = 0;
48 loop {
49 let next = iter.next();
50 if next.is_none() {
51 // print out the last text bumper.
52 println!(
53 "+---------+-----------+{:-<35}+{:-<61}+{:-<35}+",
54 "", "", ""
55 );
56 return;
57 }
58 let (overlap, res, columns) = next.unwrap();
59 // print a bumper text row.
60 println!(
61 "+---------+-----------+{:-<35}+{:-<61}+{:-<35}+",
62 "", "", ""
63 );
64
65 // Print out the common intersecting range!
66 print!("| {:^2}->{:^2} |", overlap.get_begin(), overlap.get_end());
67 let mut stop = false;
68 if res.is_err() {
69 print!(" Err({}) |", id);
70 // We still want to access the column or columns that error out before we stop
71 stop = true;
72 } else {
73 print!(" Ok({}) |", id);
74 }
75 for (column_id, col) in columns.iter().enumerate() {
76 let mut txt = Vec::new();
77 match col {
78 Ok(src) => {
79 for row in src {
80 // This range contains all of the ranges that were used to create it!
81 let container = row.as_ref();
82 txt.push(format!(
83 "[{}->{}](",
84 container.get_begin(),
85 container.get_end()
86 ));
87 let mut r = Vec::new();
88
89 // walk our raw source ranges that caused this larger range
90 for (row_id, range) in container.src().iter() {
91 r.push(format!("{}({}->{})", row_id, range.start(), range.end()));
92 }
93 txt.push(r.join(","));
94 txt.push(String::from(")"));
95 }
96 }
97 Err(msg) => {
98 // This code exists but does not execute in this example.
99 // The Err code block, exists to demonstrate how to gain access to the ranges that
100 // caused a given error.
101
102 // Save our error for output
103 txt.push(String::from(*msg));
104
105 // get our raw column and the original rows that caused the error!
106 let col = iter.get_column(column_id).unwrap();
107
108 // This Vec contains the rows that caused the error!
109 let rows = col.get_rows();
110 for row in rows {
111 let result_range = row.as_ref();
112 // The range that was generated from the raw ranges
113 txt.push(format!(
114 "Invalid Range: ({}->{})",
115 result_range.get_begin(),
116 result_range.get_end()
117 ));
118 for (row_id, range) in result_range.src().iter() {
119 // One ore more of these ranges caused the error!
120 txt.push(format!("({}){}->{}", row_id, range.start(), range.end()))
121 }
122 }
123 }
124 }
125 match column_id {
126 0 => print!("{:^35}|", txt.join("")),
127 1 => print!("{:^61}|", txt.join("")),
128 2 => print!("{:^35}|", txt.join("")),
129 _ => (),
130 }
131 }
132
133 println!();
134 if stop {
135 // stop here if we ran into an error processing an iterator.
136 break;
137 }
138 id += 1;
139 }
140}Sourcepub fn to_inner(
self,
) -> (Result<usize, &'static str>, Vec<Rc<ConsolidateMrsP<T, R, S>>>, ConsolidateChecker<T, V, R, S, F, I, C>)
pub fn to_inner( self, ) -> (Result<usize, &'static str>, Vec<Rc<ConsolidateMrsP<T, R, S>>>, ConsolidateChecker<T, V, R, S, F, I, C>)
Unwraps the current object state into a tuple.
The resulting values from the returned tuple can be used to crate a new instance of Column with via the Column::builder.
pub fn new<Q: GetBeginEnd<T>, X: GetBeginEndOption<T, Q>>(
isec: &mut Intersector<T, V, C, Q, X>,
checker: ConsolidateChecker<T, V, R, S, F, I, C>,
) -> Result<Self, Self>where
C: IncDecCpCmp<T, V>,
Sourcepub fn builder(
inner: (Result<usize, &'static str>, ConsolidateChecker<T, V, R, S, F, I, C>, Vec<Rc<ConsolidateMrsP<T, R, S>>>),
) -> Self
pub fn builder( inner: (Result<usize, &'static str>, ConsolidateChecker<T, V, R, S, F, I, C>, Vec<Rc<ConsolidateMrsP<T, R, S>>>), ) -> Self
This method alllows construction of a new instance of Column bypassing the operations performed by new.
Auto Trait Implementations§
impl<T, V, R, S, F, I, C> !Freeze for Column<T, V, R, S, F, I, C>
impl<T, V, R, S, F, I, C> !RefUnwindSafe for Column<T, V, R, S, F, I, C>
impl<T, V, R, S, F, I, C> !Send for Column<T, V, R, S, F, I, C>
impl<T, V, R, S, F, I, C> !Sync for Column<T, V, R, S, F, I, C>
impl<T, V, R, S, F, I, C> Unpin for Column<T, V, R, S, F, I, C>
impl<T, V, R, S, F, I, C> UnsafeUnpin for Column<T, V, R, S, F, I, C>
impl<T, V, R, S, F, I, C> UnwindSafe for Column<T, V, R, S, F, I, C>where
I: UnwindSafe,
C: UnwindSafe,
F: UnwindSafe,
V: UnwindSafe,
R: UnwindSafe + RefUnwindSafe,
T: UnwindSafe + RefUnwindSafe,
S: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more