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

Method _is_sparse

data_structures/hashing/hash_map.py:107–112  ·  view source on GitHub ↗

Return true if we need twice fewer buckets when we have now.

(self)

Source from the content-addressed store, hash-verified

105 return len(self) >= int(limit)
106
107 def _is_sparse(self) -> bool:
108 """Return true if we need twice fewer buckets when we have now."""
109 if len(self._buckets) <= self._initial_block_size:
110 return False
111 limit = len(self._buckets) * self._capacity_factor / 2
112 return len(self) < limit
113
114 def _resize(self, new_size: int) -> None:
115 old_buckets = self._buckets

Callers 1

__delitem__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected