subcase: New functions subcase_concat() and subcase_concat_always().
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 28 Mar 2010 20:45:44 +0000 (13:45 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 3 May 2010 04:29:21 +0000 (21:29 -0700)
src/data/subcase.c
src/data/subcase.h

index 32056215e4ace37d4fcd9b544c3e48c493d82dec..bac32ddefb21eb0fc2e1fde395c08bfc0575e188 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -201,6 +201,30 @@ subcase_add_proto_always (struct subcase *sc, const struct caseproto *proto)
   invalidate_proto (sc);
 }
 
+void
+subcase_concat (struct subcase *sc, const struct subcase *other)
+{
+  size_t i;
+
+  for (i = 0; i < other->n_fields; i++)
+    {
+      const struct subcase_field *f = &other->fields[i];
+      subcase_add (sc, f->case_index, f->width, f->direction);
+    }
+}
+
+void
+subcase_concat_always (struct subcase *sc, const struct subcase *other)
+{
+  size_t i;
+
+  for (i = 0; i < other->n_fields; i++)
+    {
+      const struct subcase_field *f = &other->fields[i];
+      subcase_add_always (sc, f->case_index, f->width, f->direction);
+    }
+}
+
 /* Obtains a caseproto for a case described by SC.  The caller
    must not modify or unref the returned case prototype. */
 const struct caseproto *
index 71bf6fd7cc33d4227a4e3c4380f6773a1bfc599a..6f778b12f4d5b47e9da036ac53ff74293015de02 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -74,6 +74,9 @@ void subcase_add_var_always (struct subcase *, const struct variable *,
                              enum subcase_direction);
 void subcase_add_proto_always (struct subcase *, const struct caseproto *);
 
+void subcase_concat (struct subcase *, const struct subcase *);
+void subcase_concat_always (struct subcase *, const struct subcase *);
+
 const struct caseproto *subcase_get_proto (const struct subcase *);
 
 static inline bool subcase_is_empty (const struct subcase *);