#include "bitmap.h"
#include <stdio.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

/**
 * allocates a struct bitmap that is large enough
 * to hold num_bits bits (possibly with padding)
 */
struct bitmap *allocate_bitmap(uint64_t num_bits) {
  struct bitmap *bmap = NULL;
  return bmap;
}

/**
 * frees all memory associated with bmap
 */
void free_bitmap(struct bitmap *bmap) {
  return;
}

/**
 * yields the value of a bit i
 * if i is out of the valid range, yields 0
 */
char get_bit(struct bitmap *map, uint64_t i) {
  return 0;
}

/**
 * sets the bit at position i (regardless of whether already set)
 * post: bit `i` is 1
 * if i is out of the valid range, has no effect
 */
void set_bit(struct bitmap *map, uint64_t i) {
  return;
}

/**
 * unset the bit at position i (regardless of whether already set)
 * post: bit `i` is 0
 * if i is out of the valid range, has no effect
 */
void unset_bit(struct bitmap *map, uint64_t i) {
  return;
}


/**
 * yields the lowest index that has an unset bit
 * if all valid bits within the bitmap is set,
 * returns map->n_valid_bits
 */
uint64_t first_unset_bit(struct bitmap *map) {
  return 0;
}

/**
 * This sample printing statement prints bitmap buckets from left to right,
 * adding formatting to help you visualize the bits in your bitmap.
 */ 
void dump_bitmap(struct bitmap *map) {
	printf("Displaying Bitmap Representation\n");
	printf("\tbitmap->n_bytes: %"PRIu64"\n", map->n_bytes);
	printf("\tbitmap->n_valid_bits: %"PRIu64"\n", map->n_valid_bits);
	printf("\tbitmap->bits (8 chars per column):\n");
	int line = 0;
	for (uint64_t i = 0; i < map->n_valid_bits; i++) {
		if (i % 8 == 0) {
			if (line % 64 == 0) {
				printf("\n");
				printf("%4"PRIu64":", i);
				line = 0;
			}

			printf(" ");
		}
		printf("%u", get_bit(map, i));
		line++;

		
	}
	printf("\n\n");
}
