• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pyllist.dllist函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyllist.dllist函数的典型用法代码示例。如果您正苦于以下问题:Python dllist函数的具体用法?Python dllist怎么用?Python dllist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_node_str

 def test_node_str(self):
     a = dllist([None, None]).first
     self.assertEqual(str(a), "dllistnode(None)")
     b = dllist([1, None]).first
     self.assertEqual(str(b), "dllistnode(1)")
     c = dllist(["abc", None]).first
     self.assertEqual(str(c), "dllistnode(abc)")
开发者ID:pombredanne,项目名称:pypy-llist,代码行数:7,代码来源:test_pyllist.py


示例2: test_node_repr

 def test_node_repr(self):
     a = dllist([None]).first
     self.assertEqual(repr(a), '<dllistnode(None)>')
     b = dllist([1, None]).first
     self.assertEqual(repr(b), '<dllistnode(1)>')
     c = dllist(['abc', None]).first
     self.assertEqual(repr(c), '<dllistnode(\'abc\')>')
开发者ID:235,项目名称:pypy-llist,代码行数:7,代码来源:test_pyllist.py


示例3: test_node_repr

 def test_node_repr(self):
     a = dllist([None]).first
     self.assertEqual(repr(a), "<dllistnode(None)>")
     b = dllist([1, None]).first
     self.assertEqual(repr(b), "<dllistnode(1)>")
     c = dllist(["abc", None]).first
     self.assertEqual(repr(c), "<dllistnode('abc')>")
开发者ID:pombredanne,项目名称:pypy-llist,代码行数:7,代码来源:test_pyllist.py


示例4: test_guards_after_concat

 def test_guards_after_concat(self):
     a = dllist([1, 2])
     b = dllist([3, 4])
     c = a + b
     self.assertIsNot(c.first, None)
     self.assertEqual(c.first.value, 1)
     self.assertIsNot(c.last, None)
     self.assertEqual(c.last.value, 4)
开发者ID:rgsoda,项目名称:pypy-llist,代码行数:8,代码来源:test_pyllist.py


示例5: test_guards_after_concat_inplace

 def test_guards_after_concat_inplace(self):
     a = dllist([1, 2])
     b = dllist([3, 4])
     orig_a_first = a.first
     a += b
     self.assertIs(a.first, orig_a_first)
     self.assertEqual(a.first.value, 1)
     self.assertIsNot(a.last, None)
     self.assertEqual(a.last.value, 4)
开发者ID:rgsoda,项目名称:pypy-llist,代码行数:9,代码来源:test_pyllist.py


示例6: test_concat

 def test_concat(self):
     a_ref = range(0, 1024, 4)
     a = dllist(a_ref)
     b_ref = range(8092, 8092 + 1024, 4)
     b = dllist(b_ref)
     ab_ref = dllist(a_ref + b_ref)
     c = a + b
     self.assertEqual(c, ab_ref)
     self.assertEqual(len(c), len(ab_ref))
     c = a + b_ref
     self.assertEqual(c, ab_ref)
     self.assertEqual(len(c), len(ab_ref))
开发者ID:235,项目名称:pypy-llist,代码行数:12,代码来源:test_pyllist.py


示例7: test_cmp

 def test_cmp(self):
     a = dllist(xrange(0, 1100))
     b = dllist(xrange(0, 1101))
     c = [xrange(0, 1100)]
     self.assertEqual(cmp(a, a), 0)
     self.assertEqual(cmp(a, b), -1)
     self.assertEqual(cmp(b, a), 1)
     self.assertEqual(cmp(a, c), 1)
     self.assertEqual(cmp(c, a), -1)
     self.assertEqual(cmp([], []), 0)
     self.assertEqual(cmp([], a), -1)
     self.assertEqual(cmp(a, []), 1)
开发者ID:235,项目名称:pypy-llist,代码行数:12,代码来源:test_pyllist.py


示例8: heavy_hitters

def heavy_hitters(e):
   k = int(1.0 / e - 1)
   table = {}
   inner = dllist()
   for i in range(k):
       inner.insert([None, 0])
   outer = dllist([inner])
   min_count = 0

   with open("Data.txt") as data:
       for line in data:
           print line
           if not table.has_key(line):
               if outer.first.value.first.value[1] == min_count:
                   victim = outer.first.value.popleft()
                   if table.has_key(victim[0]) :
                       table.pop(victim[0], None)
                   outer.first.value.insert([line, min_count])
                   table[line] = [outer.first, outer.first.value.last]

           if table.has_key(line):
               a = table.get(line)
               a[1].value[1] += 1
               if a[0].next:
                   if a[0].next.value.first.value[1] == a[1].value[1]:
                       tl = a[0].next
                       tn = a[0].value.remove(a[1])
                       tl.value.appendleft(tn)
                       table[line] = [tl, tl.value.first]
                       if a[0].value.size == 0:
                           outer.remove(a[0])

                   else:
                       tn = a[0].value.remove(a[1])
                       new_inner = dllist()
                       new_inner.appendleft(tn)
                       outer.insert(new_inner, after=a[0])
                       table[line] = [a[0].next, a[0].next.value.first]
                       if a[0].value.size == 0:
                           outer.remove(a[0])
               else:
                   tn = a[0].value.remove(a[1])
                   new_inner = dllist()
                   new_inner.appendleft(tn)
                   outer.insert(new_inner, after=a[0])
                   table[line] = [a[0].next, a[0].next.value.first]
                   if a[0].value.size == 0:
                       outer.remove(a[0])
           else:
               min_count += 1

   return table
开发者ID:noperative,项目名称:heavy_hitter,代码行数:52,代码来源:heavy_hitter.py


示例9: test_concat_empty

 def test_concat_empty(self):
     empty = dllist()
     filled_ref = range(0, 1024, 4)
     filled = dllist(filled_ref)
     res = empty + empty
     self.assertEqual(res, dllist([] + []))
     self.assertEqual(len(res), 0)
     res = empty + filled
     self.assertEqual(res, dllist([] + filled_ref))
     self.assertEqual(len(res), len(filled_ref))
     res = filled + empty
     self.assertEqual(res, dllist(filled_ref + []))
     self.assertEqual(len(res), len(filled_ref))
开发者ID:235,项目名称:pypy-llist,代码行数:13,代码来源:test_pyllist.py


示例10: test_insert_value_after_last

 def test_insert_value_after_last(self):
     ll = dllist(xrange(4))
     ref = dllist([0, 1, 2, 3, 10])
     prev = ll.nodeat(3)
     arg_node = dllistnode(10)
     new_node = ll.insert(arg_node, after=ll.last)
     self.assertNotEqual(new_node, arg_node)
     self.assertEqual(new_node.value, 10)
     self.assertEqual(new_node.prev, prev)
     self.assertEqual(new_node.next, None)
     self.assertEqual(prev.next, new_node)
     self.assertEqual(new_node, ll.last)
     self.assertEqual(ll, ref)
开发者ID:235,项目名称:pypy-llist,代码行数:13,代码来源:test_pyllist.py


示例11: test_appendleft

 def test_appendleft(self):
     ll = dllist(xrange(4))
     ref = dllist([10, 0, 1, 2, 3])
     next = ll.nodeat(0)
     arg_node = dllistnode(10)
     new_node = ll.appendleft(arg_node)
     self.assertNotEqual(new_node, arg_node)
     self.assertEqual(new_node.value, 10)
     self.assertEqual(new_node.prev, None)
     self.assertEqual(new_node.next, next)
     self.assertEqual(next.prev, new_node)
     self.assertEqual(ll.first, new_node)
     self.assertEqual(ll, ref)
开发者ID:235,项目名称:pypy-llist,代码行数:13,代码来源:test_pyllist.py


示例12: test_appendright

 def test_appendright(self):
     ll = dllist(xrange(4))
     ref = dllist([0, 1, 2, 3, 10])
     prev = ll.nodeat(-1)
     arg_node = dllistnode(10)
     new_node = ll.appendright(arg_node)
     self.assertNotEqual(new_node, arg_node)
     self.assertEqual(new_node.value, 10)
     self.assertEqual(new_node.prev, prev)
     self.assertEqual(new_node.next, None)
     self.assertEqual(prev.next, new_node)
     self.assertEqual(ll.last, new_node)
     self.assertEqual(ll, ref)
开发者ID:235,项目名称:pypy-llist,代码行数:13,代码来源:test_pyllist.py


示例13: test_insert_value_after

 def test_insert_value_after(self):
     ll = dllist(xrange(4))
     ref = dllist([0, 1, 10, 2, 3])
     prev = ll.nodeat(1)
     next = ll.nodeat(2)
     arg_node = dllistnode(10)
     new_node = ll.insert(arg_node, after=ll.nodeat(1))
     self.assertNotEqual(new_node, arg_node)
     self.assertEqual(new_node.value, 10)
     self.assertEqual(new_node.prev, prev)
     self.assertEqual(new_node.next, next)
     self.assertEqual(prev.next, new_node)
     self.assertEqual(next.prev, new_node)
     self.assertEqual(ll, ref)
开发者ID:235,项目名称:pypy-llist,代码行数:14,代码来源:test_pyllist.py


示例14: test_node_after_del

 def test_node_after_del(self):
     ll = dllist([1, 2, 3])
     node = ll.nodeat(1)
     del ll[1]
     self.assertIs(node.prev, None)
     self.assertIs(node.next, None)
     self.assertIs(node.list, None)
开发者ID:rgsoda,项目名称:pypy-llist,代码行数:7,代码来源:test_pyllist.py


示例15: test_guards_after_remove

 def test_guards_after_remove(self):
     ll = dllist([1, 2])
     ll.remove(ll.last)
     self.assertIs(ll.first, ll.last)
     ll.remove(ll.first)
     self.assertIs(ll.first, None)
     self.assertIs(ll.last, None)
开发者ID:rgsoda,项目名称:pypy-llist,代码行数:7,代码来源:test_pyllist.py


示例16: test_node_after_remove

 def test_node_after_remove(self):
     ll = dllist([1, 2, 3])
     node = ll.nodeat(1)
     ll.remove(node)
     self.assertIs(node.prev, None)
     self.assertIs(node.next, None)
     self.assertIs(node.list, None)
开发者ID:rgsoda,项目名称:pypy-llist,代码行数:7,代码来源:test_pyllist.py


示例17: test_init_empty

 def test_init_empty(self):
     ll = dllist()
     self.assertEqual(len(ll), 0)
     self.assertEqual(ll.size, 0)
     self.assertEqual(list(ll), [])
     self.assertIs(ll.first, None)
     self.assertIs(ll.last, None)
开发者ID:rgsoda,项目名称:pypy-llist,代码行数:7,代码来源:test_pyllist.py


示例18: test_guards_after_appendright

 def test_guards_after_appendright(self):
     ll = dllist()
     node1 = ll.appendright(1)
     self.assertIs(ll.first, node1)
     self.assertIs(ll.last, node1)
     node2 = ll.appendright(2)
     self.assertIs(ll.first, node1)
     self.assertIs(ll.last, node2)
开发者ID:rgsoda,项目名称:pypy-llist,代码行数:8,代码来源:test_pyllist.py


示例19: test_guards_after_insert

 def test_guards_after_insert(self):
     ll = dllist()
     node1 = ll.insert(dllistnode(1))
     self.assertIs(ll.first, node1)
     self.assertIs(ll.last, node1)
     node2 = ll.insert(dllistnode(2))
     self.assertIs(ll.first, node1)
     self.assertIs(ll.last, node2)
开发者ID:rgsoda,项目名称:pypy-llist,代码行数:8,代码来源:test_pyllist.py


示例20: test_guards_after_repeat_inplace

 def test_guards_after_repeat_inplace(self):
     ll = dllist([1, 2])
     orig_first = ll.first
     orig_last = ll.last
     ll *= 4
     self.assertIs(ll.first, orig_first)
     self.assertIsNot(ll.last, None)
     self.assertIsNot(ll.last, orig_last)
开发者ID:rgsoda,项目名称:pypy-llist,代码行数:8,代码来源:test_pyllist.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyllist.sllist函数代码示例发布时间:2022-05-25
下一篇:
Python scope.hyperopt_param函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap