Struct tskit::OwningMigrationTable
source · pub struct OwningMigrationTable { /* private fields */ }
Expand description
A standalone migration table that owns its data.
Examples
use tskit::OwningMigrationTable;
let mut migrations = OwningMigrationTable::default();
let rowid = migrations.add_row((0., 1.), 1, (0, 1), 10.3).unwrap();
assert_eq!(rowid, 0);
assert_eq!(migrations.num_rows(), 1);
An example with metadata.
This requires the cargo feature "derive"
for tskit
.
use tskit::OwningMigrationTable;
#[derive(serde::Serialize,
serde::Deserialize,
tskit::metadata::MigrationMetadata)]
#[serializer("serde_json")]
struct MigrationMetadata {
value: i32,
}
let metadata = MigrationMetadata{value: 42};
let mut migrations = OwningMigrationTable::default();
let rowid = migrations.add_row_with_metadata((0., 1.), 1, (0, 1), 10.3, &metadata).unwrap();
assert_eq!(rowid, 0);
match migrations.metadata::<MigrationMetadata>(rowid) {
// rowid is in range, decoding succeeded
Some(Ok(decoded)) => assert_eq!(decoded.value, 42),
// rowid is in range, decoding failed
Some(Err(e)) => panic!("error decoding metadata: {:?}", e),
None => panic!("row id out of range")
}
Implementations§
source§impl OwningMigrationTable
impl OwningMigrationTable
sourcepub fn clear(&mut self) -> TskReturnValue
pub fn clear(&mut self) -> TskReturnValue
Clear the table.
source§impl OwningMigrationTable
impl OwningMigrationTable
sourcepub fn as_ptr(&self) -> *const tsk_migration_table_t
pub fn as_ptr(&self) -> *const tsk_migration_table_t
Examples found in repository?
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131
pub fn set_migrations(&mut self, migrations: &crate::OwningMigrationTable) -> TskReturnValue {
// SAFETY: neither self nor edges are possible
// to create with null pointers.
let rv = unsafe {
ll_bindings::tsk_migration_table_set_columns(
&mut self.inner.migrations,
(*migrations.as_ptr()).num_rows,
(*migrations.as_ptr()).left,
(*migrations.as_ptr()).right,
(*migrations.as_ptr()).node,
(*migrations.as_ptr()).source,
(*migrations.as_ptr()).dest,
(*migrations.as_ptr()).time,
(*migrations.as_ptr()).metadata,
(*migrations.as_ptr()).metadata_offset,
)
};
handle_tsk_return_value!(rv)
}
pub fn as_mut_ptr(&mut self) -> *mut tsk_migration_table_t
source§impl OwningMigrationTable
impl OwningMigrationTable
pub fn add_row<LEFT, RIGHT, N, SOURCE, DEST, T>(
&mut self,
span: (LEFT, RIGHT),
node: N,
source_dest: (SOURCE, DEST),
time: T
) -> Result<MigrationId, TskitError>where
LEFT: Into<Position>,
RIGHT: Into<Position>,
N: Into<NodeId>,
SOURCE: Into<PopulationId>,
DEST: Into<PopulationId>,
T: Into<Time>,
pub fn add_row_with_metadata<LEFT, RIGHT, N, SOURCE, DEST, T, M>(
&mut self,
span: (LEFT, RIGHT),
node: N,
source_dest: (SOURCE, DEST),
time: T,
metadata: &M
) -> Result<MigrationId, TskitError>where
LEFT: Into<Position>,
RIGHT: Into<Position>,
N: Into<NodeId>,
SOURCE: Into<PopulationId>,
DEST: Into<PopulationId>,
T: Into<Time>,
M: MigrationMetadata,
Methods from Deref<Target = MigrationTable>§
sourcepub fn num_rows(&self) -> SizeType
pub fn num_rows(&self) -> SizeType
Return the number of rows
Examples found in repository?
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
pub fn left<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(row.into(), self.as_ref().left, self.num_rows())
}
/// Return the right coordinate for a given row.
///
/// # Returns
///
/// * `Some(positions)` if `row` is valid.
/// * `None` otherwise.
pub fn right<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(
row.into(),
self.as_ref().right,
self.num_rows(),
)
}
/// Return the node for a given row.
///
/// # Returns
///
/// * `Some(node)` if `row` is valid.
/// * `None` otherwise.
pub fn node<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<NodeId> {
sys::tsk_column_access::<NodeId, _, _, _>(row.into(), self.as_ref().node, self.num_rows())
}
/// Return the source population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn source<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().source,
self.num_rows(),
)
}
/// Return the destination population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn dest<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().dest,
self.num_rows(),
)
}
/// Return the time of the migration event for a given row.
///
/// # Returns
///
/// * `Some(time)` if `row` is valid.
/// * `None` otherwise.
pub fn time<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Time> {
sys::tsk_column_access::<Time, _, _, _>(row.into(), self.as_ref().time, self.num_rows())
}
sourcepub fn left<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position>
pub fn left<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position>
Examples found in repository?
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option<MigrationTableRow> {
Some(MigrationTableRow {
id: pos.into(),
left: table.left(pos)?,
right: table.right(pos)?,
node: table.node(pos)?,
source: table.source(pos)?,
dest: table.dest(pos)?,
time: table.time(pos)?,
metadata: table.raw_metadata(pos).map(|m| m.to_vec()),
})
}
pub(crate) type MigrationTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a MigrationTable>;
pub(crate) type MigrationTableIterator = crate::table_iterator::TableIterator<MigrationTable>;
impl<'a> Iterator for MigrationTableRefIterator<'a> {
type Item = MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(self.table, self.pos);
self.pos += 1;
rv
}
}
impl Iterator for MigrationTableIterator {
type Item = crate::migration_table::MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(&self.table, self.pos);
self.pos += 1;
rv
}
}
#[derive(Debug)]
pub struct MigrationTableRowView<'a> {
table: &'a MigrationTable,
pub id: MigrationId,
pub left: Position,
pub right: Position,
pub node: NodeId,
pub source: PopulationId,
pub dest: PopulationId,
pub time: Time,
pub metadata: Option<&'a [u8]>,
}
impl<'a> MigrationTableRowView<'a> {
fn new(table: &'a MigrationTable) -> Self {
Self {
table,
id: MigrationId::NULL,
left: Position::from(f64::NAN),
right: Position::from(f64::NAN),
node: NodeId::NULL,
source: PopulationId::NULL,
dest: PopulationId::NULL,
time: Time::from(f64::NAN),
metadata: None,
}
}
}
impl<'a> PartialEq for MigrationTableRowView<'a> {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& self.metadata == other.metadata
}
}
impl<'a> Eq for MigrationTableRowView<'a> {}
impl<'a> PartialEq<MigrationTableRow> for MigrationTableRowView<'a> {
fn eq(&self, other: &MigrationTableRow) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl PartialEq<MigrationTableRowView<'_>> for MigrationTableRow {
fn eq(&self, other: &MigrationTableRowView) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl<'a> streaming_iterator::StreamingIterator for MigrationTableRowView<'a> {
type Item = Self;
row_lending_iterator_get!();
fn advance(&mut self) {
self.id = (i32::from(self.id) + 1).into();
self.left = self.table.left(self.id).unwrap_or_else(|| f64::NAN.into());
self.right = self.table.right(self.id).unwrap_or_else(|| f64::NAN.into());
self.node = self.table.node(self.id).unwrap_or(NodeId::NULL);
self.source = self.table.source(self.id).unwrap_or(PopulationId::NULL);
self.dest = self.table.dest(self.id).unwrap_or(PopulationId::NULL);
self.time = self.table.time(self.id).unwrap_or_else(|| f64::NAN.into());
self.metadata = self.table.raw_metadata(self.id);
}
}
/// An immutable view of a migration table.
///
/// These are not created directly but are accessed
/// by types implementing [`std::ops::Deref`] to
/// [`crate::table_views::TableViews`]
#[derive(Debug)]
#[repr(transparent)]
pub struct MigrationTable {
table_: sys::LLMigrationTableRef,
}
impl MigrationTable {
pub(crate) fn new_from_table(
migrations: *mut ll_bindings::tsk_migration_table_t,
) -> Result<Self, TskitError> {
let table_ = sys::LLMigrationTableRef::new_from_table(migrations)?;
Ok(MigrationTable { table_ })
}
pub(crate) fn as_ref(&self) -> &ll_bindings::tsk_migration_table_t {
self.table_.as_ref()
}
/// Return the number of rows
pub fn num_rows(&self) -> SizeType {
self.as_ref().num_rows.into()
}
raw_metadata_getter_for_tables!(MigrationId);
/// Return the left coordinate for a given row.
///
/// # Returns
///
/// * `Some(position)` if `row` is valid.
/// * `None` otherwise.
pub fn left<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(row.into(), self.as_ref().left, self.num_rows())
}
/// Return the right coordinate for a given row.
///
/// # Returns
///
/// * `Some(positions)` if `row` is valid.
/// * `None` otherwise.
pub fn right<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(
row.into(),
self.as_ref().right,
self.num_rows(),
)
}
/// Return the node for a given row.
///
/// # Returns
///
/// * `Some(node)` if `row` is valid.
/// * `None` otherwise.
pub fn node<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<NodeId> {
sys::tsk_column_access::<NodeId, _, _, _>(row.into(), self.as_ref().node, self.num_rows())
}
/// Return the source population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn source<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().source,
self.num_rows(),
)
}
/// Return the destination population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn dest<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().dest,
self.num_rows(),
)
}
/// Return the time of the migration event for a given row.
///
/// # Returns
///
/// * `Some(time)` if `row` is valid.
/// * `None` otherwise.
pub fn time<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Time> {
sys::tsk_column_access::<Time, _, _, _>(row.into(), self.as_ref().time, self.num_rows())
}
/// Retrieve decoded metadata for a `row`.
///
/// # Returns
///
/// * `Some(Ok(T))` if `row` is valid and decoding succeeded.
/// * `Some(Err(_))` if `row` is not valid and decoding failed.
/// * `None` if `row` is not valid.
///
/// # Errors
///
/// * [`TskitError::MetadataError`] if decoding fails.
///
/// # Examples.
///
/// The big-picture semantics are the same for all table types.
/// See [`crate::IndividualTable::metadata`] for examples.
pub fn metadata<T: metadata::MigrationMetadata>(
&self,
row: MigrationId,
) -> Option<Result<T, TskitError>> {
let buffer = self.raw_metadata(row)?;
Some(decode_metadata_row!(T, buffer).map_err(|e| e.into()))
}
/// Return an iterator over rows of the table.
/// The value of the iterator is [`MigrationTableRow`].
pub fn iter(&self) -> impl Iterator<Item = MigrationTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&MigrationTable>(self)
}
pub fn lending_iter(&self) -> MigrationTableRowView {
MigrationTableRowView::new(self)
}
/// Return row `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row)` if `r` is valid
/// * `None` otherwise
pub fn row<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRow> {
let ri = r.into().into();
table_row_access!(ri, self, make_migration_table_row)
}
/// Return a view of `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRowView> {
let view = MigrationTableRowView {
table: self,
id: r.into(),
left: self.left(r)?,
right: self.right(r)?,
node: self.node(r)?,
source: self.source(r)?,
dest: self.dest(r)?,
time: self.time(r)?,
metadata: self.raw_metadata(r.into()),
};
Some(view)
}
sourcepub fn right<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position>
pub fn right<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position>
Return the right coordinate for a given row.
Returns
Some(positions)
ifrow
is valid.None
otherwise.
Examples found in repository?
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option<MigrationTableRow> {
Some(MigrationTableRow {
id: pos.into(),
left: table.left(pos)?,
right: table.right(pos)?,
node: table.node(pos)?,
source: table.source(pos)?,
dest: table.dest(pos)?,
time: table.time(pos)?,
metadata: table.raw_metadata(pos).map(|m| m.to_vec()),
})
}
pub(crate) type MigrationTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a MigrationTable>;
pub(crate) type MigrationTableIterator = crate::table_iterator::TableIterator<MigrationTable>;
impl<'a> Iterator for MigrationTableRefIterator<'a> {
type Item = MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(self.table, self.pos);
self.pos += 1;
rv
}
}
impl Iterator for MigrationTableIterator {
type Item = crate::migration_table::MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(&self.table, self.pos);
self.pos += 1;
rv
}
}
#[derive(Debug)]
pub struct MigrationTableRowView<'a> {
table: &'a MigrationTable,
pub id: MigrationId,
pub left: Position,
pub right: Position,
pub node: NodeId,
pub source: PopulationId,
pub dest: PopulationId,
pub time: Time,
pub metadata: Option<&'a [u8]>,
}
impl<'a> MigrationTableRowView<'a> {
fn new(table: &'a MigrationTable) -> Self {
Self {
table,
id: MigrationId::NULL,
left: Position::from(f64::NAN),
right: Position::from(f64::NAN),
node: NodeId::NULL,
source: PopulationId::NULL,
dest: PopulationId::NULL,
time: Time::from(f64::NAN),
metadata: None,
}
}
}
impl<'a> PartialEq for MigrationTableRowView<'a> {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& self.metadata == other.metadata
}
}
impl<'a> Eq for MigrationTableRowView<'a> {}
impl<'a> PartialEq<MigrationTableRow> for MigrationTableRowView<'a> {
fn eq(&self, other: &MigrationTableRow) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl PartialEq<MigrationTableRowView<'_>> for MigrationTableRow {
fn eq(&self, other: &MigrationTableRowView) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl<'a> streaming_iterator::StreamingIterator for MigrationTableRowView<'a> {
type Item = Self;
row_lending_iterator_get!();
fn advance(&mut self) {
self.id = (i32::from(self.id) + 1).into();
self.left = self.table.left(self.id).unwrap_or_else(|| f64::NAN.into());
self.right = self.table.right(self.id).unwrap_or_else(|| f64::NAN.into());
self.node = self.table.node(self.id).unwrap_or(NodeId::NULL);
self.source = self.table.source(self.id).unwrap_or(PopulationId::NULL);
self.dest = self.table.dest(self.id).unwrap_or(PopulationId::NULL);
self.time = self.table.time(self.id).unwrap_or_else(|| f64::NAN.into());
self.metadata = self.table.raw_metadata(self.id);
}
}
/// An immutable view of a migration table.
///
/// These are not created directly but are accessed
/// by types implementing [`std::ops::Deref`] to
/// [`crate::table_views::TableViews`]
#[derive(Debug)]
#[repr(transparent)]
pub struct MigrationTable {
table_: sys::LLMigrationTableRef,
}
impl MigrationTable {
pub(crate) fn new_from_table(
migrations: *mut ll_bindings::tsk_migration_table_t,
) -> Result<Self, TskitError> {
let table_ = sys::LLMigrationTableRef::new_from_table(migrations)?;
Ok(MigrationTable { table_ })
}
pub(crate) fn as_ref(&self) -> &ll_bindings::tsk_migration_table_t {
self.table_.as_ref()
}
/// Return the number of rows
pub fn num_rows(&self) -> SizeType {
self.as_ref().num_rows.into()
}
raw_metadata_getter_for_tables!(MigrationId);
/// Return the left coordinate for a given row.
///
/// # Returns
///
/// * `Some(position)` if `row` is valid.
/// * `None` otherwise.
pub fn left<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(row.into(), self.as_ref().left, self.num_rows())
}
/// Return the right coordinate for a given row.
///
/// # Returns
///
/// * `Some(positions)` if `row` is valid.
/// * `None` otherwise.
pub fn right<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(
row.into(),
self.as_ref().right,
self.num_rows(),
)
}
/// Return the node for a given row.
///
/// # Returns
///
/// * `Some(node)` if `row` is valid.
/// * `None` otherwise.
pub fn node<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<NodeId> {
sys::tsk_column_access::<NodeId, _, _, _>(row.into(), self.as_ref().node, self.num_rows())
}
/// Return the source population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn source<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().source,
self.num_rows(),
)
}
/// Return the destination population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn dest<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().dest,
self.num_rows(),
)
}
/// Return the time of the migration event for a given row.
///
/// # Returns
///
/// * `Some(time)` if `row` is valid.
/// * `None` otherwise.
pub fn time<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Time> {
sys::tsk_column_access::<Time, _, _, _>(row.into(), self.as_ref().time, self.num_rows())
}
/// Retrieve decoded metadata for a `row`.
///
/// # Returns
///
/// * `Some(Ok(T))` if `row` is valid and decoding succeeded.
/// * `Some(Err(_))` if `row` is not valid and decoding failed.
/// * `None` if `row` is not valid.
///
/// # Errors
///
/// * [`TskitError::MetadataError`] if decoding fails.
///
/// # Examples.
///
/// The big-picture semantics are the same for all table types.
/// See [`crate::IndividualTable::metadata`] for examples.
pub fn metadata<T: metadata::MigrationMetadata>(
&self,
row: MigrationId,
) -> Option<Result<T, TskitError>> {
let buffer = self.raw_metadata(row)?;
Some(decode_metadata_row!(T, buffer).map_err(|e| e.into()))
}
/// Return an iterator over rows of the table.
/// The value of the iterator is [`MigrationTableRow`].
pub fn iter(&self) -> impl Iterator<Item = MigrationTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&MigrationTable>(self)
}
pub fn lending_iter(&self) -> MigrationTableRowView {
MigrationTableRowView::new(self)
}
/// Return row `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row)` if `r` is valid
/// * `None` otherwise
pub fn row<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRow> {
let ri = r.into().into();
table_row_access!(ri, self, make_migration_table_row)
}
/// Return a view of `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRowView> {
let view = MigrationTableRowView {
table: self,
id: r.into(),
left: self.left(r)?,
right: self.right(r)?,
node: self.node(r)?,
source: self.source(r)?,
dest: self.dest(r)?,
time: self.time(r)?,
metadata: self.raw_metadata(r.into()),
};
Some(view)
}
sourcepub fn node<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<NodeId>
pub fn node<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<NodeId>
Examples found in repository?
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option<MigrationTableRow> {
Some(MigrationTableRow {
id: pos.into(),
left: table.left(pos)?,
right: table.right(pos)?,
node: table.node(pos)?,
source: table.source(pos)?,
dest: table.dest(pos)?,
time: table.time(pos)?,
metadata: table.raw_metadata(pos).map(|m| m.to_vec()),
})
}
pub(crate) type MigrationTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a MigrationTable>;
pub(crate) type MigrationTableIterator = crate::table_iterator::TableIterator<MigrationTable>;
impl<'a> Iterator for MigrationTableRefIterator<'a> {
type Item = MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(self.table, self.pos);
self.pos += 1;
rv
}
}
impl Iterator for MigrationTableIterator {
type Item = crate::migration_table::MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(&self.table, self.pos);
self.pos += 1;
rv
}
}
#[derive(Debug)]
pub struct MigrationTableRowView<'a> {
table: &'a MigrationTable,
pub id: MigrationId,
pub left: Position,
pub right: Position,
pub node: NodeId,
pub source: PopulationId,
pub dest: PopulationId,
pub time: Time,
pub metadata: Option<&'a [u8]>,
}
impl<'a> MigrationTableRowView<'a> {
fn new(table: &'a MigrationTable) -> Self {
Self {
table,
id: MigrationId::NULL,
left: Position::from(f64::NAN),
right: Position::from(f64::NAN),
node: NodeId::NULL,
source: PopulationId::NULL,
dest: PopulationId::NULL,
time: Time::from(f64::NAN),
metadata: None,
}
}
}
impl<'a> PartialEq for MigrationTableRowView<'a> {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& self.metadata == other.metadata
}
}
impl<'a> Eq for MigrationTableRowView<'a> {}
impl<'a> PartialEq<MigrationTableRow> for MigrationTableRowView<'a> {
fn eq(&self, other: &MigrationTableRow) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl PartialEq<MigrationTableRowView<'_>> for MigrationTableRow {
fn eq(&self, other: &MigrationTableRowView) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl<'a> streaming_iterator::StreamingIterator for MigrationTableRowView<'a> {
type Item = Self;
row_lending_iterator_get!();
fn advance(&mut self) {
self.id = (i32::from(self.id) + 1).into();
self.left = self.table.left(self.id).unwrap_or_else(|| f64::NAN.into());
self.right = self.table.right(self.id).unwrap_or_else(|| f64::NAN.into());
self.node = self.table.node(self.id).unwrap_or(NodeId::NULL);
self.source = self.table.source(self.id).unwrap_or(PopulationId::NULL);
self.dest = self.table.dest(self.id).unwrap_or(PopulationId::NULL);
self.time = self.table.time(self.id).unwrap_or_else(|| f64::NAN.into());
self.metadata = self.table.raw_metadata(self.id);
}
}
/// An immutable view of a migration table.
///
/// These are not created directly but are accessed
/// by types implementing [`std::ops::Deref`] to
/// [`crate::table_views::TableViews`]
#[derive(Debug)]
#[repr(transparent)]
pub struct MigrationTable {
table_: sys::LLMigrationTableRef,
}
impl MigrationTable {
pub(crate) fn new_from_table(
migrations: *mut ll_bindings::tsk_migration_table_t,
) -> Result<Self, TskitError> {
let table_ = sys::LLMigrationTableRef::new_from_table(migrations)?;
Ok(MigrationTable { table_ })
}
pub(crate) fn as_ref(&self) -> &ll_bindings::tsk_migration_table_t {
self.table_.as_ref()
}
/// Return the number of rows
pub fn num_rows(&self) -> SizeType {
self.as_ref().num_rows.into()
}
raw_metadata_getter_for_tables!(MigrationId);
/// Return the left coordinate for a given row.
///
/// # Returns
///
/// * `Some(position)` if `row` is valid.
/// * `None` otherwise.
pub fn left<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(row.into(), self.as_ref().left, self.num_rows())
}
/// Return the right coordinate for a given row.
///
/// # Returns
///
/// * `Some(positions)` if `row` is valid.
/// * `None` otherwise.
pub fn right<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(
row.into(),
self.as_ref().right,
self.num_rows(),
)
}
/// Return the node for a given row.
///
/// # Returns
///
/// * `Some(node)` if `row` is valid.
/// * `None` otherwise.
pub fn node<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<NodeId> {
sys::tsk_column_access::<NodeId, _, _, _>(row.into(), self.as_ref().node, self.num_rows())
}
/// Return the source population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn source<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().source,
self.num_rows(),
)
}
/// Return the destination population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn dest<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().dest,
self.num_rows(),
)
}
/// Return the time of the migration event for a given row.
///
/// # Returns
///
/// * `Some(time)` if `row` is valid.
/// * `None` otherwise.
pub fn time<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Time> {
sys::tsk_column_access::<Time, _, _, _>(row.into(), self.as_ref().time, self.num_rows())
}
/// Retrieve decoded metadata for a `row`.
///
/// # Returns
///
/// * `Some(Ok(T))` if `row` is valid and decoding succeeded.
/// * `Some(Err(_))` if `row` is not valid and decoding failed.
/// * `None` if `row` is not valid.
///
/// # Errors
///
/// * [`TskitError::MetadataError`] if decoding fails.
///
/// # Examples.
///
/// The big-picture semantics are the same for all table types.
/// See [`crate::IndividualTable::metadata`] for examples.
pub fn metadata<T: metadata::MigrationMetadata>(
&self,
row: MigrationId,
) -> Option<Result<T, TskitError>> {
let buffer = self.raw_metadata(row)?;
Some(decode_metadata_row!(T, buffer).map_err(|e| e.into()))
}
/// Return an iterator over rows of the table.
/// The value of the iterator is [`MigrationTableRow`].
pub fn iter(&self) -> impl Iterator<Item = MigrationTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&MigrationTable>(self)
}
pub fn lending_iter(&self) -> MigrationTableRowView {
MigrationTableRowView::new(self)
}
/// Return row `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row)` if `r` is valid
/// * `None` otherwise
pub fn row<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRow> {
let ri = r.into().into();
table_row_access!(ri, self, make_migration_table_row)
}
/// Return a view of `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRowView> {
let view = MigrationTableRowView {
table: self,
id: r.into(),
left: self.left(r)?,
right: self.right(r)?,
node: self.node(r)?,
source: self.source(r)?,
dest: self.dest(r)?,
time: self.time(r)?,
metadata: self.raw_metadata(r.into()),
};
Some(view)
}
sourcepub fn source<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId>
pub fn source<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId>
Return the source population for a given row.
Returns
Some(population)
ifrow
is valid.None
otherwise.
Examples found in repository?
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option<MigrationTableRow> {
Some(MigrationTableRow {
id: pos.into(),
left: table.left(pos)?,
right: table.right(pos)?,
node: table.node(pos)?,
source: table.source(pos)?,
dest: table.dest(pos)?,
time: table.time(pos)?,
metadata: table.raw_metadata(pos).map(|m| m.to_vec()),
})
}
pub(crate) type MigrationTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a MigrationTable>;
pub(crate) type MigrationTableIterator = crate::table_iterator::TableIterator<MigrationTable>;
impl<'a> Iterator for MigrationTableRefIterator<'a> {
type Item = MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(self.table, self.pos);
self.pos += 1;
rv
}
}
impl Iterator for MigrationTableIterator {
type Item = crate::migration_table::MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(&self.table, self.pos);
self.pos += 1;
rv
}
}
#[derive(Debug)]
pub struct MigrationTableRowView<'a> {
table: &'a MigrationTable,
pub id: MigrationId,
pub left: Position,
pub right: Position,
pub node: NodeId,
pub source: PopulationId,
pub dest: PopulationId,
pub time: Time,
pub metadata: Option<&'a [u8]>,
}
impl<'a> MigrationTableRowView<'a> {
fn new(table: &'a MigrationTable) -> Self {
Self {
table,
id: MigrationId::NULL,
left: Position::from(f64::NAN),
right: Position::from(f64::NAN),
node: NodeId::NULL,
source: PopulationId::NULL,
dest: PopulationId::NULL,
time: Time::from(f64::NAN),
metadata: None,
}
}
}
impl<'a> PartialEq for MigrationTableRowView<'a> {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& self.metadata == other.metadata
}
}
impl<'a> Eq for MigrationTableRowView<'a> {}
impl<'a> PartialEq<MigrationTableRow> for MigrationTableRowView<'a> {
fn eq(&self, other: &MigrationTableRow) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl PartialEq<MigrationTableRowView<'_>> for MigrationTableRow {
fn eq(&self, other: &MigrationTableRowView) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl<'a> streaming_iterator::StreamingIterator for MigrationTableRowView<'a> {
type Item = Self;
row_lending_iterator_get!();
fn advance(&mut self) {
self.id = (i32::from(self.id) + 1).into();
self.left = self.table.left(self.id).unwrap_or_else(|| f64::NAN.into());
self.right = self.table.right(self.id).unwrap_or_else(|| f64::NAN.into());
self.node = self.table.node(self.id).unwrap_or(NodeId::NULL);
self.source = self.table.source(self.id).unwrap_or(PopulationId::NULL);
self.dest = self.table.dest(self.id).unwrap_or(PopulationId::NULL);
self.time = self.table.time(self.id).unwrap_or_else(|| f64::NAN.into());
self.metadata = self.table.raw_metadata(self.id);
}
}
/// An immutable view of a migration table.
///
/// These are not created directly but are accessed
/// by types implementing [`std::ops::Deref`] to
/// [`crate::table_views::TableViews`]
#[derive(Debug)]
#[repr(transparent)]
pub struct MigrationTable {
table_: sys::LLMigrationTableRef,
}
impl MigrationTable {
pub(crate) fn new_from_table(
migrations: *mut ll_bindings::tsk_migration_table_t,
) -> Result<Self, TskitError> {
let table_ = sys::LLMigrationTableRef::new_from_table(migrations)?;
Ok(MigrationTable { table_ })
}
pub(crate) fn as_ref(&self) -> &ll_bindings::tsk_migration_table_t {
self.table_.as_ref()
}
/// Return the number of rows
pub fn num_rows(&self) -> SizeType {
self.as_ref().num_rows.into()
}
raw_metadata_getter_for_tables!(MigrationId);
/// Return the left coordinate for a given row.
///
/// # Returns
///
/// * `Some(position)` if `row` is valid.
/// * `None` otherwise.
pub fn left<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(row.into(), self.as_ref().left, self.num_rows())
}
/// Return the right coordinate for a given row.
///
/// # Returns
///
/// * `Some(positions)` if `row` is valid.
/// * `None` otherwise.
pub fn right<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(
row.into(),
self.as_ref().right,
self.num_rows(),
)
}
/// Return the node for a given row.
///
/// # Returns
///
/// * `Some(node)` if `row` is valid.
/// * `None` otherwise.
pub fn node<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<NodeId> {
sys::tsk_column_access::<NodeId, _, _, _>(row.into(), self.as_ref().node, self.num_rows())
}
/// Return the source population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn source<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().source,
self.num_rows(),
)
}
/// Return the destination population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn dest<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().dest,
self.num_rows(),
)
}
/// Return the time of the migration event for a given row.
///
/// # Returns
///
/// * `Some(time)` if `row` is valid.
/// * `None` otherwise.
pub fn time<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Time> {
sys::tsk_column_access::<Time, _, _, _>(row.into(), self.as_ref().time, self.num_rows())
}
/// Retrieve decoded metadata for a `row`.
///
/// # Returns
///
/// * `Some(Ok(T))` if `row` is valid and decoding succeeded.
/// * `Some(Err(_))` if `row` is not valid and decoding failed.
/// * `None` if `row` is not valid.
///
/// # Errors
///
/// * [`TskitError::MetadataError`] if decoding fails.
///
/// # Examples.
///
/// The big-picture semantics are the same for all table types.
/// See [`crate::IndividualTable::metadata`] for examples.
pub fn metadata<T: metadata::MigrationMetadata>(
&self,
row: MigrationId,
) -> Option<Result<T, TskitError>> {
let buffer = self.raw_metadata(row)?;
Some(decode_metadata_row!(T, buffer).map_err(|e| e.into()))
}
/// Return an iterator over rows of the table.
/// The value of the iterator is [`MigrationTableRow`].
pub fn iter(&self) -> impl Iterator<Item = MigrationTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&MigrationTable>(self)
}
pub fn lending_iter(&self) -> MigrationTableRowView {
MigrationTableRowView::new(self)
}
/// Return row `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row)` if `r` is valid
/// * `None` otherwise
pub fn row<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRow> {
let ri = r.into().into();
table_row_access!(ri, self, make_migration_table_row)
}
/// Return a view of `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRowView> {
let view = MigrationTableRowView {
table: self,
id: r.into(),
left: self.left(r)?,
right: self.right(r)?,
node: self.node(r)?,
source: self.source(r)?,
dest: self.dest(r)?,
time: self.time(r)?,
metadata: self.raw_metadata(r.into()),
};
Some(view)
}
sourcepub fn dest<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId>
pub fn dest<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId>
Return the destination population for a given row.
Returns
Some(population)
ifrow
is valid.None
otherwise.
Examples found in repository?
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option<MigrationTableRow> {
Some(MigrationTableRow {
id: pos.into(),
left: table.left(pos)?,
right: table.right(pos)?,
node: table.node(pos)?,
source: table.source(pos)?,
dest: table.dest(pos)?,
time: table.time(pos)?,
metadata: table.raw_metadata(pos).map(|m| m.to_vec()),
})
}
pub(crate) type MigrationTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a MigrationTable>;
pub(crate) type MigrationTableIterator = crate::table_iterator::TableIterator<MigrationTable>;
impl<'a> Iterator for MigrationTableRefIterator<'a> {
type Item = MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(self.table, self.pos);
self.pos += 1;
rv
}
}
impl Iterator for MigrationTableIterator {
type Item = crate::migration_table::MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(&self.table, self.pos);
self.pos += 1;
rv
}
}
#[derive(Debug)]
pub struct MigrationTableRowView<'a> {
table: &'a MigrationTable,
pub id: MigrationId,
pub left: Position,
pub right: Position,
pub node: NodeId,
pub source: PopulationId,
pub dest: PopulationId,
pub time: Time,
pub metadata: Option<&'a [u8]>,
}
impl<'a> MigrationTableRowView<'a> {
fn new(table: &'a MigrationTable) -> Self {
Self {
table,
id: MigrationId::NULL,
left: Position::from(f64::NAN),
right: Position::from(f64::NAN),
node: NodeId::NULL,
source: PopulationId::NULL,
dest: PopulationId::NULL,
time: Time::from(f64::NAN),
metadata: None,
}
}
}
impl<'a> PartialEq for MigrationTableRowView<'a> {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& self.metadata == other.metadata
}
}
impl<'a> Eq for MigrationTableRowView<'a> {}
impl<'a> PartialEq<MigrationTableRow> for MigrationTableRowView<'a> {
fn eq(&self, other: &MigrationTableRow) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl PartialEq<MigrationTableRowView<'_>> for MigrationTableRow {
fn eq(&self, other: &MigrationTableRowView) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl<'a> streaming_iterator::StreamingIterator for MigrationTableRowView<'a> {
type Item = Self;
row_lending_iterator_get!();
fn advance(&mut self) {
self.id = (i32::from(self.id) + 1).into();
self.left = self.table.left(self.id).unwrap_or_else(|| f64::NAN.into());
self.right = self.table.right(self.id).unwrap_or_else(|| f64::NAN.into());
self.node = self.table.node(self.id).unwrap_or(NodeId::NULL);
self.source = self.table.source(self.id).unwrap_or(PopulationId::NULL);
self.dest = self.table.dest(self.id).unwrap_or(PopulationId::NULL);
self.time = self.table.time(self.id).unwrap_or_else(|| f64::NAN.into());
self.metadata = self.table.raw_metadata(self.id);
}
}
/// An immutable view of a migration table.
///
/// These are not created directly but are accessed
/// by types implementing [`std::ops::Deref`] to
/// [`crate::table_views::TableViews`]
#[derive(Debug)]
#[repr(transparent)]
pub struct MigrationTable {
table_: sys::LLMigrationTableRef,
}
impl MigrationTable {
pub(crate) fn new_from_table(
migrations: *mut ll_bindings::tsk_migration_table_t,
) -> Result<Self, TskitError> {
let table_ = sys::LLMigrationTableRef::new_from_table(migrations)?;
Ok(MigrationTable { table_ })
}
pub(crate) fn as_ref(&self) -> &ll_bindings::tsk_migration_table_t {
self.table_.as_ref()
}
/// Return the number of rows
pub fn num_rows(&self) -> SizeType {
self.as_ref().num_rows.into()
}
raw_metadata_getter_for_tables!(MigrationId);
/// Return the left coordinate for a given row.
///
/// # Returns
///
/// * `Some(position)` if `row` is valid.
/// * `None` otherwise.
pub fn left<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(row.into(), self.as_ref().left, self.num_rows())
}
/// Return the right coordinate for a given row.
///
/// # Returns
///
/// * `Some(positions)` if `row` is valid.
/// * `None` otherwise.
pub fn right<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(
row.into(),
self.as_ref().right,
self.num_rows(),
)
}
/// Return the node for a given row.
///
/// # Returns
///
/// * `Some(node)` if `row` is valid.
/// * `None` otherwise.
pub fn node<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<NodeId> {
sys::tsk_column_access::<NodeId, _, _, _>(row.into(), self.as_ref().node, self.num_rows())
}
/// Return the source population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn source<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().source,
self.num_rows(),
)
}
/// Return the destination population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn dest<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().dest,
self.num_rows(),
)
}
/// Return the time of the migration event for a given row.
///
/// # Returns
///
/// * `Some(time)` if `row` is valid.
/// * `None` otherwise.
pub fn time<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Time> {
sys::tsk_column_access::<Time, _, _, _>(row.into(), self.as_ref().time, self.num_rows())
}
/// Retrieve decoded metadata for a `row`.
///
/// # Returns
///
/// * `Some(Ok(T))` if `row` is valid and decoding succeeded.
/// * `Some(Err(_))` if `row` is not valid and decoding failed.
/// * `None` if `row` is not valid.
///
/// # Errors
///
/// * [`TskitError::MetadataError`] if decoding fails.
///
/// # Examples.
///
/// The big-picture semantics are the same for all table types.
/// See [`crate::IndividualTable::metadata`] for examples.
pub fn metadata<T: metadata::MigrationMetadata>(
&self,
row: MigrationId,
) -> Option<Result<T, TskitError>> {
let buffer = self.raw_metadata(row)?;
Some(decode_metadata_row!(T, buffer).map_err(|e| e.into()))
}
/// Return an iterator over rows of the table.
/// The value of the iterator is [`MigrationTableRow`].
pub fn iter(&self) -> impl Iterator<Item = MigrationTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&MigrationTable>(self)
}
pub fn lending_iter(&self) -> MigrationTableRowView {
MigrationTableRowView::new(self)
}
/// Return row `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row)` if `r` is valid
/// * `None` otherwise
pub fn row<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRow> {
let ri = r.into().into();
table_row_access!(ri, self, make_migration_table_row)
}
/// Return a view of `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRowView> {
let view = MigrationTableRowView {
table: self,
id: r.into(),
left: self.left(r)?,
right: self.right(r)?,
node: self.node(r)?,
source: self.source(r)?,
dest: self.dest(r)?,
time: self.time(r)?,
metadata: self.raw_metadata(r.into()),
};
Some(view)
}
sourcepub fn time<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Time>
pub fn time<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Time>
Return the time of the migration event for a given row.
Returns
Some(time)
ifrow
is valid.None
otherwise.
Examples found in repository?
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option<MigrationTableRow> {
Some(MigrationTableRow {
id: pos.into(),
left: table.left(pos)?,
right: table.right(pos)?,
node: table.node(pos)?,
source: table.source(pos)?,
dest: table.dest(pos)?,
time: table.time(pos)?,
metadata: table.raw_metadata(pos).map(|m| m.to_vec()),
})
}
pub(crate) type MigrationTableRefIterator<'a> =
crate::table_iterator::TableIterator<&'a MigrationTable>;
pub(crate) type MigrationTableIterator = crate::table_iterator::TableIterator<MigrationTable>;
impl<'a> Iterator for MigrationTableRefIterator<'a> {
type Item = MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(self.table, self.pos);
self.pos += 1;
rv
}
}
impl Iterator for MigrationTableIterator {
type Item = crate::migration_table::MigrationTableRow;
fn next(&mut self) -> Option<Self::Item> {
let rv = make_migration_table_row(&self.table, self.pos);
self.pos += 1;
rv
}
}
#[derive(Debug)]
pub struct MigrationTableRowView<'a> {
table: &'a MigrationTable,
pub id: MigrationId,
pub left: Position,
pub right: Position,
pub node: NodeId,
pub source: PopulationId,
pub dest: PopulationId,
pub time: Time,
pub metadata: Option<&'a [u8]>,
}
impl<'a> MigrationTableRowView<'a> {
fn new(table: &'a MigrationTable) -> Self {
Self {
table,
id: MigrationId::NULL,
left: Position::from(f64::NAN),
right: Position::from(f64::NAN),
node: NodeId::NULL,
source: PopulationId::NULL,
dest: PopulationId::NULL,
time: Time::from(f64::NAN),
metadata: None,
}
}
}
impl<'a> PartialEq for MigrationTableRowView<'a> {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& self.metadata == other.metadata
}
}
impl<'a> Eq for MigrationTableRowView<'a> {}
impl<'a> PartialEq<MigrationTableRow> for MigrationTableRowView<'a> {
fn eq(&self, other: &MigrationTableRow) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl PartialEq<MigrationTableRowView<'_>> for MigrationTableRow {
fn eq(&self, other: &MigrationTableRowView) -> bool {
self.id == other.id
&& self.node == other.node
&& self.source == other.source
&& self.dest == other.dest
&& crate::util::partial_cmp_equal(&self.left, &other.left)
&& crate::util::partial_cmp_equal(&self.right, &other.right)
&& crate::util::partial_cmp_equal(&self.time, &other.time)
&& optional_container_comparison!(self.metadata, other.metadata)
}
}
impl<'a> streaming_iterator::StreamingIterator for MigrationTableRowView<'a> {
type Item = Self;
row_lending_iterator_get!();
fn advance(&mut self) {
self.id = (i32::from(self.id) + 1).into();
self.left = self.table.left(self.id).unwrap_or_else(|| f64::NAN.into());
self.right = self.table.right(self.id).unwrap_or_else(|| f64::NAN.into());
self.node = self.table.node(self.id).unwrap_or(NodeId::NULL);
self.source = self.table.source(self.id).unwrap_or(PopulationId::NULL);
self.dest = self.table.dest(self.id).unwrap_or(PopulationId::NULL);
self.time = self.table.time(self.id).unwrap_or_else(|| f64::NAN.into());
self.metadata = self.table.raw_metadata(self.id);
}
}
/// An immutable view of a migration table.
///
/// These are not created directly but are accessed
/// by types implementing [`std::ops::Deref`] to
/// [`crate::table_views::TableViews`]
#[derive(Debug)]
#[repr(transparent)]
pub struct MigrationTable {
table_: sys::LLMigrationTableRef,
}
impl MigrationTable {
pub(crate) fn new_from_table(
migrations: *mut ll_bindings::tsk_migration_table_t,
) -> Result<Self, TskitError> {
let table_ = sys::LLMigrationTableRef::new_from_table(migrations)?;
Ok(MigrationTable { table_ })
}
pub(crate) fn as_ref(&self) -> &ll_bindings::tsk_migration_table_t {
self.table_.as_ref()
}
/// Return the number of rows
pub fn num_rows(&self) -> SizeType {
self.as_ref().num_rows.into()
}
raw_metadata_getter_for_tables!(MigrationId);
/// Return the left coordinate for a given row.
///
/// # Returns
///
/// * `Some(position)` if `row` is valid.
/// * `None` otherwise.
pub fn left<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(row.into(), self.as_ref().left, self.num_rows())
}
/// Return the right coordinate for a given row.
///
/// # Returns
///
/// * `Some(positions)` if `row` is valid.
/// * `None` otherwise.
pub fn right<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Position> {
sys::tsk_column_access::<Position, _, _, _>(
row.into(),
self.as_ref().right,
self.num_rows(),
)
}
/// Return the node for a given row.
///
/// # Returns
///
/// * `Some(node)` if `row` is valid.
/// * `None` otherwise.
pub fn node<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<NodeId> {
sys::tsk_column_access::<NodeId, _, _, _>(row.into(), self.as_ref().node, self.num_rows())
}
/// Return the source population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn source<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().source,
self.num_rows(),
)
}
/// Return the destination population for a given row.
///
/// # Returns
///
/// * `Some(population)` if `row` is valid.
/// * `None` otherwise.
pub fn dest<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<PopulationId> {
sys::tsk_column_access::<PopulationId, _, _, _>(
row.into(),
self.as_ref().dest,
self.num_rows(),
)
}
/// Return the time of the migration event for a given row.
///
/// # Returns
///
/// * `Some(time)` if `row` is valid.
/// * `None` otherwise.
pub fn time<M: Into<MigrationId> + Copy>(&self, row: M) -> Option<Time> {
sys::tsk_column_access::<Time, _, _, _>(row.into(), self.as_ref().time, self.num_rows())
}
/// Retrieve decoded metadata for a `row`.
///
/// # Returns
///
/// * `Some(Ok(T))` if `row` is valid and decoding succeeded.
/// * `Some(Err(_))` if `row` is not valid and decoding failed.
/// * `None` if `row` is not valid.
///
/// # Errors
///
/// * [`TskitError::MetadataError`] if decoding fails.
///
/// # Examples.
///
/// The big-picture semantics are the same for all table types.
/// See [`crate::IndividualTable::metadata`] for examples.
pub fn metadata<T: metadata::MigrationMetadata>(
&self,
row: MigrationId,
) -> Option<Result<T, TskitError>> {
let buffer = self.raw_metadata(row)?;
Some(decode_metadata_row!(T, buffer).map_err(|e| e.into()))
}
/// Return an iterator over rows of the table.
/// The value of the iterator is [`MigrationTableRow`].
pub fn iter(&self) -> impl Iterator<Item = MigrationTableRow> + '_ {
crate::table_iterator::make_table_iterator::<&MigrationTable>(self)
}
pub fn lending_iter(&self) -> MigrationTableRowView {
MigrationTableRowView::new(self)
}
/// Return row `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row)` if `r` is valid
/// * `None` otherwise
pub fn row<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRow> {
let ri = r.into().into();
table_row_access!(ri, self, make_migration_table_row)
}
/// Return a view of `r` of the table.
///
/// # Parameters
///
/// * `r`: the row id.
///
/// # Returns
///
/// * `Some(row view)` if `r` is valid
/// * `None` otherwise
pub fn row_view<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRowView> {
let view = MigrationTableRowView {
table: self,
id: r.into(),
left: self.left(r)?,
right: self.right(r)?,
node: self.node(r)?,
source: self.source(r)?,
dest: self.dest(r)?,
time: self.time(r)?,
metadata: self.raw_metadata(r.into()),
};
Some(view)
}
sourcepub fn metadata<T: MigrationMetadata>(
&self,
row: MigrationId
) -> Option<Result<T, TskitError>>
pub fn metadata<T: MigrationMetadata>(
&self,
row: MigrationId
) -> Option<Result<T, TskitError>>
Retrieve decoded metadata for a row
.
Returns
Some(Ok(T))
ifrow
is valid and decoding succeeded.Some(Err(_))
ifrow
is not valid and decoding failed.None
ifrow
is not valid.
Errors
TskitError::MetadataError
if decoding fails.
Examples.
The big-picture semantics are the same for all table types.
See crate::IndividualTable::metadata
for examples.
sourcepub fn iter(&self) -> impl Iterator<Item = MigrationTableRow> + '_
pub fn iter(&self) -> impl Iterator<Item = MigrationTableRow> + '_
Return an iterator over rows of the table.
The value of the iterator is MigrationTableRow
.
pub fn lending_iter(&self) -> MigrationTableRowView<'_>
sourcepub fn row<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRow>
pub fn row<M: Into<MigrationId> + Copy>(&self, r: M) -> Option<MigrationTableRow>
sourcepub fn row_view<M: Into<MigrationId> + Copy>(
&self,
r: M
) -> Option<MigrationTableRowView<'_>>
pub fn row_view<M: Into<MigrationId> + Copy>(
&self,
r: M
) -> Option<MigrationTableRowView<'_>>
Return a view of r
of the table.
Parameters
r
: the row id.
Returns
Some(row view)
ifr
is validNone
otherwise
sourcepub fn left_slice(&self) -> &[Position]
pub fn left_slice(&self) -> &[Position]
Get the left column as a slice
sourcepub fn left_slice_raw(&self) -> &[f64]
pub fn left_slice_raw(&self) -> &[f64]
Get the left column as a slice
sourcepub fn right_slice(&self) -> &[Position]
pub fn right_slice(&self) -> &[Position]
Get the right column as a slice
sourcepub fn right_slice_raw(&self) -> &[f64]
pub fn right_slice_raw(&self) -> &[f64]
Get the right column as a slice
sourcepub fn time_slice(&self) -> &[Time]
pub fn time_slice(&self) -> &[Time]
Get the time column as a slice
sourcepub fn time_slice_raw(&self) -> &[f64]
pub fn time_slice_raw(&self) -> &[f64]
Get the time column as a slice
sourcepub fn node_slice(&self) -> &[NodeId]
pub fn node_slice(&self) -> &[NodeId]
Get the node column as a slice
sourcepub fn node_slice_raw(&self) -> &[tsk_id_t]
pub fn node_slice_raw(&self) -> &[tsk_id_t]
Get the node column as a slice
sourcepub fn source_slice(&self) -> &[PopulationId]
pub fn source_slice(&self) -> &[PopulationId]
Get the source column as a slice
sourcepub fn source_slice_raw(&self) -> &[tsk_id_t]
pub fn source_slice_raw(&self) -> &[tsk_id_t]
Get the source column as a slice
sourcepub fn dest_slice(&self) -> &[PopulationId]
pub fn dest_slice(&self) -> &[PopulationId]
Get the dest column as a slice
sourcepub fn dest_slice_raw(&self) -> &[tsk_id_t]
pub fn dest_slice_raw(&self) -> &[tsk_id_t]
Get the dest column as a slice