/[eiffelstudio]/branches/eth/eve/Src/library/memory_analyzer/ma_references_table.e
ViewVC logotype

Contents of /branches/eth/eve/Src/library/memory_analyzer/ma_references_table.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 92684 - (show annotations)
Fri Jun 7 15:28:53 2013 UTC (6 years, 7 months ago) by jasonw
File size: 2771 byte(s)
<<Merged from trunk#92682.>>
1 note
2 description: "Objects represent mappings of addresses. [referrer, referee]"
3 date: "$Date$"
4 revision: "$Revision$"
5
6 class
7 MA_REFERENCES_TABLE [G -> HASHABLE, H -> HASHABLE]
8
9 create
10 make
11
12 feature {NONE} -- Initialization
13
14 make (a_referee_count: INTEGER)
15 -- Init with `a_referee_count'
16 do
17 create relations.make (a_referee_count)
18 end
19
20 feature -- Access
21
22 references_by_referee (a_referee: H): HASH_TABLE [TUPLE [referee: H; data: detachable ANY], G]
23 -- All relations by referee.
24 require
25 a_referee_not_void: a_referee /= Void
26 local
27 l_result: detachable like references_by_referee
28 do
29 l_result := relations.item (a_referee)
30 if l_result = Void then
31 create l_result.make (0)
32 end
33 Result := l_result
34 ensure
35 Result_not_void: Result /= Void
36 end
37
38 referee_count: INTEGER
39 -- Count for referees
40 do
41 Result := relations.count
42 end
43
44 count: INTEGER
45 -- Count for all references.
46 local
47 l_relations: like relations
48 do
49 from
50 l_relations := relations
51 l_relations.start
52 until
53 l_relations.after
54 loop
55 Result := Result + l_relations.item_for_iteration.count
56 l_relations.forth
57 end
58 end
59
60 feature -- Element change
61
62 extend (a_referrer: G; a_referee: H; data: detachable ANY)
63 -- Add new relations
64 require
65 a_referrer_not_void: a_referrer /= Void
66 a_referee_not_void: a_referee /= Void
67 local
68 l_hash: detachable like references_by_referee
69 do
70 if not relations.has_key (a_referee) then
71 create l_hash.make (20)
72 -- Here we prevent extending pairs exsited or with equivalent key and value.
73 relations.force (l_hash, a_referee)
74 else
75 l_hash := relations.found_item
76 end
77 check l_hash /= Void end -- Implied by previous if clause
78 l_hash.force ([a_referee, data], a_referrer)
79 end
80
81 feature -- Removal
82
83 remove (a_referrer: G; a_referee: H)
84 -- Remove relation between `'a_referrer' and `a_referee'.
85 require
86 a_referrer_not_void: a_referrer /= Void
87 a_referee_not_void: a_referee /= Void
88 local
89 l_hash: detachable like references_by_referee
90 do
91 if relations.has_key (a_referee) then
92 l_hash := relations.found_item
93 check l_hash /= Void end -- Implied by `has_key'
94 l_hash.remove (a_referrer)
95 if l_hash.is_empty then
96 relations.remove (a_referee)
97 end
98 end
99 end
100
101 feature {NONE} -- Implementation
102
103 relations: HASH_TABLE [like references_by_referee, H];
104
105 note
106 copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
107 license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
108 source: "[
109 Eiffel Software
110 356 Storke Road, Goleta, CA 93117 USA
111 Telephone 805-685-1006, Fax 805-685-6869
112 Website http://www.eiffel.com
113 Customer support http://support.eiffel.com
114 ]"
115
116 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23