Actual source code: hashmapiv.h
1: #ifndef _PETSC_HASHMAPIV_H
2: #define _PETSC_HASHMAPIV_H
4: #include <petsc/private/hashmap.h>
6: /* SUBMANSEC = Sys */
7: /*
8: Hash map from PetscInt --> PetscScalar
9: */
10: PETSC_HASH_MAP(HMapIV, PetscInt, PetscScalar, PetscHashInt, PetscHashEqual, -1)
12: /*MC
13: PetscHMapIVAddValue - Add value to the value of a given key if the key exists,
14: otherwise, insert a new (key,value) entry in the hash table
16: Synopsis:
17: #include <petsc/private/hashmapiv.h>
18: PetscErrorCode PetscHMapIVAddValue(PetscHMapT ht,PetscInt key,PetscScalar val)
20: Input Parameters:
21: + ht - The hash table
22: . key - The key
23: - val - The value
25: Level: developer
27: .seealso: `PetscHMapIVGet()`, `PetscHMapIVIterSet()`, `PetscHMapIVSet()`
28: M*/
29: static inline PetscErrorCode PetscHMapIVAddValue(PetscHMapIV ht, PetscInt key, PetscScalar val)
30: {
31: int ret;
32: khiter_t iter;
33: PetscFunctionBeginHot;
35: iter = kh_put(HMapIV, ht, key, &ret);
36: PetscHashAssert(ret >= 0);
37: if (ret) kh_val(ht, iter) = val;
38: else kh_val(ht, iter) += val;
39: PetscFunctionReturn(PETSC_SUCCESS);
40: }
42: #endif /* _PETSC_HASHMAPIV_H */