Question: Help needed. COMP1020 Program1 Fall 2017 This program will take the first few daily assignments and combine their behaviors to make an opaque object wrapper

Help needed.
COMP1020 Program1 Fall 2017 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 nifndef BIT FLAGS H #define BITFLAGSH #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 number of bits bits but currently al1 flags are set at zero. Returns NULL on failure. The container // is assuned to hold size number_ ofbits after the init function runs BIT FLAGS bit flags init 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 // internal representation if the flag position is too large instead of failing for out of bounds. Returns SUCCESS if the operation is successful and FATLURE if the operation fails a needed resize. This /I operation is considered to be expensive if flag position is constantly going out of bounds by a small anount because the resize always attempts to minimize 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 Function will 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 1 operation is considered to be expensive if flag position is constantly going out of bounds by a small /1anount because the resize always attempts to minimize 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(BITFLAGS hait 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 bitflags_check flag(BIT FLAGS hBit flags, int flag position); //Precondition: hBit flags is a handle to a valid Bit flags object //Postcondition: returns the number of bits currently held by the data structure int bitflags get size(BIT FLAGS hBit flags) //Precondition: hBit flags is a handle to a valid Bit flags object //Postcondition: returns the number of bits the object CAN hold int bitflags_get capacity (BIT FLAGS hBit_flags); //Precondition: phBit flags is the address of a handle to a valid Bit flags object //Postcondition: The memory 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); Rendif 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 COMP1020 Program1 Fall 2017 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 nifndef BIT FLAGS H #define BITFLAGSH #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 number of bits bits but currently al1 flags are set at zero. Returns NULL on failure. The container // is assuned to hold size number_ ofbits after the init function runs BIT FLAGS bit flags init 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 // internal representation if the flag position is too large instead of failing for out of bounds. Returns SUCCESS if the operation is successful and FATLURE if the operation fails a needed resize. This /I operation is considered to be expensive if flag position is constantly going out of bounds by a small anount because the resize always attempts to minimize 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 Function will 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 1 operation is considered to be expensive if flag position is constantly going out of bounds by a small /1anount because the resize always attempts to minimize 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(BITFLAGS hait 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 bitflags_check flag(BIT FLAGS hBit flags, int flag position); //Precondition: hBit flags is a handle to a valid Bit flags object //Postcondition: returns the number of bits currently held by the data structure int bitflags get size(BIT FLAGS hBit flags) //Precondition: hBit flags is a handle to a valid Bit flags object //Postcondition: returns the number of bits the object CAN hold int bitflags_get capacity (BIT FLAGS hBit_flags); //Precondition: phBit flags is the address of a handle to a valid Bit flags object //Postcondition: The memory 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); Rendif 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
