Actual source code: hashmapiv.h
1: #pragma once
3: #include <petsc/private/hashmap.h>
5: /* SUBMANSEC = Sys */
6: /*
7: Hash map from PetscInt --> PetscScalar
8: */
9: PETSC_HASH_MAP(HMapIV, PetscInt, PetscScalar, PetscHashInt, PetscHashEqual, -1)
11: /*MC
12: PetscHMapIVAddValue - Add value to the value of a given key if the key exists,
13: otherwise, insert a new (key,value) entry in the hash table
15: Synopsis:
16: #include <petsc/private/hashmapiv.h>
17: PetscErrorCode PetscHMapIVAddValue(PetscHMapT ht,PetscInt key,PetscScalar val)
19: Input Parameters:
20: + ht - The hash table
21: . key - The key
22: - val - The value
24: Level: developer
26: .seealso: `PetscHMapIVGet()`, `PetscHMapIVIterSet()`, `PetscHMapIVSet()`
27: M*/
28: static inline PetscErrorCode PetscHMapIVAddValue(PetscHMapIV ht, PetscInt key, PetscScalar val)
29: {
30: int ret;
31: khiter_t iter;
33: PetscFunctionBeginHot;
34: PetscAssertPointer(ht, 1);
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: }