Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of Bitset #87

Closed
wants to merge 10 commits into from
Closed

Conversation

nimitbhardwaj
Copy link
Contributor

First of all, I add definitions of the basic functions for the bitset, like creation, deletion, access of bits, manipulation of bits etc, @srdja please have a check, as soon the work for it will be completed I will merge it to the master, as you gave me the write access, or otherwise you can do it

enum cc_stat bitset_setbits_range (Bitset *bs, size_t l, size_t r);
enum cc_stat bitset_unsetbits_range (Bitset *bs, size_t l, size_t r);
enum cc_stat bitset_flipbits_range (Bitset *bs, size_t l, size_t r);
enum cc_stat bitset_setbit_at (Bitset *bs, size_t position);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum cc_stat bitset_set_at(Bitset *bs, size_t index)


enum cc_stat bitset_setbits_range (Bitset *bs, size_t l, size_t r);
enum cc_stat bitset_unsetbits_range (Bitset *bs, size_t l, size_t r);
enum cc_stat bitset_flipbits_range (Bitset *bs, size_t l, size_t r);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum cc_stat bitset_flip_range(Bitset *bs, size_t from, size_t to);

void bitset_destroy (Bitset *bs);
void bitset_destroy_free (Bitset *bs);

enum cc_stat bitset_setbits_range (Bitset *bs, size_t l, size_t r);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum cc_stat bitset_set_range(Bitset *bs, size_t from, size_t to);

void bitset_destroy_free (Bitset *bs);

enum cc_stat bitset_setbits_range (Bitset *bs, size_t l, size_t r);
enum cc_stat bitset_unsetbits_range (Bitset *bs, size_t l, size_t r);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum cc_stat bitset_unset_range(Bitset *bs, size_t from, size_t to);

enum cc_stat bitset_unsetbits_range (Bitset *bs, size_t l, size_t r);
enum cc_stat bitset_flipbits_range (Bitset *bs, size_t l, size_t r);
enum cc_stat bitset_setbit_at (Bitset *bs, size_t position);
enum cc_stat bitset_unsetbit_at (Bitset *bs, size_t position);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum cc_stat bitset_unset_at(Bitset *bs, size_t index);

enum cc_stat bitset_and_operator (Bitset *bs1, Bitset *bs2);
enum cc_stat bitset_or_operator (Bitset *bs1, Bitset *bs2);
enum cc_stat bitset_xor_operator (Bitset *bs1, Bitset *bs2);
enum cc_stat bitset_not_operator (Bitset *bs);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum cc_stat bitset_not(Bitset *bs);

enum cc_stat bitset_left_shift_cyclic (Bitset *bs);
enum cc_stat bitset_right_shift (Bitset *bs);
enum cc_stat bitset_right_shift_cyclic (Bitset *bs);
int bitset_count_ones (Bitset *bs);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t bitset_count_ones(Bitset *bs);

enum cc_stat bitset_right_shift (Bitset *bs);
enum cc_stat bitset_right_shift_cyclic (Bitset *bs);
int bitset_count_ones (Bitset *bs);
int bitset_count_zeros (Bitset *bs);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t bitset_count_zeros(Bitset *bs);

int bitset_count_zeros (Bitset *bs);
enum cc_stat bitset_add (Bitset *bs1, Bitset *bs2, Bitset **out);
enum cc_stat bitset_sub (Bitset *bs1, Bitset *bs2, Bitset **out);
enum cc_stat bitset_multiply (Bitset *bs1, Bitset *bs2, Bitset **out);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't having names like multiply and sub a bit inconsistent? They should either both be abbreviated or not, but not mixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok got it

enum cc_stat bitset_setbit_at (Bitset *bs, size_t position);
enum cc_stat bitset_unsetbit_at (Bitset *bs, size_t position);
enum cc_stat bitset_flipbit_at (Bitset *bs, size_t position);
int bitset_getbit_at (Bitset *bs, size_t position);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is out of bounds error supposed to be handled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for out of bounds error i will return -1, otherwise if bit is unset its 0 else 1

@nimitbhardwaj
Copy link
Contributor Author

I made the pull request, I didnt see the changes suggested, i saw them

@nimitbhardwaj
Copy link
Contributor Author

I do the given changes, and the work for the functions which i made like flip, unset etc is not over as i had not taken the care for the number of ones and zeros, i forgot that, that time, i do it too

@nimitbhardwaj
Copy link
Contributor Author

Now did it

@nimitbhardwaj
Copy link
Contributor Author

Oops error, i fix it

@nimitbhardwaj
Copy link
Contributor Author

Implemented and, or, not, xor functions

@srdja srdja closed this Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants