/tutorial/cecil/etl/eif_stuff.e

http://github.com/tybor/Liberty · Specman e · 34 lines · 24 code · 4 blank · 6 comment · 2 complexity · 14629ef098fff3d79ccdaef4d4c24205 MD5 · raw file

  1. expanded class EIF_STUFF
  2. --
  3. -- To simulate `eif_adopt' and `eif_wean' from ETL.
  4. --
  5. feature {ANY}
  6. adopted: FAST_ARRAY[ANY] is
  7. once
  8. create Result.with_capacity(16)
  9. end
  10. adopt (object: ANY) is
  11. -- A reference to object is stored in `adopted' to avoid
  12. -- it's collection at GC time.
  13. do
  14. if not adopted.fast_has(object) then
  15. adopted.add_last(object)
  16. end
  17. end
  18. wean (object: ANY) is
  19. -- Remove the reference to `object' in adopted.
  20. local
  21. i: INTEGER
  22. do
  23. i := adopted.fast_first_index_of(object)
  24. if adopted.valid_index(i) then
  25. adopted.put(Void, i)
  26. adopted.put(adopted.last, i)
  27. adopted.remove_last
  28. end
  29. end
  30. end -- class EIF_STUFF