1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2006-2008 Jean Privat <jean@pryen.org>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 fun val1
: Int is abstract
20 fun val2
: Int do return val1
26 redef fun val1
: Int do return _a
28 init(i
: Int) do _a
= i
34 redef fun val1
: Int do return _b
/2
35 redef fun val2
: Int do return _b
36 init initelt2
(i
: Int) do _b
= i
41 init(i
: Int) do initelt2
(i
)
48 redef fun val1
: Int do return _c
end
49 redef fun val2
: Int do return _d
end
51 init init2
(i
: Int, j
: Int) do
60 redef fun val1
: Int do return _a
end
61 redef fun val2
: Int do return _b
end
63 init init2
(i
: Int, j
: Int) do
71 redef fun val1
: Int do return 5 end
73 init(i
: Int) do initelt2
(i
)
78 redef fun compare
(a
: Elt, b
: Elt): Int
81 return a
.val1
<=> b
.val1
83 return a
.val2
<=> b
.val2
89 _is_val1
= not _is_val1
92 var is_val1
: Bool = false
101 return new A
(10.rand
)
103 return new B
(10.rand
)
105 return new C
.init2
(10.rand
, 10.rand
)
107 return new D
.init2
(10.rand
, 10.rand
)
109 return new E
(10.rand
)
115 if not args
.is_empty
then
119 var array
= new Array[Elt].with_capacity
(n
)
121 array
.push
(generator
)
124 var comparator
= new EltComparator
126 comparator
.sort
(array
)