本文整理汇总了Python中LinkedList.getElement方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.getElement方法的具体用法?Python LinkedList.getElement怎么用?Python LinkedList.getElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList
的用法示例。
在下文中一共展示了LinkedList.getElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HashTable
# 需要导入模块: import LinkedList [as 别名]
# 或者: from LinkedList import getElement [as 别名]
class HashTable():
buckets = 0
hash_func = None
match_func = None
destroy_fun = None
size = 0
table = None
def __init__(self,bucks, hasher, matcher,destroy):
self.buckets = bucks
self.hash_func = hasher
self.match_func = matcher
self.destroy_func = destroy
self.table = LinkedList();
for i in range(0, self.buckets):
self.table.attach(LinkedList())
return
def Table_destroy(self):
for i in range(0,self.buckets):
self.destroy(self.table.getElement())
self.table = None
return
def Table_insert(self, value):
to_insert = value
x = self.Table_lookup(to_insert)
if x == 0:
return 1
bucket = self.hash_func(value) % self.buckets
self.table.get(bucket).attach(value)
return
def Table_remove(self, value):
bucket = self.hash_func(value) % self.buckets
self.table.get(bucket).delete(value)
return
def Table_lookup(self, value):
bucket = self.hash_func(value) % self.buckets
print "Bucket", bucket
if not (self.table.get(bucket).isEmpty()):
x = self.table.get(bucket).getvalue()
else:
return 1
return 1
def Table_size(self):
return self.table.size()