@@ -2,6 +2,7 @@ use crate::bindings as ll_bindings;
2
2
use crate :: metadata;
3
3
use crate :: { tsk_id_t, tsk_size_t, TskitError } ;
4
4
5
+ /// Row of an [`EdgeTable`]
5
6
pub struct EdgeTableRow {
6
7
pub left : f64 ,
7
8
pub right : f64 ,
@@ -10,6 +11,16 @@ pub struct EdgeTableRow {
10
11
pub metadata : Option < Vec < u8 > > ,
11
12
}
12
13
14
+ impl PartialEq for EdgeTableRow {
15
+ fn eq ( & self , other : & Self ) -> bool {
16
+ self . parent == other. parent
17
+ && self . child == other. child
18
+ && crate :: util:: f64_partial_cmp_equal ( & self . left , & other. left )
19
+ && crate :: util:: f64_partial_cmp_equal ( & self . right , & other. right )
20
+ && crate :: util:: metadata_like_are_equal ( & self . metadata , & other. metadata )
21
+ }
22
+ }
23
+
13
24
fn make_edge_table_row (
14
25
table : & EdgeTable ,
15
26
pos : tsk_id_t ,
@@ -138,4 +149,21 @@ impl<'a> EdgeTable<'a> {
138
149
pub fn iter ( & self , decode_metadata : bool ) -> EdgeTableRefIterator {
139
150
crate :: table_iterator:: make_table_iterator :: < & EdgeTable < ' a > > ( & self , decode_metadata)
140
151
}
152
+
153
+ /// Return row `r` of the table.
154
+ ///
155
+ /// # Parameters
156
+ ///
157
+ /// * `r`: the row id.
158
+ /// * `decode_metadata`: if `true`, then a *copy* of row metadata
159
+ /// will be provided in [`EdgeTableRow::metadata`].
160
+ /// The meta data are *not* decoded.
161
+ /// Rows with no metadata will contain the value `None`.
162
+ ///
163
+ /// # Errors
164
+ ///
165
+ /// [`TskitError::IndexError`] if `r` is out of range.
166
+ pub fn row ( & self , r : tsk_id_t , decode_metadata : bool ) -> Result < EdgeTableRow , TskitError > {
167
+ table_row_access ! ( r, decode_metadata, self , make_edge_table_row)
168
+ }
141
169
}
0 commit comments