paya.util.iterables#
- clampindex(index, numelems, absolute=False)#
Clamps an index, whether negative or positive, so that it remains within the range implied by numelems.
- index_in_range(index, numelems)#
- Returns
True if the index is ‘legal’. Essentially a pre-emptive
IndexError
.
- absindex(index, numelems, loop=False)#
Resolves a negative (reverse) index into a positive (forward) one.
- Parameters
index (int) – the index to edit
numelems (int) – the number of elements in the iterable
loop (bool) – if this is
False
, and the index is out of range,IndexError
will be raised; otherwise, the index will be wound over; defaults to False
- Returns
The resolved index.
- Return type
- send_indices_relative(indicesToMove, refIndex, lst, after=True)#
Sends members at the specified indices into one contiguous block after
refIndex
. This is an in-place operation
- send_indices_before(indicesToMove, refIndex, lst)#
Equivalent to
send_indices_relative(after=False)
.
- send_indices_after(indicesToMove, refIndex, lst)#
Equivalent to
send_indices_relative(after=True)
.
- nudge_index(index, lst, offset)#
Nudges an index in the direction and distance specified by ‘offset’.
- nudge_indices(indices, lst, offset)#
Suitable for multi-selection list reordering. It clamps for out-of-range shifts, and maintains order within contiguous selection groups.
This is an in-place operation.