Skip to content

Discussion about Quick sort #25

Description

@jovany-wang

The current quick sort algorithm is too concrete. It's better to make it more generic. The points that I listed here:

  1. Make partition can be rewrite and we provide an implementation for it. This means we should make partition as an interface and provide a default implementation.

  2. Make quick_sort API can be passed any iterable type. In another word, The API should looks like:

void quick_sort(std::random_iterator<?> begin, std::random_iterator<?> end);
  1. Provide another overloading API for quick_sort which can be passed a comparer:
using Comparable = std::function<bool (const random_iterator<?> &prev, const random_iterator<?> &next)>;
void quick_sort(std::random_iterator<?> begin, std::random_iterator<?> end, Comparable comparer);

TODOs:

  • implementation
  • benchmark
  • ut
  • docs

Activity

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions