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

Filter functions #17

Open
srdja opened this issue Mar 26, 2016 · 8 comments
Open

Filter functions #17

srdja opened this issue Mar 26, 2016 · 8 comments

Comments

@srdja
Copy link
Owner

srdja commented Mar 26, 2016

Collections should have *_filter and *_filter_mut functions so that one may do something like this:

bool predicate(void *e) {
    int el = *((int*) e);
    if (el > 5) return true;
    return false;
}

...

// filters out all integers greater than 5 by mutating the array
array_filter_mut(array1, predicate);


// filters out all integers greater than 5 and stores the filter results in a new array
Array *new_array;
if (array_filter(array2, predicate, &new_array) != CC_OK)
    ...
@srdja
Copy link
Owner Author

srdja commented Apr 12, 2016

  • Array
  • Deque
  • List
  • SList
  • HashTable
  • TreeTable
  • HashSet
  • TreeSet

@srdja srdja added the meta label Aug 7, 2016
@argonlaser
Copy link
Contributor

Hi @srdja ! Thanks for this awesome library. I was wondering if you are looking for a PR to address this issue. I would like to give a try if so.

@srdja
Copy link
Owner Author

srdja commented Feb 19, 2017

Hey @argonlaser, thanks for looking into the library and your interest in contributing. A PR addressing this issue would be most welcome!

However, it would be great if you could say on which specific collection you will be working on, so that we don't end up working on the same thing. Also if ever need any help along the way feel free ask. :-)

@argonlaser
Copy link
Contributor

As I see it, array.c already has this function. I think I should be using that as a reference for the other collections as well. Please correct me if I am wrong. I would like to start out with the deque and list initially.

@srdja
Copy link
Owner Author

srdja commented Feb 19, 2017

Yup, you're right, filter functions (+ tests) have been implemented for the Array so you can use that as a reference, at least on some higher level. As far as the actual implementations go, I think that implementing filter for List should be pretty straightforward. Deque on the other hand, might be a little bit tricky, especially filter_mut, which modifies the actual collection.

@argonlaser
Copy link
Contributor

argonlaser commented Feb 20, 2017

Hey @srdja ! As a start, I have raised the PR #80 that adds filter functions for list and slist. Please do have a look.

@argonlaser
Copy link
Contributor

Hi @srdja ! I would like to try the filter functions for deque and remaining data structures as well when I get some time. I am trying to understand the implementation. Will raise a PR whenever possible. Cheers 👍

@argonlaser
Copy link
Contributor

Raised #82 for deque filter functions as per the currently written tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants