parameters: (self, item)
return_statement: return item
docstring: Inserts 'item' into the shuffle buffer, returning
              a random item.
  
              If the buffer is not yet full, returns None
docstring_summary: Inserts 'item' into the shuffle buffer, returning
              a random item.
docstring_tokens: Inserts item into the shuffle buffer returning a random item .
function: def insert_or_replace(self, item):
          """
              Inserts 'item' into the shuffle buffer, returning
              a random item.
  
              If the buffer is not yet full, returns None
          """
          assert len(item) == self.elem_size, len(item)
          # putting the new item in a random location, and appending
          # the displaced item to the end of the buffer achieves a full
          # random shuffle (Fisher-Yates)
          if self.used > 0:
              # swap 'item' with random item in buffer.
              i = random.randint(0, self.used-1)
              old_item = self.buffer[i * self.elem_size : (i+1) * self.elem_size]
              self.buffer[i * self.elem_size : (i+1) * self.elem_size] = item
              item = old_item
          # If the buffer isn't yet full, append 'item' to the end of the buffer.
          if self.used < self.elem_count:
              # Not yet full, so place the returned item at the end of the buffer.
              i = self.used
              self.buffer[i * self.elem_size : (i+1) * self.elem_size] = item
              self.used += 1
              return None
          return item
function_tokens: def insert_or_replace ( self , item ) : assert len ( item ) == self . elem_size , len ( item ) # putting the new item in a random location, and appending # the displaced item to the end of the buffer achieves a full # random shuffle (Fisher-Yates) if self . used > 0 : # swap 'item' with random item in buffer. i = random . randint ( 0 , self . used - 1 ) old_item = self . buffer [ i * self . elem_size : ( i + 1 ) * self . elem_size ] self . buffer [ i * self . elem_size : ( i + 1 ) * self . elem_size ] = item item = old_item # If the buffer isn't yet full, append 'item' to the end of the buffer. if self . used < self . elem_count : # Not yet full, so place the returned item at the end of the buffer. i = self . used self . buffer [ i * self . elem_size : ( i + 1 ) * self . elem_size ] = item self . used += 1 return None return item