MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / bulk_insert

Method bulk_insert

data_structures/hashing/hash_table.py:88–131  ·  view source on GitHub ↗

bulk_insert is used for entering more than one element at a time in the HashTable. Examples: 1. >>> ht = HashTable(5) >>> ht.bulk_insert((10,20,30)) step 1 [0, 1, 2, 3, 4] [10, None, None, None, None] step 2 [0

(self, values)

Source from the content-addressed store, hash-verified

86 print(self.values)
87
88 def bulk_insert(self, values):
89 """
90 bulk_insert is used for entering more than one element at a time
91 in the HashTable.
92
93 Examples:
94 1.
95 >>> ht = HashTable(5)
96 >>> ht.bulk_insert((10,20,30))
97 step 1
98 [0, 1, 2, 3, 4]
99 [10, None, None, None, None]
100 step 2
101 [0, 1, 2, 3, 4]
102 [10, 20, None, None, None]
103 step 3
104 [0, 1, 2, 3, 4]
105 [10, 20, 30, None, None]
106
107 2.
108 >>> ht = HashTable(5)
109 >>> ht.bulk_insert([5,4,3,2,1])
110 step 1
111 [0, 1, 2, 3, 4]
112 [5, None, None, None, None]
113 step 2
114 [0, 1, 2, 3, 4]
115 [5, None, None, None, 4]
116 step 3
117 [0, 1, 2, 3, 4]
118 [5, None, None, 3, 4]
119 step 4
120 [0, 1, 2, 3, 4]
121 [5, None, 2, 3, 4]
122 step 5
123 [0, 1, 2, 3, 4]
124 [5, 1, 2, 3, 4]
125 """
126 i = 1
127 self.__aux_list = values
128 for value in values:
129 self.insert_data(value)
130 self._step_by_step(i)
131 i += 1
132
133 def _set_value(self, key, data):
134 """

Callers

nothing calls this directly

Calls 2

insert_dataMethod · 0.95
_step_by_stepMethod · 0.95

Tested by

no test coverage detected