mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-22 05:16:39 +08:00
Various ruff fixes (#12821)
This commit is contained in:
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from abc import abstractmethod
|
||||
from collections.abc import Iterable
|
||||
from typing import Generic, Protocol, TypeVar
|
||||
from typing import Protocol, TypeVar
|
||||
|
||||
|
||||
class Comparable(Protocol):
|
||||
@ -22,7 +22,7 @@ class Comparable(Protocol):
|
||||
T = TypeVar("T", bound=Comparable)
|
||||
|
||||
|
||||
class Heap(Generic[T]):
|
||||
class Heap[T: Comparable]:
|
||||
"""A Max Heap Implementation
|
||||
|
||||
>>> unsorted = [103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5]
|
||||
|
@ -4,12 +4,12 @@ from __future__ import annotations
|
||||
|
||||
import random
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, Generic, TypeVar
|
||||
from typing import Any, TypeVar
|
||||
|
||||
T = TypeVar("T", bound=bool)
|
||||
|
||||
|
||||
class RandomizedHeapNode(Generic[T]):
|
||||
class RandomizedHeapNode[T: bool]:
|
||||
"""
|
||||
One node of the randomized heap. Contains the value and references to
|
||||
two children.
|
||||
@ -73,7 +73,7 @@ class RandomizedHeapNode(Generic[T]):
|
||||
return root1
|
||||
|
||||
|
||||
class RandomizedHeap(Generic[T]):
|
||||
class RandomizedHeap[T: bool]:
|
||||
"""
|
||||
A data structure that allows inserting a new value and to pop the smallest
|
||||
values. Both operations take O(logN) time where N is the size of the
|
||||
|
@ -3,12 +3,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable, Iterator
|
||||
from typing import Any, Generic, TypeVar
|
||||
from typing import Any, TypeVar
|
||||
|
||||
T = TypeVar("T", bound=bool)
|
||||
|
||||
|
||||
class SkewNode(Generic[T]):
|
||||
class SkewNode[T: bool]:
|
||||
"""
|
||||
One node of the skew heap. Contains the value and references to
|
||||
two children.
|
||||
@ -87,7 +87,7 @@ class SkewNode(Generic[T]):
|
||||
return result
|
||||
|
||||
|
||||
class SkewHeap(Generic[T]):
|
||||
class SkewHeap[T: bool]:
|
||||
"""
|
||||
A data structure that allows inserting a new value and to pop the smallest
|
||||
values. Both operations take O(logN) time where N is the size of the
|
||||
|
Reference in New Issue
Block a user