hotspot/src/share/vm/utilities/resourceHash.hpp
changeset 23187 0f438571f278
parent 22827 07d991d45a51
child 33754 49614940dafc
equal deleted inserted replaced
22930:1c9f21f3fbf4 23187:0f438571f278
   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,