pub struct Code {
pub content: u32,
pub len: u32,
}Expand description
Represents a codeword.
Fields§
§content: u32Concatenated fragments of the codeword.
If the code is too short to take up all the bits, only the least significant ones are used. The first fragments of the code are stored either on the most significant or, in the case of an reversed code, on the least significant, of these bits.
If the code is too long, only the last few fragments are explicitly stored. Fragments that do not fit contain zeros and are not explicitly stored.
len: u32Length of the code in fragments.
Implementations§
Source§impl Code
impl Code
Sourcepub unsafe fn get_rev_unchecked(
&self,
fragment_nr: u32,
degree: impl TreeDegree,
) -> u32
pub unsafe fn get_rev_unchecked( &self, fragment_nr: u32, degree: impl TreeDegree, ) -> u32
Gets fragment_nr-th fragment from either the end or, if self is reversed, the beginning.
Result is undefined if fragment_nr is out of bounds (i.e. not less than len).
Sourcepub fn get_rev(&self, fragment_nr: u32, degree: impl TreeDegree) -> Option<u32>
pub fn get_rev(&self, fragment_nr: u32, degree: impl TreeDegree) -> Option<u32>
Gets fragment_nr-th fragment from either the end or, if self is reversed, the beginning.
Returns None if fragment_nr is out of bounds (i.e. not less than len).
Sourcepub unsafe fn get_unchecked(
&self,
fragment_nr: u32,
degree: impl TreeDegree,
) -> u32
pub unsafe fn get_unchecked( &self, fragment_nr: u32, degree: impl TreeDegree, ) -> u32
Gets fragment_nr-th fragment from either the beginning or, if self is reversed, the end.
Result is undefined if fragment_nr is out of bounds (i.e. not less than len).
Sourcepub fn get(&self, fragment_nr: u32, degree: impl TreeDegree) -> Option<u32>
pub fn get(&self, fragment_nr: u32, degree: impl TreeDegree) -> Option<u32>
Gets fragment_nr-th fragment from either the beginning or, if self is reversed, the end.
Returns None if fragment_nr is out of bounds (i.e. not less than len).
Sourcepub fn extract_first(&mut self, degree: impl TreeDegree) -> Option<u32>
pub fn extract_first(&mut self, degree: impl TreeDegree) -> Option<u32>
Extracts and returns the first remaining fragment of the unreversed code.
Return None if code is empty.
Sourcepub fn extract_rev_first(&mut self, degree: impl TreeDegree) -> Option<u32>
pub fn extract_rev_first(&mut self, degree: impl TreeDegree) -> Option<u32>
Extracts and returns the first remaining fragment of the reversed code.
Return None if code is empty.
Sourcepub fn iter<D: TreeDegree>(&self, degree: D) -> CodeIterator<D> ⓘ
pub fn iter<D: TreeDegree>(&self, degree: D) -> CodeIterator<D> ⓘ
Returns iterator over the fragments of unreversed code.
Sourcepub fn iter_rev<D: TreeDegree>(&self, degree: D) -> ReversedCodeIterator<D> ⓘ
pub fn iter_rev<D: TreeDegree>(&self, degree: D) -> ReversedCodeIterator<D> ⓘ
Returns iterator over the fragments of reversed code.