PETSc version 3.15.5
Fix/Edit manual page

# PetscHMapT

Hash table map

### Synopsis

    /*MC
      PetscHMapTCreate - Create a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTCreate(PetscHMapT *ht)

      Output Parameter:
    . ht - The hash table

    .seealso: PetscHMapTDestroy()
    M*/

    /*MC
      PetscHMapTDestroy - Destroy a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTDestroy(PetscHMapT *ht)

      Input Parameter:
    . ht - The hash table

    .seealso: PetscHMapTCreate()
    M*/

    /*MC
      PetscHMapTReset - Reset a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTReset(PetscHMapT ht)

      Input Parameter:
    . ht - The hash table

    .seealso: PetscHMapTClear()
    M*/

    /*MC
      PetscHMapTDuplicate - Duplicate a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTDuplicate(PetscHMapT ht,PetscHMapT *hd)

      Input Parameter:
    . ht - The source hash table

      Output Parameter:
    . ht - The duplicated hash table

    .seealso: PetscHMapTCreate()
    M*/

    /*MC
      PetscHMapTClear - Clear a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTClear(PetscHMapT ht)

      Input Parameter:
    . ht - The hash table

    .seealso: PetscHMapTReset()
    M*/

    /*MC
      PetscHMapTResize - Set the number of buckets in a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTResize(PetscHMapT ht,PetscInt nb)

      Input Parameters:
    + ht - The hash table
    - nb - The number of buckets

    .seealso: PetscHMapTCreate()
    M*/

    /*MC
      PetscHMapTGetSize - Get the number of entries in a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTGetSize(PetscHMapT ht,PetscInt *n)

      Input Parameter:
    . ht - The hash table

      Output Parameter:
    . n - The number of entries

    .seealso: PetscHMapTResize()
    M*/

    /*MC
      PetscHMapTGetCapacity - Get the current size of the array in the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTGetCapacity(PetscHMapT ht,PetscInt *n)

      Input Parameter:
    . ht - The hash table

      Output Parameter:
    . n - The capacity

    .seealso: PetscHMapTResize(), PetscHMapTGetSize()
    M*/

    /*MC
      PetscHMapTHas - Query for a key in the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTHas(PetscHMapT ht,KeyType key,PetscBool *has)

      Input Parameters:
    + ht  - The hash table
    - key - The key

      Output Parameter:
    . has - Boolean indicating whether key is in the hash table

    .seealso:  PetscHMapTGet(), PetscHMapTSet(), PetscHMapTFind()
    M*/

    /*MC
      PetscHMapTGet - Get the value for a key in the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTGet(PetscHMapT ht,KeyType key,ValType *val)

      Input Parameters:
    + ht  - The hash table
    - key - The key

      Output Parameter:
    . val - The value

    .seealso:  PetscHMapTSet(), PetscHMapTIterGet()
    M*/

    /*MC
      PetscHMapTSet - Set a (key,value) entry in the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTSet(PetscHMapT ht,KeyType key,ValType val)

      Input Parameters:
    + ht  - The hash table
    . key - The key
    - val - The value

    .seealso: PetscHMapTGet(), PetscHMapTIterSet()
    M*/

    /*MC
      PetscHMapTDel - Remove a key and its value from the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTDel(PetscHMapT ht,KeyType key)

      Input Parameters:
    + ht  - The hash table
    - key - The key

    .seealso: PetscHMapTHas(), PetscHMapTIterDel()
    M*/

    /*MC
      PetscHMapTQuerySet - Query and set a (key,value) entry in the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTQuerySet(PetscHMapT ht,KeyType key,ValType val,PetscBool *missing)

      Input Parameters:
    + ht  - The hash table
    . key - The key
    - val - The value

      Output Parameter:
    . missing - Boolean indicating whether the key was missing

    .seealso: PetscHMapTQueryDel(), PetscHMapTSet()
    M*/

    /*MC
      PetscHMapTQueryDel - Query and remove a (key,value) entry from the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTQueryDel(PetscHMapT ht,KeyType key,PetscBool *present)

      Input Parameters:
    + ht  - The hash table
    - key - The key

      Output Parameter:
    . present - Boolean indicating whether the key was present

    .seealso: PetscHMapTQuerySet(), PetscHMapTDel()
    M*/

    /*MC
      PetscHMapTFind - Query for key in the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTFind(PetscHMapT ht,KeyType key,PetscHashIter *iter,PetscBool *found)

      Input Parameters:
    + ht  - The hash table
    - key - The key

      Output Parameter:
    + iter - Iterator referencing the value for key
    - found - Boolean indicating whether the key was present

    .seealso: PetscHMapTIterGet(), PetscHMapTIterDel()
    M*/

    /*MC
      PetscHMapTPut - Set a key in the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTPut(PetscHMapT ht,KeyType key,PetscHashIter *iter,PetscBool *missing)

      Input Parameters:
    + ht  - The hash table
    - key - The key

      Output Parameter:
    + iter - Iterator referencing the value for key
    - missing - Boolean indicating whether the key was missing

    .seealso: PetscHMapTIterSet(), PetscHMapTQuerySet(), PetscHMapTSet()
    M*/

    /*MC
      PetscHMapTIterGet - Get the value referenced by an iterator in the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTIterGet(PetscHMapT ht,PetscHashIter iter,ValType *val)

      Input Parameters:
    + ht   - The hash table
    - iter - The iterator

      Output Parameter:
    . val  - The value

    .seealso: PetscHMapTFind(), PetscHMapTGet()
    M*/

    /*MC
      PetscHMapTIterSet - Set the value referenced by an iterator in the hash

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTIterSet(PetscHMapT ht,PetscHashIter iter,ValType val)

      Input Parameters:
    + ht   - The hash table
    . iter - The iterator
    - val  - The value

    .seealso: PetscHMapTPut(), PetscHMapTQuerySet(), PetscHMapTSet()
    M*/

    /*MC
      PetscHMapTIterDel - Remove the (key,value) referenced by an iterator from the hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTIterDel(PetscHMapT ht,PetscHashIter iter)

      Input Parameters:
    + ht   - The hash table
    - iter - The iterator

    .seealso: PetscHMapTFind(), PetscHMapTQueryDel(), PetscHMapTDel()
    M*/

    /*MC
      PetscHMapTGetKeys - Get all keys from a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTGetKeys(PetscHMapT ht,PetscInt *off,KeyType array[])

      Input Parameters:
    + ht    - The hash table
    . off   - Input offset in array (usually zero)
    - array - Array where to put hash table keys into

      Output Parameter:
    + off   - Output offset in array (output offset = input offset + hash table size)
    - array - Array filled with the hash table keys

    .seealso: PetscHSetTGetSize(), PetscHMapTGetVals()
    M*/

    /*MC
      PetscHMapTGetVals - Get all values from a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTGetVals(PetscHMapT ht,PetscInt *off,ValType array[])

      Input Parameters:
    + ht    - The hash table
    . off   - Input offset in array (usually zero)
    - array - Array where to put hash table values into

      Output Parameter:
    + off   - Output offset in array (output offset = input offset + hash table size)
    - array - Array filled with the hash table values

    .seealso: PetscHSetTGetSize(), PetscHMapTGetKeys()
    M*/

    /*MC
      PetscHMapTGetPairs - Get all (key,value) pairs from a hash table

      Synopsis:
      #include <petsc/private/hashmap.h>
      PetscErrorCode PetscHMapTGetPairs(PetscHMapT ht,PetscInt *off,KeyType karray[],ValType varray[])

      Input Parameters:
    + ht    - The hash table
    . off   - Input offset in array (usually zero)
    - karray - Array where to put hash table keys into
    - varray - Array where to put hash table values into

      Output Parameter:
    + off   - Output offset in array (output offset = input offset + hash table size)
    - karray - Array filled with the hash table keys
    - varray - Array filled with the hash table values

    .seealso: PetscHSetTGetSize(), PetscHMapTGetKeys(), PetscHMapTGetVals()
    M*/

    #define PETSC_HASH_MAP(HashT, KeyType, ValType, HashFunc, EqualFunc, DefaultValue)                   \
                                                                                                         \
    KHASH_INIT(HashT, KeyType, ValType, 1, HashFunc, EqualFunc)                                          \
                                                                                                         \
    typedef khash_t(HashT) *Pet.c.html##HashT;

### Synopsis

    typedef khash_t(HMapT) *PetscHMapT;

### See Also

PETSC_HASH_MAP(), PetscHMapTCreate()

### Level

developer

### Location

include/petsc/private/hashmap.h
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages