ptra.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*====================================================================*
  2. - Copyright (C) 2001 Leptonica. All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions
  6. - are met:
  7. - 1. Redistributions of source code must retain the above copyright
  8. - notice, this list of conditions and the following disclaimer.
  9. - 2. Redistributions in binary form must reproduce the above
  10. - copyright notice, this list of conditions and the following
  11. - disclaimer in the documentation and/or other materials
  12. - provided with the distribution.
  13. -
  14. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
  18. - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  21. - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  22. - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23. - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *====================================================================*/
  26. #ifndef LEPTONICA_PTRA_H
  27. #define LEPTONICA_PTRA_H
  28. /*
  29. * Contains the following structs:
  30. * struct L_Ptra
  31. * struct L_Ptraa
  32. *
  33. * Contains definitions for:
  34. * L_Ptra compaction flags for removal
  35. * L_Ptra shifting flags for insert
  36. * L_Ptraa accessor flags
  37. */
  38. /*------------------------------------------------------------------------*
  39. * Generic Ptr Array Structs *
  40. *------------------------------------------------------------------------*/
  41. /* Generic pointer array */
  42. struct L_Ptra
  43. {
  44. l_int32 nalloc; /* size of allocated ptr array */
  45. l_int32 imax; /* greatest valid index */
  46. l_int32 nactual; /* actual number of stored elements */
  47. void **array; /* ptr array */
  48. };
  49. typedef struct L_Ptra L_PTRA;
  50. /* Array of generic pointer arrays */
  51. struct L_Ptraa
  52. {
  53. l_int32 nalloc; /* size of allocated ptr array */
  54. struct L_Ptra **ptra; /* array of ptra */
  55. };
  56. typedef struct L_Ptraa L_PTRAA;
  57. /*------------------------------------------------------------------------*
  58. * Array flags *
  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. /* Flags for insertion into L_Ptra */
  66. enum {
  67. L_AUTO_DOWNSHIFT = 0, /* choose based on number of holes */
  68. L_MIN_DOWNSHIFT = 1, /* downshifts min # of ptrs below insert */
  69. L_FULL_DOWNSHIFT = 2 /* downshifts all ptrs below insert */
  70. };
  71. /* Accessor flags for L_Ptraa */
  72. enum {
  73. L_HANDLE_ONLY = 0, /* ptr to L_Ptra; caller can inspect only */
  74. L_REMOVE = 1 /* caller owns; destroy or save in L_Ptraa */
  75. };
  76. #endif /* LEPTONICA_PTRA_H */