pub struct TrimNode {
pub id: usize,
pub kind: NodeKind,
pub weight: usize,
pub value: f64,
pub children: Vec<TrimNode>,
pub included: bool,
}Expand description
Trim tree node.
Fields§
§id: usizeUnique node identifier within the tree
kind: NodeKind§weight: usizeWeight in tokens (serialization cost without children)
value: f64Information value (0.0-1.0), assigned by the strategy
children: Vec<TrimNode>Child nodes
included: boolWhether the node is included in the final output
Implementations§
Source§impl TrimNode
impl TrimNode
Sourcepub fn count_nodes(&self) -> usize
pub fn count_nodes(&self) -> usize
Total number of nodes in the subtree (including self).
Sourcepub fn total_weight(&self) -> usize
pub fn total_weight(&self) -> usize
Total weight of the subtree (sum of weights of all included nodes).
Sourcepub fn total_value(&self) -> f64
pub fn total_value(&self) -> f64
Total value of the subtree (sum of value * weight for included nodes).
Sourcepub fn included_items_count(&self) -> usize
pub fn included_items_count(&self) -> usize
Count of included Item nodes.
Sourcepub fn included_item_indices(&self) -> Vec<usize>
pub fn included_item_indices(&self) -> Vec<usize>
Collect indices of included Item nodes.
Sourcepub fn excluded_item_indices(&self) -> Vec<usize>
pub fn excluded_item_indices(&self) -> Vec<usize>
Collect indices of excluded Item nodes (overflow).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TrimNode
impl RefUnwindSafe for TrimNode
impl Send for TrimNode
impl Sync for TrimNode
impl Unpin for TrimNode
impl UnsafeUnpin for TrimNode
impl UnwindSafe for TrimNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more