1 /* Littlewood-Richardson Calculator
2 * Copyright (C) 1999- Anders S. Buch (asbuch at math rutgers edu)
3 * See the file LICENSE for license information.
4 */
5
6 #include "hashtab.h"
7 #include "vector.h"
8 #include "lincomb.h"
9
10
lincomb_add_element(hashtab * dst,int c,void * elt,freekey_t freekey)11 int lincomb_add_element(hashtab *dst, int c, void *elt, freekey_t freekey)
12 {
13 hashkey_t k;
14 int *valp;
15 int newcoef;
16 int hku;
17
18 if (c == 0)
19 return 0;
20
21 k = hash_hash(dst)(elt);
22 valp = _hash_mkfind_k(dst, elt, k);
23 newcoef = (*valp += c);
24 hku = hash_key_used;
25
26 if (newcoef == 0)
27 {
28 _hash_remove_k(dst, elt, k);
29 freekey(hash_removed_key);
30 }
31 return hku;
32 }
33
34