File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ impl NodeTable {
189
189
/// flag.remove(tskit::NodeFlags::IS_SAMPLE);
190
190
/// }
191
191
/// assert!(!tables.nodes_mut().flags_array_mut().iter().any(|f| f.is_sample()));
192
+ /// assert!(tables.nodes().samples_as_vector().is_empty());
192
193
/// ```
193
194
///
194
195
/// ```
@@ -404,21 +405,12 @@ impl NodeTable {
404
405
/// of all nodes for which [`crate::TSK_NODE_IS_SAMPLE`]
405
406
/// is `true`.
406
407
pub fn samples_as_vector ( & self ) -> Vec < NodeId > {
407
- let mut samples: Vec < NodeId > = vec ! [ ] ;
408
- for row in self . iter ( ) {
409
- if row. flags . contains ( NodeFlags :: IS_SAMPLE ) {
410
- samples. push ( row. id ) ;
411
- }
412
- }
413
- samples
408
+ self . create_node_id_vector ( |row| row. flags . contains ( NodeFlags :: IS_SAMPLE ) )
414
409
}
415
410
416
411
/// Obtain a vector containing the indexes ("ids") of all nodes
417
412
/// satisfying a certain criterion.
418
- pub fn create_node_id_vector (
419
- & self ,
420
- mut f : impl FnMut ( & crate :: NodeTableRow ) -> bool ,
421
- ) -> Vec < NodeId > {
413
+ pub fn create_node_id_vector ( & self , mut f : impl FnMut ( & NodeTableRow ) -> bool ) -> Vec < NodeId > {
422
414
self . iter ( )
423
415
. filter ( |row| f ( row) )
424
416
. map ( |row| row. id )
You can’t perform that action at this time.
0 commit comments