sort: New function sort_distinct_execute().
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 28 Mar 2010 20:40:25 +0000 (13:40 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 3 May 2010 04:29:21 +0000 (21:29 -0700)
src/math/sort.c
src/math/sort.h

index 9c2118985c59583bfe42d66ed5152452e3417d3b..233d0f585c680e8c75a963d5aee7d7c72fab325f 100644 (file)
@@ -216,6 +216,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);
+}
 \f
 struct pqueue
   {
index 06227d64ba670cd21013d4b267134fd10238b5c7..99395eb89eedfde6f134b10d7dd76380ee56a656 100644 (file)
@@ -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 */