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

Adding an SortedArray data structure #9

Merged
merged 9 commits into from Jul 11, 2016
Merged

Conversation

TheStefan
Copy link
Contributor

Implements all meaningful operations of an array list for a sorted array list. Contains test code, documentation and source.

@fragglet
Copy link
Owner

fragglet commented Apr 9, 2016

Hi! Thanks for submitting this. I have a few comments.

#ifndef ALGORITHM_SORTEDARRAY_H
#define ALGORITHM_SORTEDARRAY_H

#include "arraylist.h"
Copy link
Owner

Choose a reason for hiding this comment

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

A fundamental design decision of this library is that each pair of .c/.h files should be standalone. So it should be possible to take one of these files and just add it into a project without needing to depend on the entire library. Please refactor the code so that this is usable standalone without depending on arraylist.

@fragglet
Copy link
Owner

fragglet commented Apr 9, 2016

Additional comment: the indentation style of your code is not consistent with the rest of the library. I use tabs for indentation, spaces for alignment. See here for details:

https://blog.codinghorror.com/death-to-the-space-infidels/

@TheStefan
Copy link
Contributor Author

Okay, I'll fix the comments.

About the indentation: I suppose you mean I should use the third option from the blog article.

@fragglet
Copy link
Owner

fragglet commented Apr 9, 2016

Exactly - thanks!

@TheStefan
Copy link
Contributor Author

I have changed all the things you have commented. If there are still some problems, please let me know!

@ghost
Copy link

ghost commented Apr 16, 2016

This is neat. I will definitely be looking at the code to learn some things!

Just as a note: I'm not sure if the maintainer of this project will care or not, but I wanted to let you know that you may want to do a git rebase before he merges this in to master. In doing so, you can squash/fixup some of your commits into other ones; for example, you could make it so that your code had the correct indentation style from the beginning, instead of being fixed in a later commit.

That note aside, again, neat work. :)

@TheStefan
Copy link
Contributor Author

Thank you! I'll look into rebasing

Included header, implementation and testing. Files have been added to Makefile.am

Fixed sortedarray_index_of zero length failure.
Removed -1 from initialising right edge.

Refactoring: Replaced // comments with /* ... */ style comments

Removed some debug code which was still present.

Refactor: removed unnecessary function prototypes, removed full doc comments for static function

Refactor: indentation style while keeping 80 flow limit.

Refactoring, array syntax instead of pointers and some minor fixes.

Rename variables to be clearer.

Restructured tests around integers and fixed bugs detected by new tests.
@fragglet
Copy link
Owner

Sorry I still haven't got back to you. I'll see if I can take a look today.

if (order > 0) {
left = index + 1;
}
else {
Copy link
Owner

Choose a reason for hiding this comment

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

Should be on same line, ie.

} else {

unsigned int i;
for (i = 1; i < sortedarray->length; i++) {
assert(int_compare(
sortedarray->data[i - 1],
Copy link
Owner

Choose a reason for hiding this comment

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

Formatting is super weird here.

@fragglet
Copy link
Owner

Thanks for reworking this - it looks much better!

I noticed that the coverage analysis for the new file could be improved:

Lines executed:89.91% of 109

Any chance we can get closer to 100%?

@fragglet
Copy link
Owner

fragglet commented May 4, 2016

Ping.

@TheStefan
Copy link
Contributor Author

I did not forget. I just currently have a lot things todo.

@fragglet
Copy link
Owner

fragglet commented May 6, 2016

Cool, thanks :) No pressure.

@TheStefan
Copy link
Contributor Author

I'll take a look at it

@TheStefan TheStefan closed this Jul 11, 2016
@fragglet
Copy link
Owner

Hey, I wasn't aware you had pushed new commits since you didn't comment. Feel free to reopen if you'd still like to merge this.

@TheStefan TheStefan reopened this Jul 11, 2016
@TheStefan
Copy link
Contributor Author

Lol, next time I will give a ping.

@fragglet fragglet merged commit 990cccd into fragglet:master Jul 11, 2016
@fragglet
Copy link
Owner

Thanks!

@TheStefan
Copy link
Contributor Author

:)

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