ptra.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. * \file ptra.h
  30. *
  31. * <pre>
  32. * Contains the following structs:
  33. * struct L_Ptra
  34. * struct L_Ptraa
  35. *
  36. * Contains definitions for:
  37. * L_Ptra compaction flags for removal
  38. * L_Ptra shifting flags for insert
  39. * L_Ptraa accessor flags
  40. * </pre>
  41. */
  42. /*------------------------------------------------------------------------*
  43. * Generic Ptr Array Structs *
  44. *------------------------------------------------------------------------*/
  45. /*! Generic pointer array */
  46. struct L_Ptra
  47. {
  48. l_int32 nalloc; /*!< size of allocated ptr array */
  49. l_int32 imax; /*!< greatest valid index */
  50. l_int32 nactual; /*!< actual number of stored elements */
  51. void **array; /*!< ptr array */
  52. };
  53. typedef struct L_Ptra L_PTRA;
  54. /*! Array of generic pointer arrays */
  55. struct L_Ptraa
  56. {
  57. l_int32 nalloc; /*!< size of allocated ptr array */
  58. struct L_Ptra **ptra; /*!< array of ptra */
  59. };
  60. typedef struct L_Ptraa L_PTRAA;
  61. /*------------------------------------------------------------------------*
  62. * Array flags *
  63. *------------------------------------------------------------------------*/
  64. /*! Flags for removal from L_Ptra */
  65. enum {
  66. L_NO_COMPACTION = 1, /*!< null the pointer only */
  67. L_COMPACTION = 2 /*!< compact the array */
  68. };
  69. /*! Flags for insertion into L_Ptra */
  70. enum {
  71. L_AUTO_DOWNSHIFT = 0, /*!< choose based on number of holes */
  72. L_MIN_DOWNSHIFT = 1, /*!< downshifts min # of ptrs below insert */
  73. L_FULL_DOWNSHIFT = 2 /*!< downshifts all ptrs below insert */
  74. };
  75. /*! Accessor flags for L_Ptraa */
  76. enum {
  77. L_HANDLE_ONLY = 0, /*!< ptr to L_Ptra; caller can inspect only */
  78. L_REMOVE = 1 /*!< caller owns; destroy or save in L_Ptraa */
  79. };
  80. #endif /* LEPTONICA_PTRA_H */