Skip to main content

TreeModel

Trait TreeModel 

Source
pub trait TreeModel {
    type Id: Copy + Eq + Hash;

    // Required methods
    fn roots(&self) -> impl Iterator<Item = Self::Id> + '_;
    fn children(&self, id: Self::Id) -> TreeChildren<'_, Self::Id>;
    fn revision(&self) -> TreeRevision;

    // Provided method
    fn size_hint(&self) -> usize { ... }
}
Expand description

Минимальный контракт источника дерева, леса или корневого ациклического графа.

Общие дочерние вершины допустимы и создают отдельные вхождения видимых строк. Циклы, повторные корни и повторные идентификаторы в одном списке детей недопустимы. Идентификаторы должны быть стабильными и дешёвыми для копирования. Каждый идентификатор из roots или children должен оставаться корректным для последующих вызовов методов модели.

Required Associated Types§

Source

type Id: Copy + Eq + Hash

The node identifier type.

Required Methods§

Source

fn roots(&self) -> impl Iterator<Item = Self::Id> + '_

Returns forest roots in deterministic order.

Source

fn children(&self, id: Self::Id) -> TreeChildren<'_, Self::Id>

Returns the node’s child state and loaded children.

Source

fn revision(&self) -> TreeRevision

Returns the revision of the model structure and display data.

Provided Methods§

Source

fn size_hint(&self) -> usize

Returns an approximate number of available nodes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, Id, C> TreeModel for TreeModelRef<'a, Id, C>
where Id: Copy + Eq + Hash, C: Fn(Id) -> TreeChildren<'a, Id>,

Source§

type Id = Id

Source§

impl<C> TreeModel for IndexedTree<'_, C>
where C: AsRef<[usize]>,