class_docstr: Queue with Binary Indexed Tree cache
  
  queue-like data structure
  append, update are O(log n)
  reduction over an interval is O(log n) per query
class_docstr_tok: ["Queue","with","Binary","Indexed","Tree","cache","queue-like","data","structure","append",",","update","are","O","(","log","n",")","reduction","over","an","interval","is","O","(","log","n",")","per","query"]
code: def popleft(self) -> Optional[V]:
      assert self.length > 0
      ret = self._write(0, None)
      ixl, ixr = self.bounds
      ixl -= 1
      ixr -= 1
      self.length -= 1
      if self.length == 0:
          del self.root
          del self.bounds
          return ret
  
      ixc = (ixl + ixr) // 2
      if ixc == 0:
          ixl = ixc
          _, self.root, _ = self.root
      self.bounds = ixl, ixr
      return ret
  
imports: import collections
  from typing import Any, Callable, Deque, Generic, List, Optional, Sequence, Tuple, TypeVar
  import numpy
  from pfrl.utils.random import sample_n_k
label_desc: Use image node_id 5 for calling the TreeQueue obj's underlying member method code with example usage: obj.popleft() and returns: ret, ret