Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class HashMap:
- keyList = []
- valueList = []
- # if i want to add parameters etc def __init__():
- # Returns the index of the key.
- def getIndex(key):
- index = 0;
- for i in HashMap.keyList:
- if (HashMap.keyList[index] == key):
- return index
- index+=1
- return -1
- # Adds entrys into the lists.
- def addEntry(key,value):
- HashMap.keyList.append(key)
- HashMap.valueList.append(value)
- # Returns a boolean if it has removed the key and the value
- def removeEntry(key):
- index = HashMap.getIndex(key)
- if (index !=-1):
- HashMap.keyList.pop(index)
- HashMap.valueList.pop(index)
- return True
- return False
- # Returns the valuelist index of the key
- def getValue(key):
- index = HashMap.getIndex(key)
- if (index !=-1):
- return HashMap.valueList[index]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement