mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
!8270 BugFix treeset remove firstValue
Merge pull request !8270 from 王笑佳/master
This commit is contained in:
commit
9175348584
@ -481,6 +481,11 @@ JSHandle<Derived> TaggedTree<Derived>::Shrink(const JSThread *thread, const JSHa
|
||||
|
||||
int length = ELEMENTS_START_INDEX + static_cast<int>(newCapacity) * (Derived::ENTRY_SIZE);
|
||||
JSHandle<Derived> newTree = AdjustTaggedTree(thread, tree, length);
|
||||
JSTaggedValue fn = tree->GetCompare();
|
||||
JSHandle<JSTaggedValue> compareFn = JSHandle<JSTaggedValue>(thread, fn);
|
||||
if (!compareFn->IsUndefined() && !compareFn->IsNull()) {
|
||||
newTree->SetCompare(thread, compareFn.GetTaggedValue());
|
||||
}
|
||||
newTree->SetCapacity(thread, newCapacity);
|
||||
return newTree;
|
||||
}
|
||||
|
@ -240,5 +240,55 @@ if (globalThis["ArkPrivate"] != undefined) {
|
||||
} else {
|
||||
print("Test TreeSet fail: " + flag);
|
||||
}
|
||||
let treeSet = new fastset((first,second) =>{
|
||||
return first > second
|
||||
});
|
||||
let insertArr = [
|
||||
643,
|
||||
811,
|
||||
807,
|
||||
378,
|
||||
226,
|
||||
195,
|
||||
599,
|
||||
641,
|
||||
494,
|
||||
964,
|
||||
156,
|
||||
419,
|
||||
977,
|
||||
20,
|
||||
788,
|
||||
596
|
||||
]
|
||||
let addItem = function(obj){
|
||||
treeSet.add(obj)
|
||||
}
|
||||
let removeItem = function(){
|
||||
const first = treeSet.getFirstValue()
|
||||
treeSet.remove(first)
|
||||
}
|
||||
for(let i = 0;i < insertArr.length;i++) {
|
||||
addItem(insertArr[i])
|
||||
}
|
||||
removeItem()
|
||||
removeItem()
|
||||
removeItem()
|
||||
removeItem()
|
||||
removeItem()
|
||||
addItem(664)
|
||||
removeItem()
|
||||
removeItem()
|
||||
removeItem()
|
||||
removeItem()
|
||||
removeItem()
|
||||
removeItem()
|
||||
removeItem()
|
||||
removeItem()
|
||||
let resArr = []
|
||||
treeSet.forEach(element => {
|
||||
resArr.push(element)
|
||||
});
|
||||
print(resArr)
|
||||
}
|
||||
export let treesetRes = "Test TreeSet done";
|
@ -25,6 +25,7 @@ Test Stack success!!!
|
||||
Test TreeMap success!!!
|
||||
Test TreeMap set After Clear Success
|
||||
Test TreeSet success!!!
|
||||
226,195,156,20
|
||||
Test Vector success!!!
|
||||
Test ArrayList
|
||||
Test Deque done
|
||||
|
Loading…
Reference in New Issue
Block a user