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