# Algorithm

> Operations that build a new object out of existing ones.

Symbols in this group are spelled `otio_algorithm_…`. An SDK drops that prefix.

## `flatten_stack`

`otio_algorithm_flatten_stack` · method

Collapses a stack's tracks into one, top layer winning where it is visible.

```c
OtioStatus otio_algorithm_flatten_stack(
    OtioDocument *target,
    OtioNode stack,
    OtioNode *out_track,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `target` | `document` | document mut |
| `stack` | `node` | input |
| `out_track` | `node` | output |
| `out_error` | `text` | error |

## `flatten_tracks`

`otio_algorithm_flatten_tracks` · method

Collapses a list of tracks into one, lowest first.

```c
OtioStatus otio_algorithm_flatten_tracks(
    OtioDocument *target,
    const OtioNode *tracks,
    size_t count,
    OtioNode *out_track,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `target` | `document` | document mut |
| `tracks` (optional) | `list<node>` | input |
| `count` | `size` | length |
| `out_track` | `node` | output |
| `out_error` | `text` | error |

## `track_trimmed_to_range`

`otio_algorithm_track_trimmed_to_range` · method

Returns a copy of a track holding only what falls inside a span.

The copy is added to the same document and has no parent.

```c
OtioStatus otio_algorithm_track_trimmed_to_range(
    OtioDocument *target,
    OtioNode track,
    OtioTimeRange trim_range,
    OtioNode *out_track,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `target` | `document` | document mut |
| `track` | `node` | input |
| `trim_range` | `OtioTimeRange` | input |
| `out_track` | `node` | output |
| `out_error` | `text` | error |

---

Page: https://otio-rust-docs.vercel.app/reference/algorithm/
