当前位置: 首页>>代码示例>>Python>>正文


Python LinkedList.get方法代码示例

本文整理汇总了Python中LinkedList.get方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.get方法的具体用法?Python LinkedList.get怎么用?Python LinkedList.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinkedList的用法示例。


在下文中一共展示了LinkedList.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_when_adding_several_items_should_be_able_to_get_last_node_by_index

# 需要导入模块: import LinkedList [as 别名]
# 或者: from LinkedList import get [as 别名]
 def test_when_adding_several_items_should_be_able_to_get_last_node_by_index(self):
     linked_list = LinkedList()
     linked_list.add('test item 0')
     linked_list.add('test item 1')
     linked_list.add('test item 2')
     linked_list.add('test item 3')
     last_node = linked_list.get(3)
     self.assertEqual(last_node.value, 'test item 3')
开发者ID:Restuta,项目名称:LinkedListTests,代码行数:10,代码来源:LinkedListTests.py

示例2: test_when_adding_second_element_previous_one_should_point_to_it

# 需要导入模块: import LinkedList [as 别名]
# 或者: from LinkedList import get [as 别名]
    def test_when_adding_second_element_previous_one_should_point_to_it(self):
        linked_list = LinkedList()
        linked_list.add('test item 0')
        first_node = linked_list.get(0)

        linked_list.add('test item 1')

        self.assertEqual(first_node.next_node, linked_list.get_last())
开发者ID:Restuta,项目名称:LinkedListTests,代码行数:10,代码来源:LinkedListTests.py

示例3: test_when_there_are_two_items_added_to_list_that_point_to_each_other_should_report_it_as_a_cycle

# 需要导入模块: import LinkedList [as 别名]
# 或者: from LinkedList import get [as 别名]
    def test_when_there_are_two_items_added_to_list_that_point_to_each_other_should_report_it_as_a_cycle(self):
        linked_list = LinkedList()
        linked_list.add('test item 0')
        linked_list.add('test item 1')
        node0 = linked_list.get(0)
        node1 = linked_list.get(1)
        node1.next_node = node0

        self.assertTrue(linked_list.has_loop())
开发者ID:Restuta,项目名称:LinkedListTests,代码行数:11,代码来源:LinkedListTests.py

示例4: test_when_there_is_a_loop_in_the_middle_of_the_list_should_be_able_to_report_it

# 需要导入模块: import LinkedList [as 别名]
# 或者: from LinkedList import get [as 别名]
    def test_when_there_is_a_loop_in_the_middle_of_the_list_should_be_able_to_report_it(self):
        linked_list = LinkedList()
        linked_list.add('test item 0')
        linked_list.add('test item 1')
        linked_list.add('test item 2')
        linked_list.add('test item 3')
        linked_list.add('test item 4')

        node1 = linked_list.get(1)
        node3 = linked_list.get(3)
        node3.next_node = node1

        self.assertTrue(linked_list.has_loop())
开发者ID:Restuta,项目名称:LinkedListTests,代码行数:15,代码来源:LinkedListTests.py

示例5: HashTable

# 需要导入模块: import LinkedList [as 别名]
# 或者: from LinkedList import get [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()
开发者ID:SaadTalaat,项目名称:Algorithms-bag,代码行数:53,代码来源:HashTable.py


注:本文中的LinkedList.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。