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.
25 if cmp
(e1
, e2
) > 0 then
62 if _k
== k
then return _v
64 if n
!= null then return n
[k
] !def
do continue def
66 _next
= new Map[K
, V
](k
, v
)
69 fun has_key
(k
: K
): Bool
71 if _k
== k
then return true
73 if n
!= null then return n
.has_key
(k
) else return false
78 var n
: nullable Map[K
, V
] = self
86 var _next
: nullable Map[K
, V
]
113 readable var _id
: Int
114 readable var _is_open
: Bool
130 fun file_open
(i
: Int)
132 break !error
(j
: Int) do abort
135 if not f
.is_open
then error
(404)
136 work
(f
) !break do f
.close
144 var a
= new Array[Char]('2', '1')
146 a
.sort
!cmp
(x
, y
) = x
<=> y
148 a
.sort
!cmp
(x
, y
) = y
<=> x
150 a
.iterate
!each i
do i
.output
156 var m
= new Map[Char, Char]('I', '1')
160 if not m
.has_key
('I') then (-1).output
169 if m
.has_key
('V') then (-2).output
172 i
= m
['V'] !def
= '5'
178 if not m
.has_key
('V') then (-3).output
181 i
= m
['V'] !def
= '6'
187 if m
.has_key
('X') then (-4).output
190 i
= m
['X'] !def
do break '0'
196 if m
.has_key
('X') then (-5).output
198 m
.iterate
!each2
(k
,v
) do
207 fun test_file
(i
: Int)
209 var f_escape
: nullable File = null
210 file_open
(i
) !work
(f
) do
219 if f_escape
!= null then
222 f_escape
.is_open
.output