Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Add FrozenBitset.__reversed__
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorkarn committed Jun 20, 2022
1 parent a6e696e commit d4f3d86
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sage/data_structures/bitset.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,19 @@ cdef class FrozenBitset:
"""
return iter(bitset_list(self._bitset))

def __reversed__(self):
"""
Return an iterator over ``self``, starting with the largest element.
EXAMPLES::
sage: list(reversed(FrozenBitset('11011')))
[4, 3, 1, 0]
sage: list(reversed(FrozenBitset('00001' * 20)))
[99, 94, 89, 84, 79, 74, 69, 64, 59, 54, 49, 44, 39, 34, 29, 24, 19, 14, 9, 4]
"""
return reversed(bitset_list(self._bitset))

cpdef FrozenBitset _larger_capacity_(self, long capacity):
"""
Return a copy of ``self`` where the bitset has the maximum of the
Expand Down

0 comments on commit d4f3d86

Please sign in to comment.