/src/lib/storage/stack.e

http://github.com/tybor/Liberty · Specman e · 73 lines · 39 code · 7 blank · 27 comment · 0 complexity · 02ae4a221270255eb567bc5b5e024c52 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class STACK[E_]
  5. --
  6. -- A Stack of elements of type `E_'.
  7. --
  8. insert
  9. FAST_ARRAY[E_]
  10. rename last as top,
  11. add_last as push,
  12. remove_last as pop,
  13. make as collection_make
  14. export {ANY} is_empty, top, pop, push, count, item, clear_count;
  15. {STACK} all
  16. redefine new_iterator
  17. end
  18. RECYCLABLE
  19. -- To get reasonable default exports
  20. undefine default_create, out_in_tagged_out_memory, copy, is_equal
  21. end
  22. create {ANY}
  23. make, with_capacity
  24. create {FAST_ARRAY}
  25. collection_make
  26. feature {}
  27. make
  28. do
  29. with_capacity(16)
  30. ensure
  31. is_empty
  32. end
  33. new_iterator: ITERATOR[E_]
  34. do
  35. check
  36. False
  37. end
  38. end
  39. feature {RECYCLING_POOL}
  40. recycle
  41. do
  42. check
  43. require_is_empty: is_empty
  44. end
  45. end
  46. end -- class STACK
  47. --
  48. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  49. --
  50. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  51. -- of this software and associated documentation files (the "Software"), to deal
  52. -- in the Software without restriction, including without limitation the rights
  53. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  54. -- copies of the Software, and to permit persons to whom the Software is
  55. -- furnished to do so, subject to the following conditions:
  56. --
  57. -- The above copyright notice and this permission notice shall be included in
  58. -- all copies or substantial portions of the Software.
  59. --
  60. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  61. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  62. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  63. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  64. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  65. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  66. -- THE SOFTWARE.