/src/lib/storage/internal/linked_collection.e

http://github.com/tybor/Liberty · Specman e · 94 lines · 53 code · 11 blank · 30 comment · 0 complexity · d12c7841c69f1ea09660d2db308de065 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. deferred class LINKED_COLLECTION[E_]
  5. --
  6. -- Common root of LINKED_LIST and TWO_WAY_LINKED_LIST.
  7. --
  8. insert
  9. COLLECTION[E_]
  10. feature {ANY}
  11. lower: INTEGER 1
  12. -- Lower index bound is frozen.
  13. upper: INTEGER
  14. -- Memorized upper index bound.
  15. make
  16. -- Make an empty list
  17. deferred
  18. end
  19. remove_head (n: INTEGER)
  20. local
  21. i: INTEGER
  22. do
  23. from
  24. i := n
  25. until
  26. i = 0
  27. loop
  28. remove_first
  29. i := i - 1
  30. end
  31. end
  32. remove_tail (n: INTEGER)
  33. local
  34. i: INTEGER
  35. do
  36. from
  37. i := n
  38. until
  39. i = 0
  40. loop
  41. remove_last
  42. i := i - 1
  43. end
  44. end
  45. first_index_of (element: like item): INTEGER
  46. do
  47. Result := index_of(element, lower)
  48. end
  49. fast_first_index_of (element: like item): INTEGER
  50. do
  51. Result := fast_index_of(element, lower)
  52. end
  53. feature {} -- Implement manifest generic creation:
  54. manifest_make (needed_capacity: INTEGER)
  55. -- Manifest creation of a list of items of type E_.
  56. do
  57. make
  58. end
  59. manifest_put (index: INTEGER; element: like item)
  60. do
  61. add_last(element)
  62. end
  63. end -- class LINKED_COLLECTION
  64. --
  65. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  66. --
  67. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  68. -- of this software and associated documentation files (the "Software"), to deal
  69. -- in the Software without restriction, including without limitation the rights
  70. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  71. -- copies of the Software, and to permit persons to whom the Software is
  72. -- furnished to do so, subject to the following conditions:
  73. --
  74. -- The above copyright notice and this permission notice shall be included in
  75. -- all copies or substantial portions of the Software.
  76. --
  77. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  78. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  79. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  80. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  81. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  82. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  83. -- THE SOFTWARE.