# LibTmux.Selection

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/66b9b1c3f3f3186428abdfda2c76f5cf87446710/lib/libtmux/selection.ex#L1
- **Page:** https://libtmux.org/en/elixir/latest/reference/libtmux-selection/

An ordered, materialized Enumerable over one captured entity type.

Enumeration never refreshes or performs I/O. `where/2` accepts predicate
data; `filter/2` accepts unary Elixir functions with Enum truthiness.
Holding a selection retains its snapshot graph. `Enum.to_list/1` projects
ordinary values when graph context is no longer needed.

## Members

### Common operations

- [`count/2`](/en/elixir/latest/reference/libtmux-selection-count-2/) (function): Counts observed matching items; use size/1 for cached unfiltered size.
- [`filter/2`](/en/elixir/latest/reference/libtmux-selection-filter-2/) (function): Filters with a unary local function; normal predicate exceptions propagate.
- [`one!/2`](/en/elixir/latest/reference/libtmux-selection-one-bang-2/) (function): Returns exactly one match or raises its cardinality error.
- [`where/2`](/en/elixir/latest/reference/libtmux-selection-where-2/) (function): Filters validated data while retaining order and captured graph context.
- [`member_id?/2`](/en/elixir/latest/reference/libtmux-selection-member_id-question-2/) (function): Checks native identity separately from Enumerable element membership.
- [`one/2`](/en/elixir/latest/reference/libtmux-selection-one-2/) (function): Returns exactly one match, or a structured cardinality error; stops at the second match.
- [`one_or_nil/2`](/en/elixir/latest/reference/libtmux-selection-one_or_nil-2/) (function): Returns one match or nil; a second match remains an error.

### Other members

- [`exists?/2`](/en/elixir/latest/reference/libtmux-selection-exists-question-2/) (function): Returns true on the first matching observed item.
- [`new/2`](/en/elixir/latest/reference/libtmux-selection-new-2/) (function): Materializes the observed items of an entity without I/O.
- [`one_or_nil!/2`](/en/elixir/latest/reference/libtmux-selection-one_or_nil-bang-2/) (function): Returns one match or nil, raising on multiple matches.
- [`size/1`](/en/elixir/latest/reference/libtmux-selection-size-1/) (function): Returns cached materialized size in constant time.
- [`t/0`](/en/elixir/latest/reference/libtmux-selection-t-0/) (typealias): A selection without a concrete observation type; use `t:t/1` to preserve item types.
- [`t/1`](/en/elixir/latest/reference/libtmux-selection-t-1/) (typealias): An ordered selection retaining items of one observation type and their originating snapshot.
