<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "binheap.h"

struct Heap {
   int capacity;
   int size;
   ElemType *elements;
};

/* Indices start from 0 */
/*
int getParent(int i) {
   return (i - 1) / 2;
}

int getLeft(int i) {
  return 2 * i + 1;
}

int getRight(int i) {
  return 2 * i + 2;
}
*/

/* We could reserve pq->elements[0] as a sentinel, 
 * and the indices start from 1
 */
int getParent(int i) {
   return i / 2;
}

int getLeft(int i) {
   return 2 * i;
}

int getRight(int i) {
   return 2 * i + 1;
}

int isEmpty(PriorityQueue pq) {
   if (pq == NULL) {
      printf("Invalid input - NULL priority queue!");
      return -1;
   }
   else {
      if (pq->size == 0) return 1;
      else return 0;
   }
}

int isFull(PriorityQueue pq) { 
   if (pq == NULL) {
      printf("Invalid input - NULL priority queue!");
      return -1;
   }
   else {
      if (pq->size == pq->capacity) return 1;
      else return 0;
      /* check the case pq->size > pq->capacity ?? */
   }
}

PriorityQueue initialize(int maxElements) {
   PriorityQueue pq;

   pq = malloc(sizeof(struct Heap));
   if (NULL == pq)
      printf("Out of space!");
   else {
      pq->elements = malloc(sizeof(maxElements + 1) * sizeof(ElemType));
      if (pq->elements == NULL) {
         printf("Out of space!");
         pq = NULL;
      }
      else {
         pq->capacity = maxElements;
         pq->size = 0;
      }<commit_msg>minor fix<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "binheap.h"

struct Heap {
   int capacity;
   int size;
   ElemType *elements;
};

/* Indices start from 0 */
/*
int getParent(int i) {
   return (i - 1) / 2;
}

int getLeft(int i) {
  return 2 * i + 1;
}

int getRight(int i) {
  return 2 * i + 2;
}
*/

/* We could reserve pq->elements[0] as a sentinel, 
 * and the indices start from 1
 */
int getParent(int i) {
   return i / 2;
}

int getLeft(int i) {
   return 2 * i;
}

int getRight(int i) {
   return 2 * i + 1;
}

int isEmpty(PriorityQueue pq) {
   if (pq == NULL) {
      printf("Invalid input - NULL priority queue!");
      return -1;
   }
   else {
      if (pq->size == 0) return 1;
      else return 0;
   }
}

int isFull(PriorityQueue pq) { 
   if (pq == NULL) {
      printf("Invalid input - NULL priority queue!");
      return -1;
   }
   else {
      if (pq->size == pq->capacity) return 1;
      else return 0;
      /* check the case pq->size > pq->capacity ?? */
   }
}

PriorityQueue initialize(int maxElements) {
   PriorityQueue pq;

   pq = malloc(sizeof(struct Heap));
   if (NULL == pq)
      printf("Out of space!");
   else {
      pq->elements = malloc((maxElements + 1) * sizeof(ElemType));
      if (pq->elements == NULL) {
         printf("Out of space!");
         pq = NULL;
      }
      else {
         pq->capacity = maxElements;
         pq->size = 0;
      }
{'fraction_non_alphanumeric': 0.14937759336099585, 'fraction_numerical': 0.015214384508990318, 'mean_word_length': 2.193156732891832, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4800820', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1018, 'n_words': 309}