# RealizedStackElements

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls-treedatagrid/primitives/struct-realizedstackelements/

**struct** · [`ferroui-controls-treedatagrid`](/docs/0.5.0/api/ferroui-controls-treedatagrid/) · v0.5.0

```rust
struct RealizedStackElements
```

Stores the realized element state for a presenter of the control.

The state is interior-mutable: the methods that call back into the presenter (to recycle an
element or to update its index) never hold a borrow of the element list across the callback.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L21)

## Members

- [`new`](#function-new)
- [`count`](#function-count)
- [`first_index`](#function-first_index)
- [`last_index`](#function-last_index)
- [`elements`](#function-elements)
- [`elements_snapshot`](#function-elements_snapshot)
- [`size_u`](#function-size_u)
- [`element_at`](#function-element_at)
- [`size_u_at`](#function-size_u_at)
- [`start_u`](#function-start_u)
- [`try_get_stable_range`](#function-try_get_stable_range)
- [`add`](#function-add)
- [`get_element`](#function-get_element)
- [`get_or_estimate_anchor_element_for_viewport`](#function-get_or_estimate_anchor_element_for_viewport)
- [`get_element_u`](#function-get_element_u)
- [`get_or_estimate_element_u`](#function-get_or_estimate_element_u)
- [`estimate_element_size_u`](#function-estimate_element_size_u)
- [`get_index`](#function-get_index)
- [`items_inserted`](#function-items_inserted)
- [`items_removed`](#function-items_removed)
- [`items_moved`](#function-items_moved)
- [`items_replaced`](#function-items_replaced)
- [`items_reset`](#function-items_reset)
- [`recycle_elements_before`](#function-recycle_elements_before)
- [`recycle_elements_after`](#function-recycle_elements_after)
- [`recycle_all_elements`](#function-recycle_all_elements)
- [`reset_for_reuse`](#function-reset_for_reuse)

<a id="function-new"></a>

### new

```rust
fn new(trace_enabled: bool) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L31)

<a id="function-count"></a>

### count

```rust
fn count(self: &Self) -> usize
```

Gets the number of realized elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L51)

<a id="function-first_index"></a>

### first_index

```rust
fn first_index(self: &Self) -> i32
```

Gets the index of the first realized element, or -1 if no elements are realized.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L57)

<a id="function-last_index"></a>

### last_index

```rust
fn last_index(self: &Self) -> i32
```

Gets the index of the last realized element, or -1 if no elements are realized.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L67)

<a id="function-elements"></a>

### elements

```rust
fn elements(self: &Self) -> CellRef<'_, Vec<Option<Ref<Control>>>>
```

Gets the elements.

The returned borrow must not be held across a call that can run code outside the
presenter; use `element_at` for that.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L81)

<a id="function-elements_snapshot"></a>

### elements_snapshot

```rust
fn elements_snapshot(self: &Self) -> Vec<Option<Ref<Control>>>
```

A copy of the elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L86)

<a id="function-size_u"></a>

### size_u

```rust
fn size_u(self: &Self) -> CellRef<'_, Vec<f64>>
```

Gets the sizes of the elements on the primary axis.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L92)

<a id="function-element_at"></a>

### element_at

```rust
fn element_at(self: &Self, i: usize) -> Option<Ref<Control>>
```

Gets the element at the specified position of the realized list (not of the source
collection), if there is one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L99)

<a id="function-size_u_at"></a>

### size_u_at

```rust
fn size_u_at(self: &Self, i: usize) -> f64
```

Gets the size on the primary axis of the element at the specified position of the realized
list (not of the source collection).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L106)

<a id="function-start_u"></a>

### start_u

```rust
fn start_u(self: &Self) -> f64
```

Gets the position of the first element on the primary axis.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L112)

<a id="function-try_get_stable_range"></a>

### try_get_stable_range

```rust
fn try_get_stable_range(self: &Self) -> Option<(f64, f64)>
```

Gets the range covered by contiguous, measured realized elements, as `(start, end)`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L117)

<a id="function-add"></a>

### add

```rust
fn add(self: &Self, index: i32, element: Ref<Control>, u: f64, size_u: f64)
```

Adds a newly realized element to the collection.

`index` is the index of the element, `u` the position of the element on the primary axis and
`size_u` the size of the element on the primary axis.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L148)

<a id="function-get_element"></a>

### get_element

```rust
fn get_element(self: &Self, index: i32) -> Option<Ref<Control>>
```

Gets the element at the specified index, if realized.

`index` is the index in the source collection of the element to get.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L177)

<a id="function-get_or_estimate_anchor_element_for_viewport"></a>

### get_or_estimate_anchor_element_for_viewport

```rust
fn get_or_estimate_anchor_element_for_viewport(self: &Self, viewport_start_u: f64, viewport_end_u: f64, item_count: i32, estimated_element_size_u: &Cell<f64>) -> (i32, f64)
```

Gets or estimates the index and start U position of the anchor element for the specified
viewport.

Returns the index of the anchor element, or -1 if an anchor could not be determined, and the
U position of the start of the anchor element, if determined.

This method tries to find an existing element in the specified viewport from which element
realization can start. Failing that it estimates the first element in the viewport.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L195)

<a id="function-get_element_u"></a>

### get_element_u

```rust
fn get_element_u(self: &Self, index: i32) -> f64
```

Gets the position of the element with the requested index on the primary axis, if realized.

Returns the position of the element, or NaN if the element is not realized.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L250)

<a id="function-get_or_estimate_element_u"></a>

### get_or_estimate_element_u

```rust
fn get_or_estimate_element_u(self: &Self, index: i32, estimated_element_size_u: &Cell<f64>) -> f64
```

Gets the position of the element with the requested index on the primary axis, estimating
it from the realized range when the element is not realized.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L273)

<a id="function-estimate_element_size_u"></a>

### estimate_element_size_u

```rust
fn estimate_element_size_u(self: &Self) -> f64
```

Estimates the average U size of all elements in the source collection based on the realized
elements.

Returns the estimated U size of an element, or -1 if not enough information is present to
make an estimate.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L326)

<a id="function-get_index"></a>

### get_index

```rust
fn get_index(self: &Self, element: &Ref<Control>) -> i32
```

Gets the index of the specified element.

Returns the index or -1 if the element is not present in the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L350)

<a id="function-items_inserted"></a>

### items_inserted

```rust
fn items_inserted(self: &Self, index: i32, count: i32, update_element_index: impl Fn(&Ref<Control>, i32, i32) -> (), recycle_element: impl Fn(&Ref<Control>) -> ())
```

Updates the elements in response to items being inserted into the source collection.

`index` is the index in the source collection of the insert, `count` the number of items
inserted, `update_element_index` a method used to update the element indexes and
`recycle_element` a method used to recycle elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L363)

<a id="function-items_removed"></a>

### items_removed

```rust
fn items_removed(self: &Self, index: i32, count: i32, update_element_index: impl Fn(&Ref<Control>, i32, i32) -> (), recycle_element: impl Fn(&Ref<Control>) -> ())
```

Updates the elements in response to items being removed from the source collection.

`index` is the index in the source collection of the remove, `count` the number of items
removed, `update_element_index` a method used to update the element indexes and
`recycle_element` a method used to recycle elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L443)

<a id="function-items_moved"></a>

### items_moved

```rust
fn items_moved(self: &Self, old_index: i32, new_index: i32, count: i32, update_element_index: impl Fn(&Ref<Control>, i32, i32) -> (), recycle_element: impl Fn(&Ref<Control>) -> ())
```

Updates the elements in response to items being moved within the source collection.

`old_index` is the old index in the source collection, `new_index` the new index, `count`
the number of items moved, `update_element_index` a method used to update the element
indexes and `recycle_element` a method used to recycle elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L517)

<a id="function-items_replaced"></a>

### items_replaced

```rust
fn items_replaced(self: &Self, index: i32, count: i32, recycle_element: impl Fn(&Ref<Control>) -> ())
```

Updates the elements in response to items being replaced in the source collection.

`index` is the index in the source collection of the remove, `count` the number of items
removed and `recycle_element` a method used to recycle elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L596)

<a id="function-items_reset"></a>

### items_reset

```rust
fn items_reset(self: &Self, recycle_element: impl Fn(&Ref<Control>) -> ())
```

Recycles all elements in response to the source collection being reset.

`recycle_element` is a method used to recycle elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L622)

<a id="function-recycle_elements_before"></a>

### recycle_elements_before

```rust
fn recycle_elements_before(self: &Self, index: i32, recycle_element: impl Fn(&Ref<Control>, i32) -> ())
```

Recycles elements before a specific index.

`index` is the index in the source collection of new first element and `recycle_element` a
method used to recycle elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L645)

<a id="function-recycle_elements_after"></a>

### recycle_elements_after

```rust
fn recycle_elements_after(self: &Self, index: i32, recycle_element: impl Fn(&Ref<Control>, i32) -> ())
```

Recycles elements after a specific index.

`index` is the index in the source collection of new last element and `recycle_element` a
method used to recycle elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L671)

<a id="function-recycle_all_elements"></a>

### recycle_all_elements

```rust
fn recycle_all_elements(self: &Self, recycle_element: impl Fn(&Ref<Control>, i32) -> ())
```

Recycles all realized elements.

`recycle_element` is a method used to recycle elements.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L696)

<a id="function-reset_for_reuse"></a>

### reset_for_reuse

```rust
fn reset_for_reuse(self: &Self)
```

Resets the element list and prepares it for reuse.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/TreeDataGrid/FerroUI.Controls.TreeDataGrid/primitives/realized_stack_elements.rs#L718)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
