Skip to content

Commit

Permalink
Add compare meths for queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Krispeckt committed Sep 13, 2024
1 parent 02d6e7c commit 219f825
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions harmonize/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ class Queue:
Checks if two filters are not the same.
.. desribe:: x >= y
Checks if the first queue is greater or equal to the second queue.
.. describe:: x <= y
Checks if the first queue is less than or equal to the second queue.
.. describe:: x > y
Checks if the first queue is greater than the second queue.
.. describe:: x < y
Checks if the first queue is less than the second queue.
.. describe:: for y in x
Returns an iterator over the tracks in the queue.
Expand Down Expand Up @@ -257,3 +273,27 @@ def __hash__(self) -> int:

def __str__(self) -> str:
return str(self._now)

def __le__(self, other: int | Queue) -> bool:
if isinstance(other, Queue):
return len(self) <= len(other)

return self.__lt__(other) or len(self) == other

def __lt__(self, other: int | Queue) -> bool:
if isinstance(other, Queue):
return len(self) < len(other)

return len(self) < other

def __ge__(self, other: int | Queue) -> bool:
if isinstance(other, Queue):
return len(self) >= len(other)

return self.__gt__(other) or len(self) == other

def __gt__(self, other: int | Queue) -> bool:
if isinstance(other, Queue):
return len(self) > len(other)

return len(self) > other

0 comments on commit 219f825

Please # to comment.