pub trait IndexMapping: Sealed {
// Required methods
fn get(&self, id: u32) -> Option<u32>;
fn is_mapped(&self, id: u32) -> bool;
fn is_partial(&self) -> bool;
fn mapped_count(&self) -> u32;
fn index_count(&self) -> u32;
}Expand description
A mapping from the indices 0..index_count() to the indices of another numbering - Java’s abstract
class IndexMapping. It is the common base of the node and edge mappings and of the partitions.
The indices are node IDs or edge indices. get(i) is the index that i maps to, or
None if i is not mapped - Java’s -1; a mapping with unmapped indices is partial. A
NodeMapping maps the node IDs of one graph to those of another, and an EdgeMapping does the
same for edge indices. Neither maps two indices to the same index, so both can be inverted. An
IndexPartition maps indices to groups and lists the indices of each
group. Several indices can map to the same group.
That a node or edge mapping maps no two indices to the same index is a contract, not a check:
NodeMapping::of accepts an array that breaks it, and only inverted and
graphs::remapped reject such a mapping.
NodeMapping, EdgeMapping, NodePartition,
EdgePartition and Sccs implement this trait. Each of
them has the same methods as inherent methods too, so the trait is needed only for code that is
generic over them. It is sealed, as Java’s class hierarchy is. Instances are immutable and safe to
share between threads (Send and Sync).
Memory: 4 x index_count bytes; a partition holds more.
Required Methods§
Sourcefn get(&self, id: u32) -> Option<u32>
fn get(&self, id: u32) -> Option<u32>
Returns the index that id maps to, or None if id is not mapped - Java’s -1.
In a partition, it is the group of id.
Time: O(1).
§Panics
With an index out of bounds message if id is not in 0..index_count().
Sourcefn is_mapped(&self, id: u32) -> bool
fn is_mapped(&self, id: u32) -> bool
Returns whether id is mapped. Equivalent to get(id).is_some().
Time: O(1).
§Panics
With an index out of bounds message if id is not in 0..index_count().
Sourcefn is_partial(&self) -> bool
fn is_partial(&self) -> bool
Returns whether some index is not mapped. Equivalent to mapped_count() < index_count().
Time: O(1).
Sourcefn mapped_count(&self) -> u32
fn mapped_count(&self) -> u32
Returns the number of indices that are mapped; in a partition, the number of indices that belong to a group.
Time: O(1).
Sourcefn index_count(&self) -> u32
fn index_count(&self) -> u32
Returns the number of indices this mapping maps from, mapped or not.
It is the length of the arrays that gather returns and that reduce takes.
Time: O(1).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".