<commit_before>__author__ = 'Andrea'

import time

from Heap.HeapNode import HeapNode

class DHeap:

    def __init__(self, d):
        self.d = d
        self.heap = []

    def get_min(self):
        if not self.is_empty():
            return self.heap[0].elem
        else:
            return None

    def is_empty(self):
        if len(self.heap) == 0:
            return True
        return False

    def delete(self, node):
        if len(self.heap) == 0:
            return
        node_to_delete = self.heap[node.index]
        node_leaf = self.heap[- 1]
        self.swap_node(node_to_delete, node_leaf)
        del self.heap[-1]
        self.move_up(node_leaf)
        self.move_down(node_leaf)

    def delete_min(self):
        if len(self.heap) == 0:
            return
        node_to_delete = self.heap[0]
        node_leaf = self.heap[- 1]
        self.swap_node(node_to_delete, node_leaf)
        del self.heap[-1]
        self.move_down(node_leaf)

    def insert(self, elem, key):
        new_node = HeapNode(elem, key, len(self.heap))
        self.heap.append(new_node)
        self.move_up(new_node)

    def get_min_son(self, node):
        # Son law: d*(index)+{1,...,d}
        count = 1
        min_son = HeapNode(None, float('inf'), None)
        while count <= self.d:
            son_index = (self.d*node.index)+count
            if son_index >= len(self.heap):
                break<commit_msg>Added return on delete_min method<commit_after>__author__ = 'Andrea'

import time

from Heap.HeapNode import HeapNode

class DHeap:

    def __init__(self, d):
        self.d = d
        self.heap = []

    def get_min(self):
        if not self.is_empty():
            return self.heap[0].elem
        else:
            return None

    def is_empty(self):
        if len(self.heap) == 0:
            return True
        return False

    # def delete(self, node):
    #    if len(self.heap) == 0:
    #        return None
    #    node_to_delete = self.heap[node.index]
    #    node_leaf = self.heap[- 1]
    #    self.swap_node(node_to_delete, node_leaf)
    #    del self.heap[-1]
    #    self.move_up(node_leaf)
    #    self.move_down(node_leaf)

    def delete_min(self):
        if len(self.heap) == 0:
            return None
        node_to_delete = self.heap[0]
        node_leaf = self.heap[- 1]
        self.swap_node(node_to_delete, node_leaf)
        del self.heap[-1]
        self.move_down(node_leaf)
        return node_to_delete

    def insert(self, elem, key):
        new_node = HeapNode(elem, key, len(self.heap))
        self.heap.append(new_node)
        self.move_up(new_node)

    def get_min_son(self, node):
        # Son law: d*(index)+{1,...,d}
        count = 1
        min_son = HeapNode(None, float('inf'), None)
        while count <= self.d:
            son_index = (self.d*node.index)+count
            if son_index >= len(self.heap):
                break
{'fraction_non_alphanumeric': 0.11678082191780823, 'fraction_numerical': 0.007534246575342466, 'mean_word_length': 1.875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5848400', 'n_tokens_mistral': 998, 'n_tokens_neox': 971, 'n_words': 207}