PageRenderTime 21ms CodeModel.GetById 17ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/storage/collection/dictionary_key_traverser.e

http://github.com/tybor/Liberty
Specman e | 97 lines | 57 code | 15 blank | 25 comment | 0 complexity | 10b7810a6ec56c9632526dd060765348 MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4class DICTIONARY_KEY_TRAVERSER[V_, K_]
 5   -- This class allows you to view a MAP[V_, K_] as a TRAVERSABLE[K_].  Note that there is no need for
 6   -- a DICTIONARY_ITEM_TRAVERSER because MAP[V_, K_] is already a TRAVERSABLE[V_].
 7
 8inherit
 9   TRAVERSABLE[K_]
10
11create {ANY}
12   from_dictionary
13
14create {MAP}
15   from_map
16
17feature {}
18   from_map (map_: like map)
19      do
20         map := map_
21      end
22
23feature {ANY}
24   from_dictionary (map_: like map)
25      obsolete "Use MAP#`keys' instead."
26      do
27         from_map(map)
28      end
29
30feature {ANY}
31   lower: INTEGER
32      do
33         Result := map.lower
34      end
35
36   upper: INTEGER
37      do
38         Result := map.upper
39      end
40
41feature {ANY}
42   count: INTEGER
43      do
44         Result := map.count
45      end
46
47   is_empty: BOOLEAN
48      do
49         Result := map.is_empty
50      end
51
52feature {ANY}
53   item (i: INTEGER): K_
54      do
55         Result := map.key(i)
56      end
57
58   first: like item
59      do
60         Result := item(lower)
61      end
62
63   last: like item
64      do
65         Result := item(upper)
66      end
67
68feature {ANY}
69   new_iterator: ITERATOR[K_]
70      do
71         Result := map.new_iterator_on_keys
72      end
73
74feature {}
75   map: MAP[V_, K_]
76
77end -- class DICTIONARY_KEY_TRAVERSER
78--
79-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
80--
81-- Permission is hereby granted, free of charge, to any person obtaining a copy
82-- of this software and associated documentation files (the "Software"), to deal
83-- in the Software without restriction, including without limitation the rights
84-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
85-- copies of the Software, and to permit persons to whom the Software is
86-- furnished to do so, subject to the following conditions:
87--
88-- The above copyright notice and this permission notice shall be included in
89-- all copies or substantial portions of the Software.
90--
91-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
92-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
93-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
94-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
95-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
96-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
97-- THE SOFTWARE.