-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from AhmedHamed3699/Scheduling
Scheduling
- Loading branch information
Showing
8 changed files
with
344 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
#pragma once | ||
#include "structs.h" | ||
// #include "headers.h" | ||
#include <stdlib.h> | ||
|
||
/** | ||
* @list: array of data | ||
* @size: number of elements in the heap | ||
* @compare: | ||
returns: | ||
* @compare: | ||
returns: | ||
- 1: element1 > element2 | ||
- -1: element1 < element1 | ||
- -1: element1 < element2 | ||
- 0: element1 = element2 | ||
* Description: minimum heap structure | ||
*/ | ||
typedef struct min_heap{ | ||
size_t capacity; | ||
void** arr; | ||
size_t size; | ||
int (*compare)(void* e1, void* e2); | ||
}min_heap; | ||
typedef struct min_heap { | ||
size_t capacity; | ||
void **arr; | ||
size_t size; | ||
int (*compare)(void *e1, void *e2); | ||
} min_heap; | ||
|
||
min_heap* createMinHeap(int comp(void* , void* )); //returns pointer on the heap to start using it | ||
void insertMinHeap(min_heap** heap , void* element); //insert new element in the heap | ||
void* extractMin(min_heap* heap); //get the min element | ||
void decreaseKey(min_heap* heap ,int ind); //shift-up operation, called on decreasing the priority value | ||
void minHeapify(min_heap* heap , int ind); | ||
min_heap** doubleCapacity(min_heap* heap); | ||
void swap(void** arr, int ind1, int ind2); | ||
void printHeap(min_heap* heap); | ||
// returns pointer on the heap to start using it | ||
min_heap *createMinHeap(int comp(void *, void *)); | ||
// insert new element in the heap | ||
void insertMinHeap(min_heap **heap, void *element); | ||
// get the min element | ||
void *extractMin(min_heap *heap); | ||
void *getMin(min_heap *heap); | ||
// shift-up operation, called on decreasing the priority value | ||
void decreaseKey(min_heap *heap, int ind); | ||
void minHeapify(min_heap *heap, int ind); | ||
min_heap **doubleCapacity(min_heap *heap); | ||
void swap(void **arr, int ind1, int ind2); | ||
void printHeap(min_heap *heap); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.