def deletemin(self): old_head = self.head to_merge = ydeque(backend=self.nodes, iterable=takepairs(self.__getchildren(old_head))) to_merge_final = ydeque(backend=self.nodes) for first, second in to_merge: if second is None: to_merge_final.append(first) continue to_merge_final.append(self.__link(first, second)) #TODO: implement __reversed__ for sqlitedeque new_head = None for item in reversed(to_merge_final): new_head = self.__link(item, new_head) # Replace self.head self.head = new_head del self.nodes[old_head] if new_head is not None: self.nodes[self.head][PARENT] = None return old_head
def test_construct_from_iterable(): backend = BackendSQLite() q = yaupon.ydeque(backend, [1, 2, 3, 4]) assert [x for x in q] == [1, 2, 3, 4] q = yaupon.ydeque(backend, (1, 2, 3, 4)) assert [x for x in q] == [1, 2, 3, 4]