1: #if !defined(_LABELIMPL_H)
2: #define _LABELIMPL_H 4: #include <petscdmlabel.h>
5: #include <petscbt.h>
6: #include <../src/sys/utils/hash.h>
8: /* This is an integer map, in addition it is also a container class
9: Design points:
10: - Low storage is the most important design point
11: - We want flexible insertion and deletion
12: - We can live with O(log) query, but we need O(1) iteration over strata
13: */
14: struct _n_DMLabel {
15: PetscInt refct;
16: PetscObjectState state;
17: char *name; /* Label name */
18: PetscInt numStrata; /* Number of integer values */
19: PetscInt defaultValue; /* Background value when no value explicitly given */
20: PetscInt *stratumValues; /* Value of each stratum */
21: /* Basic sorted array storage */
22: PetscBool *arrayValid; /* The array storage is valid (no additions need to be merged in) */
23: PetscInt *stratumSizes; /* Size of each stratum */
24: PetscInt **points; /* Points for each stratum, always sorted */
25: /* Hashtable for fast insertion */
26: PetscHashI *ht; /* Hash table for fast insertion */
27: /* Index for fast search */
28: PetscInt pStart, pEnd; /* Bounds for index lookup */
29: PetscBT bt; /* A bit-wise index */
30: };
32: #endif