Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C programming language !!! This programming asigniment will taloe the fint few dailybotsewoek aseignments and combine their behaviors to make an opaque object wrapper that

C programming language !!! image text in transcribed
image text in transcribed
This programming asigniment will taloe the fint few dailybotsewoek aseignments and combine their behaviors to make an opaque object wrapper that allows for all the behaviors we want in a bit collection data structure callexd BIT FL.AGS. \#ifndef BIT.FLAGS.H \#define BIT FL.AGS.H \#include "status . h" typedef void: BIT FI.AGS; /tentionally leaving out a default init function to foree axer to //at least guess at the size needed. If one WBRE to be wad it wrould /have the following prototype: //BIT FLAGS bit_ftagninit_default (roid): / Precandition: number of bits is a ponitiee integer- //Postcondition: Retarns the handle to a ralid Bit-flags object that // has the ability to store up to number_of.bits bits but currently (1) all flagn are sef at zero. Returns NtLL en failare. The canfainer is // assumed to hold size=number_of-bits after the init function ravs. BIT.FLAGS bit.flags.iait_aumber_of.bits (iat aumber-of.bits): //Precondition: flag-position is a Non-negatiee integer and h Bit-flags // is a handle to a valid Bit.flags object. Pontcondition: The flag 1/ at the flag-ponition indre in set te t. Functien will attempt to // resiae the internul representation if the flag-position is too // large initead of faiting for out of bownds. Retwrns 1/ SUCCESS if the operation is suceessful and FALURE if the 1. operation fails a needed resizc. This operation is considered to // be expensive if flag-position is constantly going ost of bounds 1. by a smoll amosnt because the resize almags attempts to minimize // the amount of epace required to store the bits. All new flags /1. ereated in a resize eperation (exeept the ene bring set. will be /l set as zero. Status bit-flags-set-flag (BTT.FLAGS hBituflags, int flag-position): //Precondition: flag-ponition is a not-negaliee infeger and hBitflag s /7. is a handle to a valid Bit-flags abject. // Posteondition: The flag at the flag-penition index is set to 0. Function will aftempt to resite the infernat repreacatation 1. if the flag-position is toe large instead of failing for out of // bounds. Returno SUCCESS if the eperation is suceesulul and 1/ FALLLRE if the operetion fails a necded resize. This operation // is considered to be expensive if fleg-position is constantly /1. going out of beundn by a small amosnt becaune the resize alwayn // attempts to minimize the amount of space required to store the /l bits. All new flags ereated in a resize aperatian urill be set as zero. Status bit flags-anset,flag (BTT FLAGs hBit_flags, int flag-posirion): //Precondition: fiag-ponition in a non-negatiee integer and A Bit-flag* /. is a handle to a valid Bit.Jlags object. //Posteondition returns the value of the f lag at index flag-position // if it in in beunds or 1 otherwine. int bit-flagsi-check-flag (BIT.FLAGS hBit_flags, int flag-positiou); //Precondition: hBitflags is a handle to a valid Bit.flags object. /Posteondition returas tae number of bits currently held by the data structus int bit-flags-get-size (BIT FLAGS hBit_flags): //Precondition: hBit.flags is a handle to a valid Bit.flags object. //Posteondition: returns the number of bitn the object CAN hald. int bit-flags-get-capacity (BTT FLAGS hBit flags): / Precondition: phBit.ftage is the addrens of a hendte to a valial Bit.flags ob //Postcondition: The memory for the ebject 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 Hags.h and bit flags.e 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 statusih 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 write it) and explain why you think it should be added (what it would do and how it would be useful). At the top of your code you should have a comment soction that has the following format: Author: Date: Purpose: Purpose of this assignment in your own words>

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions