Skip to content

Instantly share code, notes, and snippets.

View AdamGold's full-sized avatar
🌏
Trust the process

Adam Goldschmidt AdamGold

🌏
Trust the process
  • Israel
View GitHub Profile
{
"definitions": {
"<script>alert(1)</script>": {
"type": "object"
},
"Feedback": {
"properties": {
"feedback": {
"type": "integer"
}
{
"definitions": {
"Device": {
"type": "object"
},
"Feedback": {
"properties": {
"feedback": {
"type": "integer"
}
def __getitem__(self, key: str) -> Entry:
"""subscript method - object[key]
use hashing function to find the index"""
entry = Entry(key)
index = entry.hash % self.actual_size
found = self.entries[index]
if found == None:
raise KeyError
return found
def __setitem__(self, key: str, value: Any) -> int:
"""allow insertion of items with object[key] = value"""
entry = Entry(key, value)
index = entry.hash % self.actual_size
self.entries[index] = entry
return index
def __init__(self, size=10):
self.entries = [None for _ in range(size * 2)]
self.size = size
self.actual_size = size * 2
self.filled_entries = 0
def __setitem__(self, key: str, value: Any) -> int:
"""allow insertion of items with object[key] = value"""
if self.filled_entries == self.size:
# no more room
table = HashTable()
names = [
"Eden Marriott",
"Sebastian Frame",
"Cassia Hicks",
"Bert Blankenship",
"Clarence Hughes",
"Clay Burch",
"Linda Holmes",
"Felix Galloway",
found = 0
for num in int_array:
if num in d:
found += 1
int_array = array.array("i", range(10 ** 5))
d = dict.fromkeys(int_array, None)
l = list(range(10 ** 5))
class Entry(object):
def __init__(self, key: str, value=None):
self.key = key
self.value = value
@property
def hash(self) -> int:
"""return entry's hash"""
return len(self.key)
@property
def hash(self) -> int:
"""return entry's hash"""
return len(self.key)