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


Python LinkedList.map方法代码示例

本文整理汇总了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
开发者ID:teroqim,项目名称:linkedlist,代码行数:10,代码来源:test_linkedlist.py

示例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
开发者ID:teroqim,项目名称:linkedlist,代码行数:10,代码来源:test_linkedlist.py

示例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
开发者ID:teroqim,项目名称:linkedlist,代码行数:11,代码来源:test_linkedlist.py

示例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
开发者ID:teroqim,项目名称:linkedlist,代码行数:16,代码来源:test_linkedlist.py

示例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)
开发者ID:oelizondo,项目名称:Python_exercises,代码行数:22,代码来源:main.py

示例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
开发者ID:teroqim,项目名称:linkedlist,代码行数:6,代码来源:test_linkedlist.py


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