Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Status.h enum status { FAILURE, SUCCESS }; typedef enum status Status; enum boolean { FALSE, TRUE }; typedef enum boolean Boolean; This program will take

image text in transcribed

Status.h

enum status { FAILURE, SUCCESS }; typedef enum status Status; enum boolean { FALSE, TRUE }; typedef enum boolean Boolean; 
This program will take the first few daily assignments and combine their behaviors to make an opaque object wrapper that allows for all the behaviors we want in a bit collection data structure called BIT FLAGS #ifndef BIT FLAGS H define BIT FLAGS H include "status . h" typedef void BIT FLAGS //Intentionally leaving out a default init function to force user to at least guess at the size needed //If one WERE to be used it would have the following prototype //BIT_FLAGS bit flags init_default(void) //Precondition: number of bits is a positive integer //Postcondition: Returns the handle to a valid Bit flags object that has the ability to store up to /I number of bits bits but currently all flags are set at zero. Returns NULL on failure. The container I is assumed to hold size-number_of_bits after the init function runs BIT_FLAGS bit_flagsinit_number_of_bits (int number_of_bits); //Precondition: flag position is a non-negative integer and hBit flags is a handle to a valid Bit flags object //Postcondition: The flag at the flag position index is set to 1. Function will attempt to resize the /I internal representation if the flag position is too large instead of failing for out of bounds. Returns // SUCCESS if the operation is successful and FAILURE if the operation fails a needed resize. This II operation is considered to be expensive if flag position is constantly going out of bounds by a small /I amount because the resize always attempts to mininize the amount of space required to store the bits All new flags created in a resize operation (except the one being set) will be set as zero Status bit flags_set_flag(BIT_FLAGS hBit flags, int flag position); //Precondition: flag position is a non-negative integer and hBit flags is a handle to a valid Bit flags object //Postcondition: The flag at the flag position index is set to 8 Function will attempt to resize the /I internal representation if the flag position is too large instead of failing for out of bounds. Returns // SUCCESS if the operation is successful and FAILURE if the operation fails a needed resize. This II operation is considered to be expensive if flag position is constantly going out of bounds by a small /I amount because the resize always attempts to mininize the amount of space required to store the bits All new flags created in a resize operation will be set as zero Status bit_flags_unset flag(BIT_FLAGS hBit_flags, int flag position); //Precondition: flag position is a non-negative integer and hBit flags is a handle to a valid Bit flags object //Postcondition: returns the value of the flag at index flag position if it is in bounds or -1 otherwise int bit flags_check flag(BIT_FLAGS hBit_flags, int flag_position); //Precondition: hBit flags is a handle to a valid Bitflags object //Postcondition: returns the number of bits currently held by the data structure int bit_flags_get_size(BIT_FLAGS hBit flags); //Precondition: hBit flags is a handle to a valid Bitflags object //Postcondition: returns the number of bits the object CAN hold int bit_flags_get_capacity (BIT_FLAGS hBit_flags); //Precondition: phBit flags is the address of a handle to a valid Bitflags object //Postcondition: The menory for the object referred to by the handle is free'd and the handle is set to NULL void bit flags_destroy(BIT FLAGS* phBit_flags); #endif Turn in only your bit flags.h and bit flags.c files for grading. The graders will use their own main program to test your data structure but you should test it as well as you can yoursel with your own driver. The graders will also assume you are using the status.h we created in class. Please note that you may not change prototype of any of these functions as the functions must work with our driver you can only use these This program will take the first few daily assignments and combine their behaviors to make an opaque object wrapper that allows for all the behaviors we want in a bit collection data structure called BIT FLAGS #ifndef BIT FLAGS H define BIT FLAGS H include "status . h" typedef void BIT FLAGS //Intentionally leaving out a default init function to force user to at least guess at the size needed //If one WERE to be used it would have the following prototype //BIT_FLAGS bit flags init_default(void) //Precondition: number of bits is a positive integer //Postcondition: Returns the handle to a valid Bit flags object that has the ability to store up to /I number of bits bits but currently all flags are set at zero. Returns NULL on failure. The container I is assumed to hold size-number_of_bits after the init function runs BIT_FLAGS bit_flagsinit_number_of_bits (int number_of_bits); //Precondition: flag position is a non-negative integer and hBit flags is a handle to a valid Bit flags object //Postcondition: The flag at the flag position index is set to 1. Function will attempt to resize the /I internal representation if the flag position is too large instead of failing for out of bounds. Returns // SUCCESS if the operation is successful and FAILURE if the operation fails a needed resize. This II operation is considered to be expensive if flag position is constantly going out of bounds by a small /I amount because the resize always attempts to mininize the amount of space required to store the bits All new flags created in a resize operation (except the one being set) will be set as zero Status bit flags_set_flag(BIT_FLAGS hBit flags, int flag position); //Precondition: flag position is a non-negative integer and hBit flags is a handle to a valid Bit flags object //Postcondition: The flag at the flag position index is set to 8 Function will attempt to resize the /I internal representation if the flag position is too large instead of failing for out of bounds. Returns // SUCCESS if the operation is successful and FAILURE if the operation fails a needed resize. This II operation is considered to be expensive if flag position is constantly going out of bounds by a small /I amount because the resize always attempts to mininize the amount of space required to store the bits All new flags created in a resize operation will be set as zero Status bit_flags_unset flag(BIT_FLAGS hBit_flags, int flag position); //Precondition: flag position is a non-negative integer and hBit flags is a handle to a valid Bit flags object //Postcondition: returns the value of the flag at index flag position if it is in bounds or -1 otherwise int bit flags_check flag(BIT_FLAGS hBit_flags, int flag_position); //Precondition: hBit flags is a handle to a valid Bitflags object //Postcondition: returns the number of bits currently held by the data structure int bit_flags_get_size(BIT_FLAGS hBit flags); //Precondition: hBit flags is a handle to a valid Bitflags object //Postcondition: returns the number of bits the object CAN hold int bit_flags_get_capacity (BIT_FLAGS hBit_flags); //Precondition: phBit flags is the address of a handle to a valid Bitflags object //Postcondition: The menory for the object referred to by the handle is free'd and the handle is set to NULL void bit flags_destroy(BIT FLAGS* phBit_flags); #endif Turn in only your bit flags.h and bit flags.c files for grading. The graders will use their own main program to test your data structure but you should test it as well as you can yoursel with your own driver. The graders will also assume you are using the status.h we created in class. Please note that you may not change prototype of any of these functions as the functions must work with our driver you can only use these

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Infrastructure For Medical Research In Databases

Authors: Thomas Heinis ,Anastasia Ailamaki

1st Edition

1680833480, 978-1680833485

Students also viewed these Databases questions

Question

=+3. What does this public want on this issue?

Answered: 1 week ago

Question

Describe the five elements of the listening process.

Answered: 1 week ago