nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/serialization: add README.md
[nit.git]
/
tests
/
bench_complex_sort.nit
diff --git
a/tests/bench_complex_sort.nit
b/tests/bench_complex_sort.nit
index
9ee9dda
..
2eef2cb
100644
(file)
--- a/
tests/bench_complex_sort.nit
+++ b/
tests/bench_complex_sort.nit
@@
-15,38
+15,38
@@
# limitations under the License.
# limitations under the License.
-class Elt
- meth val1: Int is abstract
- meth val2: Int do return val1 end
+interface Elt
+ fun val1: Int is abstract
+ fun val2: Int do return val1
end
class A
end
class A
-special Elt
- attr _a: Int
- redef meth val1: Int do return _a end
+ super Elt
+ var a: Int
+ redef fun val1: Int do return _a
- init(i: Int) do _a = i end
+ init(i: Int) do _a = i
end
class Elt2
end
class Elt2
-special Elt
- attr _b: Int
- redef meth val1: Int do return _b/2 end
- redef meth val2: Int do return _b end
+ super Elt
+ var b: Int
+ redef fun val1: Int do return _b/2
+ redef fun val2: Int do return _b
+ init initelt2(i: Int) do _b = i
end
class B
end
class B
-special Elt2
-
- init(i: Int) do _b = i end
+ super Elt2
+ init(i: Int) do initelt2(i)
end
class C
end
class C
-special Elt
- attr _c: Int
- attr _d: Int
- redef meth val1: Int do return _c end
- redef meth val2: Int do return _d end
+ super Elt
+ var c: Int
+ var d: Int
+ redef fun val1: Int do return _c end
+ redef fun val2: Int do return _d end
init init2(i: Int, j: Int) do
_c = i
init init2(i: Int, j: Int) do
_c = i
@@
-55,27
+55,28
@@
special Elt
end
class D
end
class D
-special A
-special Elt2
- redef meth val1: Int do return _a end
- redef meth val2: Int do return _b end
+ super A
+ super Elt2
+ redef fun val1: Int do return _a end
+ redef fun val2: Int do return _b end
init init2(i: Int, j: Int) do
init(i)
init init2(i: Int, j: Int) do
init(i)
- _b = j
+ initelt2(j)
end
end
class E
end
end
class E
-special Elt2
- redef meth val1: Int do return 5 end
+ super Elt2
+ redef fun val1: Int do return 5 end
- init(i: Int) do _b = i end
+ init(i: Int) do initelt2(i)
end
end
-class EltSorter
-special AbstractSorter[Elt]
- redef meth compare(a: Elt, b: Elt): Int
+class EltComparator
+ super Comparator
+ redef type COMPARED: Elt
+ redef fun compare(a, b)
do
if _is_val1 then
return a.val1 <=> b.val1
do
if _is_val1 then
return a.val1 <=> b.val1
@@
-84,17
+85,17
@@
special AbstractSorter[Elt]
end
end
end
end
- meth toggle
+ fun toggle
do
_is_val1 = not _is_val1
end
do
_is_val1 = not _is_val1
end
- attr _is_val1: Bool
+ var is_val1: Bool = false
init do end
end
init do end
end
-meth generator: Elt
+fun generator: Elt
do
var r = 5.rand
if r == 0 then
do
var r = 5.rand
if r == 0 then
@@
-121,9
+122,9
@@
for i in [0..n[ do
array.push(generator)
end
array.push(generator)
end
-var sorter = new EltSorter
+var comparator = new EltComparator
for i in [0..n[ do
for i in [0..n[ do
- sorter.sort(array)
- sorter.toggle
+ comparator.sort(array)
+ comparator.toggle
end
end