aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/utils.c b/src/utils.c
index 21ba882f..0f20435e 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -387,24 +387,23 @@ int num_items(const ReflItemList *items)
}
-unsigned int *items_to_counts(ReflItemList *items)
+void union_op_items(ReflItemList *items, ReflItemList *newi)
{
- unsigned int *c;
- int i;
+ int n, i;
- c = new_list_count();
+ n = num_items(newi);
+ for ( i=0; i<n; i++ ) {
- for ( i=0; i<num_items(items); i++ ) {
- struct refl_item *r;
- r = get_item(items, i);
- set_count(c, r->h, r->k, r->l, 1);
- }
+ struct refl_item *r = get_item(newi, i);
+ if ( find_op(items, r->op) ) continue;
+
+ add_item_with_op(items, r->h, r->k, r->l, r->op);
- return c;
+ }
}
-void union_op_items(ReflItemList *items, ReflItemList *newi)
+void union_items(ReflItemList *items, ReflItemList *newi)
{
int n, i;
@@ -412,9 +411,28 @@ void union_op_items(ReflItemList *items, ReflItemList *newi)
for ( i=0; i<n; i++ ) {
struct refl_item *r = get_item(newi, i);
- if ( find_op(items, r->op) ) continue;
+ if ( find_item(items, r->h, r->k, r->l) ) continue;
add_item_with_op(items, r->h, r->k, r->l, r->op);
}
}
+
+
+ReflItemList *intersection_items(ReflItemList *i1, ReflItemList *i2)
+{
+ int n, i;
+ ReflItemList *res = new_items();
+
+ n = num_items(i1);
+ for ( i=0; i<n; i++ ) {
+
+ struct refl_item *r = get_item(i1, i);
+ if ( find_item(i2, r->h, r->k, r->l) ) {
+ add_item_with_op(res, r->h, r->k, r->l, r->op);
+ }
+
+ }
+
+ return res;
+}