File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -561,6 +561,50 @@ def where(self, value):
561
561
"""
562
562
return np .where (self .deque == value )[0 ]
563
563
564
+ def index (self , value , start = 0 , stop = None ):
565
+ """
566
+ Return the deque index of value (at or after index start and before index stop).
567
+ Returns the first match
568
+
569
+ Parameters:
570
+ value: The value to search for.
571
+
572
+ Returns:
573
+ int: The the first index that value is found at.
574
+
575
+ """
576
+ p = self .where (value )
577
+ if len (p ) > 0 :
578
+ if stop is None :
579
+ stop = self .size
580
+ for i in p :
581
+ if start <= i < stop :
582
+ return i
583
+ return None
584
+
585
+ def remove (self , value ):
586
+ """
587
+ Remove the first occurrence of value.
588
+
589
+ Parameters:
590
+ value: The value to search for.
591
+ """
592
+ i = self .index (value )
593
+ if i is not None :
594
+ self .drop (i )
595
+
596
+ def count (self , value ):
597
+ """
598
+ Count the number of deque elements equal to value.
599
+
600
+ Parameters:
601
+ value: The value that is being counted.
602
+
603
+ Returns:
604
+ int: The count.
605
+ """
606
+ return np .count_nonzero (self .deque == value )
607
+
564
608
def __getitem__ (self , index ):
565
609
return self .queue [index ]
566
610
You can’t perform that action at this time.
0 commit comments