• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*====================================================================*
2  -  Copyright (C) 2001 Leptonica.  All rights reserved.
3  -  This software is distributed in the hope that it will be
4  -  useful, but with NO WARRANTY OF ANY KIND.
5  -  No author or distributor accepts responsibility to anyone for the
6  -  consequences of using this software, or for whether it serves any
7  -  particular purpose or works at all, unless he or she says so in
8  -  writing.  Everyone is granted permission to copy, modify and
9  -  redistribute this source code, for commercial or non-commercial
10  -  purposes, with the following restrictions: (1) the origin of this
11  -  source code must not be misrepresented; (2) modified versions must
12  -  be plainly marked as such; and (3) this notice may not be removed
13  -  or altered from any source or modified source distribution.
14  *====================================================================*/
15 
16 #ifndef  LEPTONICA_PTRA_H
17 #define  LEPTONICA_PTRA_H
18 
19 /*
20  *  Contains the following structs:
21  *      struct L_Ptra
22  *      struct L_Ptraa
23  *
24  *  Contains definitions for:
25  *      L_Ptra compaction flags for removal
26  *      L_Ptra shifting flags for insert
27  *      L_Ptraa accessor flags
28  */
29 
30 
31 /*------------------------------------------------------------------------*
32  *                     Generic Ptr Array Structs                          *
33  *------------------------------------------------------------------------*/
34 
35     /* Generic pointer array */
36 struct L_Ptra
37 {
38     l_int32          nalloc;    /* size of allocated ptr array         */
39     l_int32          imax;      /* greatest valid index                */
40     l_int32          nactual;   /* actual number of stored elements    */
41     void           **array;     /* ptr array                           */
42 };
43 typedef struct L_Ptra  L_PTRA;
44 
45 
46     /* Array of generic pointer arrays */
47 struct L_Ptraa
48 {
49     l_int32          nalloc;    /* size of allocated ptr array         */
50     struct L_Ptra  **ptra;      /* array of ptra                       */
51 };
52 typedef struct L_Ptraa  L_PTRAA;
53 
54 
55 
56 /*------------------------------------------------------------------------*
57  *                              Array flags                               *
58  *------------------------------------------------------------------------*/
59 
60     /* Flags for removal from L_Ptra */
61 enum {
62     L_NO_COMPACTION = 1,        /* null the pointer only  */
63     L_COMPACTION = 2            /* compact the array      */
64 };
65 
66     /* Flags for insertion into L_Ptra */
67 enum {
68     L_AUTO_DOWNSHIFT = 0,       /* choose based on number of holes        */
69     L_MIN_DOWNSHIFT = 1,        /* downshifts min # of ptrs below insert  */
70     L_FULL_DOWNSHIFT = 2        /* downshifts all ptrs below insert       */
71 };
72 
73     /* Accessor flags for L_Ptraa */
74 enum {
75     L_HANDLE_ONLY = 0,          /* ptr to L_Ptra; caller can inspect only    */
76     L_REMOVE = 1                /* caller owns; destroy or save in L_Ptraa   */
77 };
78 
79 
80 #endif  /* LEPTONICA_PTRA_H */
81