Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language please This programming aseigntment will talos the fint few dailykotsewoek aseignments and combine their behayiors to make an opaque object wrapper that allows

C language please image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
This programming aseigntment will talos the fint few dailykotsewoek aseignments and combine their behayiors 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 FLAGS.H \#include "status . h" typedef void: BIT.FI.AGS; /tentionally teaving out a default init fmnction to foree axer to /at leant gues, at the size needed. If ome WBRE to be wed it would /have the following prototype: //BIT FLAGS bit.ftagkinit.default (roid): / Precandition: number of bitn 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 5 ut currently 1/ all flagn are sef at zero. Returns NiLL on failare. The canfainer is assumed to hold size=number-of-bits after the init function ravs. BIT.FLACS bit.flags.iait _ummber_of.bits (iat aumber -of.bits): //Precondition: flag-position is a Non-negatiee integer and hB it-flags // is a handle to a valid Bit.flags object. Ponteondition: The flag (l at the flag-position 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 SUCCESS if the operation is successful and FALURE if the / operation fails a needed resizc. This operation is considered to // be expensive if flag-position is censtontly going ost of bounds /1. by a smoll amosnt because the resize almags attempts to minimize // the amount of space required to store the bits. AIl new flags // created 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 integer and hBitflag s is a handle to a valid Bit-flags abject. / Posteondition: The flag at the flag-penition index is set to O. Function will attempt to resite the infernat repreaentatioa /. if the fleg-pesition is toe large instead of failing for out of // bounds. Return. SUCCESS if the eperation is success ful and FALLLRE if the operetion fails a necded resize. This operation is considered to be expensiee if fleg-position is constantly // going out of beundn by a small amosnt becaune the resize alwayn // attempts to minimize the amount of space required to store the / bits. All new flags ereated in a resiae aperatian urill be set as zero. Status bit flags-anset,flag (BTT FLAGs hBit_flags, int flag-position): //Precondition: fiag-penition is 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: hBit-flags is a handle to a valid Bit.flags object. /Postconditionz 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 (BIT FLAGS hBit flags): //Precondition phBit.flags is the addrens of a hendte to a valial Bit.flags ob //Postcondition: The memory for the ebject referred to by the handle /s 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.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 hes the following format: Author: Date: Purpose: to make an opaque object wrapper that allows for all the behaviors we want in a bit collection data structur called BIT.FLAGS. \#ifndef BIT.FLAGS.H \#define BIT FLAGS.H \#include "status. h" typedef void : BIT.FLAGS; //utentionally learing 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 posifive integer. //osteondition: Returns the handle to a valid Bit.flags object that // has the ability to store up to number_of_bits bits but currently // all flags are set at zero. Returns NULL on failure. The container is assumed to hold size=number-of-bits after the init function runs. BIT.FLAGS bit -flags_init -numer 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. Posteondition: 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 FALLURE 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 small amount because the resize aluays 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 (BTT-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. //Posteondition: The flag at the flag-position index is set to D. Function will attempt to resize the internal representation /f the flag-position is too large instead of failing for out of bounds. Returns SUCCESs if the operation is successful and FAlLURE 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 small amount 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 (BTT 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. /Posteondition: 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 ealid Bit-flags object. /Posteondition: returns the number of bits eurrently held by the data struetu int bit flags,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 bit-flags-get-capacity (BIT.FLAGS hBit-flags): //Precondition: phBit-flags is the address of a handle to a valid Bit-flags ob //Posteondition: 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); \#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 stat us.h we created in class. Please note that you muy 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 section that has the following format: Author: Effort: Time you spent on this project> 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

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago