本文整理汇总了Python中linkedlist.LinkedList.in_filter方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.in_filter方法的具体用法?Python LinkedList.in_filter怎么用?Python LinkedList.in_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linkedlist.LinkedList
的用法示例。
在下文中一共展示了LinkedList.in_filter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_in_filter_preserves_front_and_back_if_needed
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import in_filter [as 别名]
def test_in_filter_preserves_front_and_back_if_needed(self):
ll = LinkedList()
item1 = ll.add_to_front(123, 123123)
item2 = ll.add_to_front(234234, 92834923)
ll.in_filter(None)
assert ll.front == item2
assert ll.back == item1
示例2: test_in_filter_None_equal_to_identity
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import in_filter [as 别名]
def test_in_filter_None_equal_to_identity(self):
ll = LinkedList()
item1 = ll.add_to_front(123, 8907067)
ll.in_filter(None)
assert item1.key == ll.front.key
assert item1.value == ll.front.value
assert ll.length == 1
示例3: test_in_filter_remove_all
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import in_filter [as 别名]
def test_in_filter_remove_all(self):
ll = LinkedList()
item1 = ll.add_to_front(123, 345)
item2 = ll.add_to_front(51515, 15151551)
item3 = ll.add_to_front(987, 234267)
assert ll.length == 3
ll.in_filter(lambda x,y: False)
assert ll.length == 0
示例4: test_in_filter_remove_selective
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import in_filter [as 别名]
def test_in_filter_remove_selective(self):
ll = LinkedList()
item1 = ll.add_to_back(1, 345)
item2 = ll.add_to_back(5, 15151551)
item3 = ll.add_to_back(7, 234267)
item4 = ll.add_to_back(1, 907525)
item5 = ll.add_to_back(7, 789235)
ll.in_filter(lambda x,y: x==1)
assert ll.length == 2
assert ll.front == item1
assert ll.back == item4
示例5: test_in_filter_applies_func_to_all_items
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import in_filter [as 别名]
def test_in_filter_applies_func_to_all_items(self):
ll = LinkedList()
items = [ll.add_to_back(123, 345),
ll.add_to_back("", 2345),
ll.add_to_back([1,2,3], 234)]
ll.in_filter(lambda x, y: True)
ll_current = ll.front
assert ll.length == 3
i = 0
while ll_current:
assert ll_current == items[i]
ll_current = ll_current.next
i += 1