-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQuickSort.j
More file actions
274 lines (237 loc) · 3.6 KB
/
QuickSort.j
File metadata and controls
274 lines (237 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
.class public QuickSort
.super java/lang/Object
.method public <init>()V
aload_0
invokenonvirtual java/lang/Object/<init>()V
return
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 5
.limit locals 4
bipush 10
newarray int
astore_1
iconst_0
istore_2
iload_2
aload_1
arraylength
if_icmplt lt_true_0
iconst_0
goto lt_false_0
lt_true_0:
iconst_1
lt_false_0:
ifeq end_while_0
start_while_0:
aload_1
iload_2
aload_1
arraylength
iload_2
isub
iastore
iload_2
iconst_1
iadd
istore_2
iload_2
aload_1
arraylength
if_icmplt lt_true_1
iconst_0
goto lt_false_1
lt_true_1:
iconst_1
lt_false_1:
ifne start_while_0
end_while_0:
new QuickSort
dup
invokespecial QuickSort/<init>()V
astore_3
aload_3
aload_1
invokevirtual QuickSort/quicksort([I)Z
pop
aload_3
aload_1
invokevirtual QuickSort/printL([I)Z
pop
return
.end method
.method public printL([I)Z
.limit stack 4
.limit locals 3
iconst_0
istore_2
iload_2
aload_1
arraylength
if_icmplt lt_true_2
iconst_0
goto lt_false_2
lt_true_2:
iconst_1
lt_false_2:
ifeq end_while_1
start_while_1:
aload_1
iload_2
iaload
invokestatic io/println(I)V
iload_2
iconst_1
iadd
istore_2
iload_2
aload_1
arraylength
if_icmplt lt_true_3
iconst_0
goto lt_false_3
lt_true_3:
iconst_1
lt_false_3:
ifne start_while_1
end_while_1:
iconst_1
ireturn
.end method
.method public quicksort([I)Z
.limit stack 5
.limit locals 2
aload_0
aload_1
iconst_0
aload_1
arraylength
iconst_1
isub
invokevirtual QuickSort/quicksort([III)Z
ireturn
.end method
.method public quicksort([III)Z
.limit stack 6
.limit locals 5
iload_2
iload_3
if_icmplt lt_true_4
iconst_0
goto lt_false_4
lt_true_4:
iconst_1
lt_false_4:
ifeq else_0
aload_0
aload_1
iload_2
iload_3
invokevirtual QuickSort/partition([III)I
istore 4
aload_0
aload_1
iload_2
iload 4
iconst_1
isub
invokevirtual QuickSort/quicksort([III)Z
pop
aload_0
aload_1
iload 4
iconst_1
iadd
iload_3
invokevirtual QuickSort/quicksort([III)Z
pop
goto endif_0
else_0:
endif_0:
iconst_1
ireturn
.end method
.method public partition([III)I
.limit stack 7
.limit locals 8
aload_1
iload_3
iaload
istore 4
iload_2
istore 5
iload_2
istore 6
iload 6
iload_3
if_icmplt lt_true_5
iconst_0
goto lt_false_5
lt_true_5:
iconst_1
lt_false_5:
ifeq end_while_2
start_while_2:
aload_1
iload 6
iaload
iload 4
if_icmplt lt_true_6
iconst_0
goto lt_false_6
lt_true_6:
iconst_1
lt_false_6:
ifeq else_1
aload_1
iload 5
iaload
istore 7
aload_1
iload 5
aload_1
iload 6
iaload
iastore
aload_1
iload 6
iload 7
iastore
iload 5
iconst_1
iadd
istore 5
goto endif_1
else_1:
endif_1:
iload 6
iconst_1
iadd
istore 6
iload 6
iload_3
if_icmplt lt_true_7
iconst_0
goto lt_false_7
lt_true_7:
iconst_1
lt_false_7:
ifne start_while_2
end_while_2:
aload_1
iload 5
iaload
istore 7
aload_1
iload 5
aload_1
iload_3
iaload
iastore
aload_1
iload_3
iload 7
iastore
iload 5
ireturn
.end method