@@ -12,41 +12,44 @@ def __init__(self, x: int, y: int):
1212
1313 items = [Point (1 , 1 ), Point (2 , 2 ), Point (3 , 3 ), Point (4 , 4 ), Point (5 , 6 ), Point (6 , 6 )]
1414
15- pst = PrioritySearchSet (key_func = lambda v : v .x , priority_func = lambda v : v .y , iterable = items )
16- assert_rb_tree (pst ._pst ._root )
15+ pss = PrioritySearchSet (key_func = lambda v : v .x , priority_func = lambda v : v .y , iterable = items )
16+ assert_rb_tree (pss ._pst ._root )
1717
18- assert pst .query (Point (1 , 1 ), Point (2 , 2 ), Point (2 , 2 )) == [items [1 ]]
19- assert pst .query (Point (1 , 1 ), Point (5 , 1 ), Point (1 , 6 )) == [items [4 ]]
20- assert pst .sorted_query (Point (1 , 1 ), Point (6 , 1 ), Point (1 , 6 )) == [items [5 ], items [4 ]]
21- assert pst .sorted_query (Point (1 , 1 ), Point (4 , 1 ), Point (1 , 1 ), items_limit = 1 ) == [items [3 ]]
18+ assert pss .query (Point (1 , 1 ), Point (2 , 2 ), Point (2 , 2 )) == [items [1 ]]
19+ assert pss .query (Point (1 , 1 ), Point (5 , 1 ), Point (1 , 6 )) == [items [4 ]]
20+ assert pss .sorted_query (Point (1 , 1 ), Point (6 , 1 ), Point (1 , 6 )) == [items [5 ], items [4 ]]
21+ assert pss .sorted_query (Point (1 , 1 ), Point (4 , 1 ), Point (1 , 1 ), items_limit = 1 ) == [items [3 ]]
2222
23- assert items [2 ] in pst
24- assert Point (10 , 10 ) not in pst
25- assert Point (2 , 10 ) in pst
23+ assert items [2 ] in pss
24+ assert Point (10 , 10 ) not in pss
25+ assert Point (2 , 10 ) in pss
2626
27- pst .remove (items [2 ])
28- pst .remove (Point (2 , 10 ))
29- pst .discard (Point (4 , 1 ))
30- pst .discard (Point (4 , 1 ))
27+ pss .remove (items [2 ])
28+ pss .remove (Point (2 , 10 ))
29+ pss .discard (Point (4 , 1 ))
30+ pss .discard (Point (4 , 1 ))
3131
3232 with pytest .raises (KeyError , match = "Key not found:" ):
33- pst .remove (Point (7 , 1 ))
33+ pss .remove (Point (7 , 1 ))
3434
3535 with pytest .raises (KeyError , match = "Key not found:" ):
36- pst .remove (Point (7 , 7 ))
36+ pss .remove (Point (7 , 7 ))
3737
38- assert_rb_tree (pst ._pst ._root )
38+ assert_rb_tree (pss ._pst ._root )
3939
40- assert pst .get_with_max_priority ().y == 6
40+ assert pss .get_with_max_priority ().y == 6
4141
42- assert pst .pop ().y == 6
43- assert pst .pop ().y == 6
44- assert pst .pop ().y == 1
42+ assert pss .pop ().y == 6
43+ assert pss .pop ().y == 6
44+ assert pss .pop ().y == 1
4545
46- assert not pst
46+ assert not pss
4747
48- pst = PrioritySearchSet (key_func = lambda v : v .x , priority_func = lambda v : v .y )
49- pst .add (Point (1 , 1 ))
50- assert len (pst ) == 1
51- pst .clear ()
52- assert not pst
48+ pss = PrioritySearchSet (key_func = lambda v : v .x , priority_func = lambda v : v .y )
49+ pss .add (Point (1 , 4 ))
50+ assert len (pss ) == 1
51+ for p in pss :
52+ assert p .x == 1
53+ assert p .y == 4
54+ pss .clear ()
55+ assert not pss
0 commit comments