Core LibrarystableAPI Reference

Choose documentation 3

stable

Current version

stable
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

method libtmux stable

SparseArray.add

Add a value at a specific index.

Source and package
Qualified name
libtmux._internal.sparse_array.SparseArray.add
Module
libtmux._internal.sparse_array
Declared in
SparseArray
Package
libtmux
Source
src/libtmux/_internal/sparse_array.py
add (self, index: int, value: T) → None

Examples#

>>> from libtmux._internal.sparse_array import SparseArray
>>> arr: SparseArray[str] = SparseArray()
>>> arr.add(0, "hook at index 0")
>>> arr.add(10, "hook at index 10")
>>> arr[0]
'hook at index 0'
>>> arr[10]
'hook at index 10'
>>> sorted(arr.keys())
[0, 10]
Type parameters
Parameters
  • index (int) # – The index at which to store the value.

  • value (T) # – The value to store.

Esc

Type to search.

Reference preview Open reference