本文整理汇总了Python中linkedlist.LinkedList.map方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.map方法的具体用法?Python LinkedList.map怎么用?Python LinkedList.map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linkedlist.LinkedList
的用法示例。
在下文中一共展示了LinkedList.map方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_map_creates_new_items
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import map [as 别名]
def test_map_creates_new_items(self):
ll = LinkedList()
item1 = ll.add_to_front(12, 3534536)
ll2 = ll.map(None)
item2 = ll2.front
assert item1 != item2
assert item1.key == item2.key
assert item2.value == item2.value
示例2: test_map_None_equal_to_identity
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import map [as 别名]
def test_map_None_equal_to_identity(self):
ll = LinkedList()
item1 = ll.add_to_front(123, 8907067)
ll2 = ll.map(None)
item2 = ll2.front
assert item1.key == item2.key
assert item1.value == item2.value
assert ll.length == ll2.length
示例3: test_map_preserves_front_and_back
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import map [as 别名]
def test_map_preserves_front_and_back(self):
ll = LinkedList()
ll.add_to_front(123, 123123)
ll.add_to_front(234234, 92834923)
ll2 = ll.map(None)
assert ll.front.key == ll2.front.key
assert ll.front.value == ll2.front.value
assert ll.back.key == ll2.back.key
assert ll.back.value == ll2.back.value
示例4: test_map_applies_func_to_all_keys_and_values
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import map [as 别名]
def test_map_applies_func_to_all_keys_and_values(self):
ll = LinkedList()
item1 = ll.add_to_front(123, 345)
item2 = ll.add_to_front("", 2345)
item3 = ll.add_to_front([1,2,3], 234)
ll2 = ll.map(lambda x, y: (x, False))
ll_current = ll.front
ll2_current = ll2.front
assert ll.length == ll2.length and ll.length == 3
while ll_current:
assert ll_current.key == ll2_current.key
assert ll2_current.value == False
ll_current = ll_current.next
ll2_current = ll2_current.next
示例5: LinkedList
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import map [as 别名]
from linkedlist import LinkedList
myLL = LinkedList()
myLL.add(10)
myLL.add(11)
myLL.add(12)
myLL.add(13)
myLL.erase(10)
myLL.add(14)
myLL.add(15)
# myLL.invert()
myLL.print_list()
square = lambda x: x * x
myLL.map(square)
# myLL.print_list()
print(myLL.selfie())
print(myLL.reduce("+"))
print(myLL.reduce("*"))
print(myLL.length)
示例6: test_map_creates_new_list
# 需要导入模块: from linkedlist import LinkedList [as 别名]
# 或者: from linkedlist.LinkedList import map [as 别名]
def test_map_creates_new_list(self):
ll = LinkedList()
ll2 = ll.map(None)
assert ll != ll2