當前位置: 首頁>>代碼示例>>Python>>正文


Python LinkedList.remove方法代碼示例

本文整理匯總了Python中LinkedList.LinkedList.remove方法的典型用法代碼示例。如果您正苦於以下問題:Python LinkedList.remove方法的具體用法?Python LinkedList.remove怎麽用?Python LinkedList.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LinkedList.LinkedList的用法示例。


在下文中一共展示了LinkedList.remove方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testRemove

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import remove [as 別名]
def testRemove():
	my_linked_list = LinkedList()

	for i in range(0, 10):
		my_linked_list.append(i)

	for i in range(0, 10):
		print "removing " + str(i)
		my_linked_list.remove(i)
		print my_linked_list
開發者ID:WillYee,項目名稱:LinkedListDemo,代碼行數:12,代碼來源:LinkedListTest.py

示例2: test_remove

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import remove [as 別名]
    def test_remove(self):
        # test empty list
        myLinkedList = LinkedList()
        self.assertRaises(ValueError, myLinkedList.remove, 5)

        # test node not in linked list
        myLinkedList = self.getLinkedList()
        self.assertRaises(ValueError, myLinkedList.remove, 11)

        # test successful removal
        myLinkedList.remove(5)
        self.assertFalse(myLinkedList.search(5))
開發者ID:avihoo,項目名稱:singly-linked-list,代碼行數:14,代碼來源:TestLinkedList.py

示例3: main

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import remove [as 別名]
def main():
	# comparator that is passed into the LinkedList
	def comparator(value_one, value_two):
		if value_one == value_two:
			return 0
		elif value_one > value_two:
			return 1
		else:
			return -1

	test_one = LinkedList(comparator)
	test_two = LinkedList(comparator)
	test_three = LinkedList(comparator)

	test_one.insert(2)
	test_one.insert(3)
	test_one.insert(1)

	test_two.insert(5)

	test_three.insert(10)
	test_three.insert(20)
	test_three.insert(30)
	test_three.insert(40)
	test_three.insert(50)

	print("Test one: ")
	test_one.print()

	print("\nTest two: ")
	test_two.print()

	print("\nTest three: ")
	test_three.print()

	test_one.remove(2)
	test_one.remove(6)

	test_two.remove(5)

	test_three.remove(10)
	test_three.remove(50)

	print("\nTest one after removals: ")
	test_one.print()

	print("\nTest two after removals: ")
	test_two.print()

	print("\nTest three after removals: ")
	test_three.print()
開發者ID:hspearman,項目名稱:LinkedList,代碼行數:53,代碼來源:Test.py

示例4: list

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import remove [as 別名]
# Verify book was pushed to front of list
print "Pushed Book"
print "--------------------------------------------------"
print books.get(0).toString()

# Add book at index
books.addAtIndex(3, angelsAndDemons);

# Verify book was added to correct index
print "Set of Books"
print "--------------------------------------------------"
print books.toString()

# Remove first book from list (Digital Fortress)
books.remove(0)

# Verify book was removed
print "First Book"
print "--------------------------------------------------"
print books.get(0).toString()

# Delete 3rd book (Angels and Demons)
books.remove(2)

# Verify book was removed
print "Set of Books"
print "--------------------------------------------------"
print books.toString()

# Delete last book (The Martian)
開發者ID:bpred754,項目名稱:AlgorithmsAndDataStructures,代碼行數:32,代碼來源:Driver.py

示例5: print

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import remove [as 別名]
# -*- coding: utf-8 -*-

"""
App.py:
"""
from LinkedList import LinkedList
print("Start")
LinkedList = LinkedList()

LinkedList.insertEnd(12)
LinkedList.insertEnd(122)
LinkedList.insertEnd(3)
LinkedList.insertStart(31)

LinkedList.traverseList()

LinkedList.remove(12)

LinkedList.traverseList()
print("End")




開發者ID:cogfor,項目名稱:AlgorithmsAndDatastructuresPython,代碼行數:22,代碼來源:App.py

示例6: comment

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import remove [as 別名]
        comment("FAIL -> " + test_name +"\n moveHead() debe lanzar una excepcion de tipo IndexError cuando la lista esta vacia")
        grade(0)
except:
    e = sys.exc_info()[1]
    comment("FAIL -> " + test_name + "\n" + str(e))
    grade(0)


# Check empty list - remove


try:
    test_name = 'LinkedList vacia: remove()'
    l = LinkedList()
    try:
        l.remove()
        comment("FAIL -> " + test_name +"\n remove() debe lanzar una excepcion de tipo IndexError cuando la lista esta vacia")
    except IndexError:
        comment("OK -> " + test_name)
        grade(points['ll_vacia_remove'])
    except:
        e = sys.exc_info()[1]
        comment("FAIL -> " + test_name +"\n remove() debe lanzar una excepcion de tipo IndexError cuando la lista esta vacia")
        grade(0)
except:
    e = sys.exc_info()[1]
    comment("FAIL -> " + test_name + "\n" + str(e))
    grade(0)

# Check empty list - isEmpty
開發者ID:emiliogq,項目名稱:pyrobot,代碼行數:32,代碼來源:joc_proves_LinkedList.py

示例7: LinkedList

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import remove [as 別名]
from LinkedList import LinkedList

linkedList = LinkedList()

linkedList.insertAtEnd(12)
linkedList.insertAtEnd(122)
linkedList.insertAtEnd(3)
linkedList.insertAtStart(31)

linkedList.traverseList()

linkedList.remove(122)

linkedList.traverseList()
開發者ID:harihpr,項目名稱:Data-structures-and-Algorithms,代碼行數:16,代碼來源:testLL.py

示例8: LinkedList

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import remove [as 別名]
from LinkedList import LinkedList

# Test cases for LinkedList
linklist = LinkedList()
linklist2 = LinkedList()
linklist.add(1)
print(linklist.__str__())
linklist.add(2)
print(linklist.__str__())
linklist.add(3)
print(linklist.__str__())
linklist.add(4)
print(linklist.__str__())
linklist.remove(2)
print(linklist.__str__())
linklist.remove(1)
linklist.remove(6)
print(linklist.contains(1))
print(linklist.__str__())
print(linklist.size)
開發者ID:NateRiehl,項目名稱:Python-Data-Structures,代碼行數:22,代碼來源:TestLinkedList.py


注:本文中的LinkedList.LinkedList.remove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。