From 2f5ea6bbd8c8c8a01f87bf3cdb9e1e1eab6e7fd6 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 28 Mar 2010 13:40:25 -0700 Subject: [PATCH] sort: New function sort_distinct_execute(). --- src/math/sort.c | 17 +++++++++++++++++ src/math/sort.h | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/src/math/sort.c b/src/math/sort.c index 61256ccdbc..752d527000 100644 --- a/src/math/sort.c +++ b/src/math/sort.c @@ -219,6 +219,23 @@ sort_execute_1var (struct casereader *input, const struct variable *var) subcase_destroy (&sc); return reader; } + +/* Reads all the cases from INPUT. Sorts the cases according to ORDERING, + combining cases that have the same ORDERING values using COMBINE. + Returns the sorted cases in a new casereader. */ +struct casereader * +sort_distinct_execute (struct casereader *input, + const struct subcase *ordering, + sort_distinct_combine_func *combine, + sort_distinct_destroy_func *destroy, + void *aux) +{ + struct casewriter *output = + sort_distinct_create_writer (ordering, casereader_get_proto (input), + combine, destroy, aux); + casereader_transfer (input, output); + return casewriter_make_reader (output); +} struct pqueue { diff --git a/src/math/sort.h b/src/math/sort.h index 06227d64ba..99395eb89e 100644 --- a/src/math/sort.h +++ b/src/math/sort.h @@ -39,5 +39,10 @@ struct casewriter *sort_distinct_create_writer (const struct subcase *, sort_distinct_combine_func *, sort_distinct_destroy_func *, void *aux); +struct casereader *sort_distinct_execute (struct casereader *, + const struct subcase *, + sort_distinct_combine_func *, + sort_distinct_destroy_func *, + void *aux); #endif /* math/sort.h */ -- 2.30.2