PageRenderTime 19ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/storage/queue.e

http://github.com/tybor/Liberty
Specman e | 79 lines | 41 code | 7 blank | 31 comment | 0 complexity | faa10d499564b96a6bd31046147c5236 MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4class QUEUE[E_]
 5   --
 6   -- A Queue of elements of type `E_'.
 7   --
 8
 9insert
10   RING_ARRAY[E_]
11      rename add as collection_add,
12         add_last as add,
13         remove as collection_remove,
14         remove_first as remove,
15         make as collection_make,
16         with_capacity as collection_with_capacity
17      export {ANY} is_empty, add, remove, first, count;
18         {QUEUE} all
19      redefine
20         new_iterator
21      end
22   ANY
23      -- To get reasonable default exports
24      undefine out_in_tagged_out_memory, copy, is_equal, default_create
25      end
26
27create {ANY}
28   make, with_capacity
29
30create {RING_ARRAY}
31   collection_make
32
33feature {}
34   make
35         -- Create an empty array. Also consider `with_capacity',
36         -- since growing a full queue is rather expensive.
37      do
38         with_capacity(16)
39      ensure
40         is_empty
41      end
42
43   with_capacity (needed_capacity: INTEGER)
44         -- Create an empty array with capacity initialized
45         -- at least to `needed_capacity'
46      require
47         needed_capacity >= 0
48      do
49         collection_with_capacity(needed_capacity, 1)
50      end
51
52   new_iterator: ITERATOR[E_]
53      do
54         check
55            False
56         end
57      end
58
59end -- class QUEUE
60--
61-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
62--
63-- Permission is hereby granted, free of charge, to any person obtaining a copy
64-- of this software and associated documentation files (the "Software"), to deal
65-- in the Software without restriction, including without limitation the rights
66-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
67-- copies of the Software, and to permit persons to whom the Software is
68-- furnished to do so, subject to the following conditions:
69--
70-- The above copyright notice and this permission notice shall be included in
71-- all copies or substantial portions of the Software.
72--
73-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
74-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
75-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
76-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
77-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
78-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
79-- THE SOFTWARE.