MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Pop

Method Pop

src/script/api/script_priorityqueue.cpp:51–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51SQInteger ScriptPriorityQueue::Pop(HSQUIRRELVM vm)
52{
53 if (this->IsEmpty()) {
54 ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_FAILED);
55 sq_pushnull(vm);
56 return 1;
57 }
58
59 HSQOBJECT item = this->queue.front().second;
60 std::pop_heap(this->queue.begin(), this->queue.end(), this->comp);
61 this->queue.pop_back();
62
63 /* Store the object on the Squirrel stack before releasing it to make sure the ref count can't drop to zero. */
64 auto ret = SQConvert::Return<HSQOBJECT>::Set(vm, item);
65 sq_release(vm, &item);
66 return ret;
67}
68
69SQInteger ScriptPriorityQueue::Peek(HSQUIRRELVM vm)
70{

Callers 1

InsertResultMethod · 0.45

Calls 6

IsEmptyMethod · 0.95
sq_pushnullFunction · 0.85
sq_releaseFunction · 0.85
pop_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected