Skip to content

Commit 02064d7

Browse files
committed
修改命名与结构,让代码更加 Pythonic
1 parent 07aab8c commit 02064d7

10 files changed

+27
-247
lines changed

Diff for: Sort/BubbleSort.py

-29
This file was deleted.

Diff for: Sort/CountSort.py

-22
This file was deleted.

Diff for: Sort/HeapSort.py

-30
This file was deleted.

Diff for: Sort/InsertSort.py

-26
This file was deleted.

Diff for: Sort/MargeSort.py

-31
This file was deleted.

Diff for: Sort/QuickSort.py

-39
This file was deleted.

Diff for: Sort/SelectionSort.py

-18
This file was deleted.

Diff for: Sort/ShellSort.py

-21
This file was deleted.

Diff for: Sort/__init__.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
4-
'''a test module '''
5-
6-
__author__ = 'EINDEX'

Diff for: Sort/main.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
'''测试函数 '''
4+
"""测试函数 """
55
import random
66
import time
77

8-
from Sort.BubbleSort import bubble_sort, bubble_sort_flag
9-
from Sort.CountSort import count_sort
10-
from Sort.HeapSort import heap_sort
11-
from Sort.InsertSort import insert_sort
12-
from Sort.MargeSort import merge_sort
13-
from Sort.QuickSort import quick_sort, qsort
14-
from Sort.SelectionSort import selection_sort
15-
from Sort.ShellSort import shell_sort
8+
from Sort.bubble_sort import bubble_sort, bubble_sort_flag
9+
from Sort.count_sort import count_sort
10+
from Sort.heap_sort import heap_sort
11+
from Sort.insert_sort import insert_sort
12+
from Sort.marge_sort import merge_sort
13+
from Sort.quick_sort import quick_sort, qsort
14+
from Sort.selection_sort import selection_sort
15+
from Sort.shell_sort import shell_sort
1616
import sys
1717

1818
# 开挂 防止栈溢出
1919
sys.setrecursionlimit(99999)
2020

21-
#整数数列
21+
# 整数数列
2222
# L = [int(random.uniform(0, 5000)) for x in range(1000)]
2323
# 浮点数列
2424
L = [random.uniform(0, 5000) for x in range(1000)]
25-
2625
current = list(L)
2726
current.sort()
2827

29-
def compile(fun):
28+
29+
def sort_test(fun):
3030
l = list(L)
31-
start=time.time()
31+
start = time.time()
3232
res = fun(l)
3333
over = time.time()
34-
print('time:'+str(over-start),current == res, fun.__name__)
35-
36-
37-
compile(selection_sort)
38-
compile(bubble_sort)
39-
compile(bubble_sort_flag)
40-
compile(insert_sort)
41-
compile(merge_sort)
42-
compile(shell_sort)
43-
compile(quick_sort)
44-
compile(qsort)
45-
compile(heap_sort)
46-
if isinstance(L[0],int):
47-
compile(count_sort)
34+
print('time:' + str(over - start), current == res, fun.__name__)
35+
36+
37+
sort_test(selection_sort)
38+
sort_test(bubble_sort)
39+
sort_test(bubble_sort_flag)
40+
sort_test(insert_sort)
41+
sort_test(merge_sort)
42+
sort_test(shell_sort)
43+
sort_test(quick_sort)
44+
sort_test(qsort)
45+
sort_test(heap_sort)
46+
if isinstance(L[0], int):
47+
sort_test(count_sort)

0 commit comments

Comments
 (0)