示例#1
0
 def test_add(self):
     s = zset()
     s.add(3, 'ciao')
     s.add(4, 'bla')
     self.assertEqual(len(s), 2)
     s.add(-1, 'bla')
     self.assertEqual(len(s), 2)
     data = list(s)
     self.assertEqual(data, ['bla', 'ciao'])
示例#2
0
 def test_add(self):
     s = zset()
     s.add(3, 'ciao')
     s.add(4, 'bla')
     self.assertEqual(len(s), 2)
     s.add(-1, 'bla')
     self.assertEqual(len(s), 2)
     data = list(s)
     self.assertEqual(data, ['bla', 'ciao'])
示例#3
0
 def test_update(self):
     string = test.populate('string', size=100)
     values = test.populate('float', size=100)
     s = zset()
     s.update(zip(values, string))
     self.assertTrue(s)
     prev = None
     for score, _ in s.items():
         if prev is not None:
             self.assertTrue(score >= prev)
         prev = score
     return s
示例#4
0
 def test_update(self):
     string = test.populate('string', size=100)
     values = test.populate('float', size=100)
     s = zset()
     s.update(zip(values,string))
     self.assertTrue(s)
     prev = None
     for score, _ in s.items():
         if prev is not None:
             self.assertTrue(score>=prev)
         prev = score
     return s
示例#5
0
 def test_rank(self):
     s = zset()
     s.add(3, 'ciao')
     s.add(4, 'bla')
     s.add(2, 'foo')
     s.add(20, 'pippo')
     s.add(-1, 'bla')
     self.assertEqual(len(s), 4)
     self.assertEqual(s.rank('bla'), 0)
     self.assertEqual(s.rank('foo'), 1)
     self.assertEqual(s.rank('ciao'), 2)
     self.assertEqual(s.rank('pippo'), 3)
     self.assertEqual(s.rank('xxxx'), None)
示例#6
0
 def test_rank(self):
     s = zset()
     s.add(3, 'ciao')
     s.add(4, 'bla')
     s.add(2, 'foo')
     s.add(20, 'pippo')
     s.add(-1, 'bla')
     self.assertEqual(len(s), 4)
     self.assertEqual(s.rank('bla'), 0)
     self.assertEqual(s.rank('foo'), 1)
     self.assertEqual(s.rank('ciao'), 2)
     self.assertEqual(s.rank('pippo'), 3)
     self.assertEqual(s.rank('xxxx'), None)
示例#7
0
 def set_cache(self, data):
     if self.cache is None:
         self.cache = zset()
     self.cache.update(data)
示例#8
0
 def clear(self):
     self.cache = None
     self.toadd = zset()
     self.toremove = set()
示例#9
0
 def set_cache(self, data):
     if self.cache is None:
         self.cache = zset()
     self.cache.update(data)
示例#10
0
 def clear(self):
     self.cache = None
     self.toadd = zset()
     self.toremove = set()