equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
102 _entries = (SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, _num_entries * SparsePRTEntry::size(), mtGC); |
102 _entries = (SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, _num_entries * SparsePRTEntry::size(), mtGC); |
103 clear(); |
103 clear(); |
104 } |
104 } |
105 |
105 |
106 RSHashTable::~RSHashTable() { |
106 RSHashTable::~RSHashTable() { |
107 if (_entries != NULL) { |
107 FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries); |
108 FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries); |
108 FREE_C_HEAP_ARRAY(int, _buckets); |
109 _entries = NULL; |
|
110 } |
|
111 if (_buckets != NULL) { |
|
112 FREE_C_HEAP_ARRAY(int, _buckets); |
|
113 _buckets = NULL; |
|
114 } |
|
115 } |
109 } |
116 |
110 |
117 void RSHashTable::clear() { |
111 void RSHashTable::clear() { |
118 _occupied_entries = 0; |
112 _occupied_entries = 0; |
119 _occupied_cards = 0; |
113 _occupied_cards = 0; |
273 } |
267 } |
274 // Otherwise, there were no entry. |
268 // Otherwise, there were no entry. |
275 return false; |
269 return false; |
276 } |
270 } |
277 |
271 |
|
272 bool RSHashTableBucketIter::has_next(SparsePRTEntry*& entry) { |
|
273 while (_bl_ind == RSHashTable::NullEntry) { |
|
274 if (_tbl_ind == (int)_rsht->capacity() - 1) { |
|
275 return false; |
|
276 } |
|
277 _tbl_ind++; |
|
278 _bl_ind = _rsht->_buckets[_tbl_ind]; |
|
279 } |
|
280 entry = _rsht->entry(_bl_ind); |
|
281 _bl_ind = entry->next_index(); |
|
282 return true; |
|
283 } |
|
284 |
278 bool RSHashTable::contains_card(RegionIdx_t region_index, CardIdx_t card_index) const { |
285 bool RSHashTable::contains_card(RegionIdx_t region_index, CardIdx_t card_index) const { |
279 SparsePRTEntry* e = get_entry(region_index); |
286 SparsePRTEntry* e = get_entry(region_index); |
280 return (e != NULL && e->contains_card(card_index)); |
287 return (e != NULL && e->contains_card(card_index)); |
281 } |
288 } |
282 |
289 |