Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux latest

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 previewOpen reference