PageRenderTime 13ms CodeModel.GetById 11ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/test/language/gc/aux_agent_gc6.e

http://github.com/tybor/Liberty
Specman e | 98 lines | 70 code | 7 blank | 21 comment | 5 complexity | 64535c59a034a8f5926c0cd4fb36e361 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--
 4expanded class AUX_AGENT_GC6
 5
 6feature {ANY}
 7   head, tail: AUX_AGENT_GC7
 8
 9   clear
10      do
11         head := Void
12         tail := Void
13      end
14
15   add (p: AUX_AGENT_GC3)
16      local
17         node: AUX_AGENT_GC7
18      do
19         create node.set_patient(p)
20         if tail = Void then
21            head := node
22         else
23            tail.set_next(node)
24         end
25         tail := node
26      end
27
28   remove (p: AUX_AGENT_GC3)
29      local
30         node, previous: AUX_AGENT_GC7
31      do
32         from
33            node := head
34         until
35            node = Void or else node.patient = p
36         loop
37            previous := node
38            node := node.next
39         end
40         if node /= Void then
41            if previous /= Void then
42               previous.set_next(node.next)
43            else
44               head := node.next
45            end
46            if tail = node then
47               tail := previous
48            end
49         end
50      end
51
52   for_each (proc: ROUTINE[TUPLE[AUX_AGENT_GC3]])
53      local
54         node: AUX_AGENT_GC7
55      do
56         from
57            node := head
58         until
59            node = Void
60         loop
61            proc.call([node.patient])
62            node := node.next
63         end
64      end
65
66   accumulate_totals: AUX_AGENT_GC5
67      local
68         node: AUX_AGENT_GC7
69      do
70         from
71            node := head
72         until
73            node = Void
74         loop
75            Result.add(node.patient)
76            node := node.next
77         end
78      end
79
80end -- class AUX_AGENT_GC6
81--
82-- ------------------------------------------------------------------------------------------------------------------------------
83-- Copyright notice below. Please read.
84--
85-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
86-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
87-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
88-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
89-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
90-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
91--
92-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
93-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
94--
95-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
96--
97-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
98-- ------------------------------------------------------------------------------------------------------------------------------