PageRenderTime 21ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/test/language/agent/aux_agent53_container.e

http://github.com/tybor/Liberty
Specman e | 68 lines | 41 code | 6 blank | 21 comment | 2 complexity | a42fb54e0551b4ad7c33b9889eeee93e MD5 | raw file
 1-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
 2-- See the Copyright notice at the end of this file.
 3--
 4class AUX_AGENT53_CONTAINER[G]
 5
 6create {ANY}
 7   make
 8
 9feature {ANY}
10   list: FAST_ARRAY[G]
11
12   make
13      do
14         create list.make(0)
15      end
16
17   stats_for (fct: FUNCTION[TUPLE[G], TUPLE[INTEGER, INTEGER]]): REAL
18      local
19         ti: TUPLE[INTEGER, INTEGER]; i, n1, n2: INTEGER
20      do
21         from
22            i := list.lower
23         until
24            i > list.upper
25         loop
26            ti := fct.item([list.item(i)])
27            n1 := n1 + ti.first
28            n2 := n2 + ti.second
29            i := i + 1
30         end
31         if n1 /= 0 then
32            Result := n2 / n1 * 100
33         end
34      end
35
36   exists (test: FUNCTION[TUPLE[G], BOOLEAN]): BOOLEAN
37      local
38         i: INTEGER
39      do
40         from
41            i := list.lower
42         until
43            i > list.upper or else Result
44         loop
45            Result := test.item([list.item(i)])
46            i := i + 1
47         end
48      end
49
50end -- class AUX_AGENT53_CONTAINER
51--
52-- ------------------------------------------------------------------------------------------------------------------------------
53-- Copyright notice below. Please read.
54--
55-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
56-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
57-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
58-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
59-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
60-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
61--
62-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
63-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
64--
65-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
66--
67-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
68-- ------------------------------------------------------------------------------------------------------------------------------