Skip to main content
Log in

Mojo function

reversed

reversed[T: ReversibleRange](value: T) -> _StridedRange

Get a reversed iterator of the input range.

Note: iterators are currently non-raising.

Parameters:

  • ​T (ReversibleRange): The type conforming to ReversibleRange.

Args:

  • ​value (T): The range to get the reversed iterator of.

Returns:

The reversed iterator of the range.

reversed[T: CollectionElement](ref [value_is_lifetime] value: List[T, hint_trivial_type]) -> _ListIter[$2, $0, $1, $3, 0]

Get a reversed iterator of the input list.

Note: iterators are currently non-raising.

Parameters:

  • ​T (CollectionElement): The type of the elements in the list.

Args:

  • ​value (List[T, hint_trivial_type]): The list to get the reversed iterator of.

Returns:

The reversed iterator of the list.

reversed[K: KeyElement, V: CollectionElement](ref [value_is_lifetime] value: Dict[K, V]) -> _DictKeyIter[$2, $0, $1, $3, 0]

Get a reversed iterator of the input dict.

Note: iterators are currently non-raising.

Parameters:

  • ​K (KeyElement): The type of the keys in the dict.
  • ​V (CollectionElement): The type of the values in the dict.

Args:

  • ​value (Dict[K, V]): The dict to get the reversed iterator of.

Returns:

The reversed iterator of the dict keys.

reversed[K: KeyElement, V: CollectionElement, dict_mutability: Bool, dict_lifetime: AnyLifetime[$2.value]](ref [value_is_lifetime] value: _DictValueIter[dict_mutability, K, V, dict_lifetime, 1]) -> _DictValueIter[$2, $0, $1, $3, 0]

Get a reversed iterator of the input dict values.

Note: iterators are currently non-raising.

Parameters:

  • ​K (KeyElement): The type of the keys in the dict.
  • ​V (CollectionElement): The type of the values in the dict.
  • ​dict_mutability (Bool): Whether the reference to the dict values is mutable.
  • ​dict_lifetime (AnyLifetime[$2.value]): The lifetime of the dict values.

Args:

  • ​value (_DictValueIter[dict_mutability, K, V, dict_lifetime, 1]): The dict values to get the reversed iterator of.

Returns:

The reversed iterator of the dict values.

reversed[K: KeyElement, V: CollectionElement, dict_mutability: Bool, dict_lifetime: AnyLifetime[$2.value]](ref [value_is_lifetime] value: _DictEntryIter[dict_mutability, K, V, dict_lifetime, 1]) -> _DictEntryIter[$2, $0, $1, $3, 0]

Get a reversed iterator of the input dict items.

Note: iterators are currently non-raising.

Parameters:

  • ​K (KeyElement): The type of the keys in the dict.
  • ​V (CollectionElement): The type of the values in the dict.
  • ​dict_mutability (Bool): Whether the reference to the dict items is mutable.
  • ​dict_lifetime (AnyLifetime[$2.value]): The lifetime of the dict items.

Args:

  • ​value (_DictEntryIter[dict_mutability, K, V, dict_lifetime, 1]): The dict items to get the reversed iterator of.

Returns:

The reversed iterator of the dict items.

Was this page helpful?