{"action":"created","issue":{"url":"https://api.github.com/repos/israel-lugo/tsarray/issues/12","repository_url":"https://api.github.com/repos/israel-lugo/tsarray","labels_url":"https://api.github.com/repos/israel-lugo/tsarray/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/israel-lugo/tsarray/issues/12/comments","events_url":"https://api.github.com/repos/israel-lugo/tsarray/issues/12/events","html_url":"https://github.com/israel-lugo/tsarray/issues/12","id":285287236,"number":12,"title":"Create max and min operators","user":{"login":"israel-lugo","id":19789187,"avatar_url":"https://avatars1.githubusercontent.com/u/19789187?v=4","gravatar_id":"","url":"https://api.github.com/users/israel-lugo","html_url":"https://github.com/israel-lugo","followers_url":"https://api.github.com/users/israel-lugo/followers","following_url":"https://api.github.com/users/israel-lugo/following{/other_user}","gists_url":"https://api.github.com/users/israel-lugo/gists{/gist_id}","starred_url":"https://api.github.com/users/israel-lugo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/israel-lugo/subscriptions","organizations_url":"https://api.github.com/users/israel-lugo/orgs","repos_url":"https://api.github.com/users/israel-lugo/repos","events_url":"https://api.github.com/users/israel-lugo/events{/privacy}","received_events_url":"https://api.github.com/users/israel-lugo/received_events","type":"User","site_admin":false},"labels":[{"id":669631669,"url":"https://api.github.com/repos/israel-lugo/tsarray/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-01-01T03:49:19Z","updated_at":"2018-03-12T02:58:22Z","closed_at":null,"author_association":"OWNER","body":"It would be nice to have max and min operators, which return respectively the largest or smallest element. Naturally, they would need to receive a key function as a parameter, which takes an element and returns an ordinal key.\r\n\r\nGiven an array ``fooarray`` of items of type ``foo_t``, the function signature should be something like this:\r\n```c\r\nfoo_t *fooarray_max(const fooarray *array, long (*key)(foo_t *));\r\n```\r\n\r\nProblem: we're limiting the key to the width of a ``long``. That may be too limiting, if the items have a larger key space. One alternative would be to receive an abstract comparison function, but that would make an efficient implementation more difficult to achieve."},"comment":{"url":"https://api.github.com/repos/israel-lugo/tsarray/issues/comments/372180825","html_url":"https://github.com/israel-lugo/tsarray/issues/12#issuecomment-372180825","issue_url":"https://api.github.com/repos/israel-lugo/tsarray/issues/12","id":372180825,"user":{"login":"israel-lugo","id":19789187,"avatar_url":"https://avatars1.githubusercontent.com/u/19789187?v=4","gravatar_id":"","url":"https://api.github.com/users/israel-lugo","html_url":"https://github.com/israel-lugo","followers_url":"https://api.github.com/users/israel-lugo/followers","following_url":"https://api.github.com/users/israel-lugo/following{/other_user}","gists_url":"https://api.github.com/users/israel-lugo/gists{/gist_id}","starred_url":"https://api.github.com/users/israel-lugo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/israel-lugo/subscriptions","organizations_url":"https://api.github.com/users/israel-lugo/orgs","repos_url":"https://api.github.com/users/israel-lugo/repos","events_url":"https://api.github.com/users/israel-lugo/events{/privacy}","received_events_url":"https://api.github.com/users/israel-lugo/received_events","type":"User","site_admin":false},"created_at":"2018-03-12T02:58:22Z","updated_at":"2018-03-12T02:58:22Z","author_association":"OWNER","body":"The function signatures should therefore be:\r\n\r\n```c\r\nfoo_t *fooarray_min(const fooarray *array, int (*cmp)(const foo_t *a, const foo_t *b, void *arg));\r\nfoo_t *fooarray_max(const fooarray *array, int (*cmp)(const foo_t *a, const foo_t *b, void *arg));\r\n```"}}
{"actor":{"display_login":"israel-lugo"}}