本文整理汇总了Python中linkedlist.LinkedList.search方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.search方法的具体用法?Python LinkedList.search怎么用?Python LinkedList.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linkedlist.LinkedList
的用法示例。
在下文中一共展示了LinkedList.search方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import search [as 别名]
def main():
#Create list of names
listOfNames = { "Tom", "Harry","Susan","Ethan","Willy","Shaina"}
#Create linkedlist object
testinglist = LinkedList()
#Test insertion method
for name in listOfNames:
testinglist.insert(name)
#Test size of list
print testinglist.size()
#Test print list
testinglist.printList()
#Test Deletion of head node
testinglist.delete("Tom")
#Test Deletion method:
testinglist.delete("Susan")
testinglist.printList()
#Test search list
testinglist.search("Willy")
示例2: test_searchNone
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import search [as 别名]
def test_searchNone():
l_list = LinkedList()
l_list.insert("Jacob")
l_list.insert("Pallymay")
# make sure reg search works
found = l_list.search("Jacob")
assert found.get_data() == "Jacob"
with pytest.raises(ValueError):
l_list.search("Vincent")
示例3: test_positive_search
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import search [as 别名]
def test_positive_search():
l_list = LinkedList()
l_list.insert("Jacob")
l_list.insert("Pallymay")
l_list.insert("Rasmus")
found = l_list.search("Jacob")
assert found.get_data() == "Jacob"
found = l_list.search("Pallymay")
assert found.get_data() == "Pallymay"
found = l_list.search("Jacob")
assert found.get_data() == "Jacob"
示例4: test_corrupt_loop
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import search [as 别名]
def test_corrupt_loop():
l_list = LinkedList()
l_list.insert('E')
l_list.insert('D')
l_list.insert('C')
l_list.insert('B')
l_list.insert('A')
print l_list
node1 = l_list.search('E')
node2 = l_list.search('C')
node1.set_next(node2)
node = l_list.corrupt_loop()
print node
示例5:
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import search [as 别名]
n=n+1
if((j!=(l1-1))&(i!=(l2-1))):
f2=maxSim(list1[j+1],list2[i+1])
n=n+1
num2=num2+((1.0+f1+f2)/n)*idf(list2[i])"""
num2=num2+idf(list2[i])
j=j+1
i=i+1
count=0
sim=0.5*((num1/deno1)+(num2/deno2))
if(sim>.7): #why .7 ---- Jaccard's
l.add(stok1[0],pos_count)
pos_count=pos_count+1
l.addsen(stok1[1],pos_count,l.search(stok1[0]))
pos_count=pos_count+1
count=1
#print(l.head.child.data)
else:#two clusters
l.add(stok1[0],pos_count)
pos_count=pos_count+1
l.add(stok1[1],pos_count)
pos_count=pos_count+1
count=2
#print(l.head.child.data)
#print(l.head.next.child.data)
#print("aaaaa\n")
#print(l.head.child.data)