Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ebfcc29

Browse files
sort
1 parent 99e7fed commit ebfcc29

2 files changed

Lines changed: 52 additions & 17 deletions

File tree

‎.idea/workspace.xml‎

Lines changed: 36 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Bit_maps.py‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,34 @@ def sequence(self, reverse=False):
6565
for i in range(start, end, step):
6666
value = self.values[i]
6767
count = 0
68+
values_bin = bin(value)
69+
6870
while value != 0:
6971
values_bin = bin(value)
7072
if value & 1 == 1:
7173
yield count + i * (1<<self.div_num)
72-
value = value >> 1
74+
value = max(value >> 1, 0)
7375
count += 1
7476
else:
7577
count += 1
76-
value = value >> 1
78+
value = max(value >> 1, 0)
79+
7780

7881
if __name__ == "__main__":
7982
bit_map = XC_bitmap(1000)
80-
print(" need bit memory_size {a} 个整数(s) \n".format(a=bit_map.bit_size))
81-
num_list = [32, 63, 64, 65, 125, 126, 126, 128, 129, 98, 999]
82-
83+
# print(" need bit memory_size {a} 个整数(s) \n".format(a=bit_map.bit_size))
84+
#
85+
import numpy as np
86+
#
87+
test_list = np.random.randint(0, 1000, 100)
88+
print(test_list)
89+
for _ in test_list:
90+
bit_map.add(_)
8391
print("\n == sort == \n")
84-
for _ in bit_map.sequence(reverse=True):
92+
for _ in bit_map.sequence(reverse=False):
8593
print(_)
94+
# [814 679 105 957 217 638 663 89 895 842]
95+
print("13 + bin " + bin(-9223372036854774784))
8696

8797

8898

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /