Mercurial > hg > truffle
comparison src/share/vm/utilities/resourceHash.hpp @ 14702:d4dd5204c0aa
Merge
author | ehelin |
---|---|
date | Fri, 14 Mar 2014 13:27:18 +0100 |
parents | 3c6ae9109a86 |
children | 92aa6797d639 |
comparison
equal
deleted
inserted
replaced
14701:d3ef21095134 | 14702:d4dd5204c0aa |
---|---|
103 } else { | 103 } else { |
104 return NULL; | 104 return NULL; |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 // Inserts or replaces a value in the table | 108 /** |
109 void put(K const& key, V const& value) { | 109 * Inserts or replaces a value in the table. |
110 * @return: true: if a new item is added | |
111 * false: if the item already existed and the value is updated | |
112 */ | |
113 bool put(K const& key, V const& value) { | |
110 unsigned hv = HASH(key); | 114 unsigned hv = HASH(key); |
111 Node** ptr = lookup_node(hv, key); | 115 Node** ptr = lookup_node(hv, key); |
112 if (*ptr != NULL) { | 116 if (*ptr != NULL) { |
113 (*ptr)->_value = value; | 117 (*ptr)->_value = value; |
118 return false; | |
114 } else { | 119 } else { |
115 *ptr = new Node(hv, key, value); | 120 *ptr = new Node(hv, key, value); |
121 return true; | |
116 } | 122 } |
117 } | 123 } |
118 | 124 |
119 // ITER contains bool do_entry(K const&, V const&), which will be | 125 // ITER contains bool do_entry(K const&, V const&), which will be |
120 // called for each entry in the table. If do_entry() returns false, | 126 // called for each entry in the table. If do_entry() returns false, |