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