BOOL ami_schedule_create(void) { schedule_list = pblHeapNew(); if(schedule_list == PBL_ERROR_OUT_OF_MEMORY) return false; pblHeapSetCompareFunction(schedule_list, ami_schedule_compare); }
/** * Creates a new priority queue. * * The priority queue implementation is a * <a href="http://en.wikipedia.org/wiki/Binary_heap">binary max-heap</a> using * an array list as underlying data structure. * The entries kept in the array list are of type \Ref{PblPriorityQueueEntry}. * Each entry holding the 'void *' element payload and the 'int' priority * associated with the element. * * This function has a time complexity of O(1). * * @return PblPriorityQueue * retPtr != NULL: A pointer to the new priority queue. * @return PblPriorityQueue * retPtr == NULL: An error, see pbl_errno: * * <BR>PBL_ERROR_OUT_OF_MEMORY - Out of memory. */ PblPriorityQueue * pblPriorityQueueNew(void) { PblHeap * pblHeap = pblHeapNew(); if (!pblHeap) { return NULL; } pblHeapSetCompareFunction(pblHeap, PblPriorityQueueEntryCompareFunction); return (PblPriorityQueue *) pblHeap; }