Question: C programming This program will take the first few daily assignments and combine their behaviors to make an opaque object wrapper that allows for all
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 #1fndet BIT-FLAGS-H define BIT FLAGSH #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(vold) I/Precondition: number of bits is a positive integer / /Postcondition: Returns the handle to a valid 8it flags object that has the ability to store up to // nber-of-bits bits but currently all flags are set at zero. Returns NULL on failure. The container is assuned to hold sizesnumber of bits after the init function runs IT FLAGS bit flags init number of bits(int number_ofbits): //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 wil1 attenpt to resize the / 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 // operation is considered to be expensive if flag position is constantly going out of bounds by a 11 anount because the resize always attenpts to mininize the anount 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 h8it 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 e. Function will attenpt to resize the I Internal representation if the flag pesition is too large instead of failing for out of bounds. Returns SUCCESS if the operation is successful and FAILURE Sf the operation fails a needed resize. This // operation is considered to b expensive if flag_position is constantly going out of bounds by sean anount because the resize always attempts to minimize the amount of space required to store the bits Al1 new flags created in a resize operation will be set as zero. Status bit flags unset flag(BIT FLAGSs hBitflags, int flag position) //Precondition: flag position is a non-negative integer and heit 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: h8it flags is a handle to a valld Bit flags object //Postcondition: returns the nunber of bits currently held by the data structure int bit flags get ssze(BIT_FLAGS HBIflags); //Precondition: hBit flags is a handle to a valid Bit flags object. /Postcondition: returns the nunber of bits the object CAN hold. int bit flags get capacity(BIT FLAGS hsit flags): //Precondition: phBst flags is the address of a handle to a valid Bit flags object / /Postcondition: The menory for the object referred to by the handle is free'd and the handle is set to NULL void bitflags 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 yourself 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. In the comments section of your code think about your data structure and what might be missing. Come up with one proposed function that you could add to the interface (you do not have to
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
