/ocr/ocrservice/jni/hydrogen/include/leptonica/stack.h

http://eyes-free.googlecode.com/ · C++ Header · 55 lines · 11 code · 7 blank · 37 comment · 0 complexity · bf67fe91a6b4440da9ff2ff5df72f103 MD5 · raw file

  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. #ifndef LEPTONICA_STACK_H
  16. #define LEPTONICA_STACK_H
  17. /*
  18. * stack.h
  19. *
  20. * Expandable pointer stack for arbitrary void* data.
  21. *
  22. * The L_Stack is an array of void * ptrs, onto which arbitrary
  23. * objects can be stored. At any time, the number of
  24. * stored objects is stack->n. The object at the bottom
  25. * of the stack is at array[0]; the object at the top of
  26. * the stack is at array[n-1]. New objects are added
  27. * to the top of the stack, at the first available location,
  28. * which is array[n]. Objects are removed from the top of the
  29. * stack. When an attempt is made to remove an object from an
  30. * empty stack, the result is null. When the stack becomes
  31. * filled, so that n = nalloc, the size is doubled.
  32. *
  33. * The auxiliary stack can be used to store and remove
  34. * objects for re-use. It must be created by a separate
  35. * call to pstackCreate(). [Just imagine the chaos if
  36. * pstackCreate() created the auxiliary stack!]
  37. * pstackDestroy() checks for the auxiliary stack and removes it.
  38. */
  39. /* Note that array[n] is the first null ptr in the array */
  40. struct L_Stack
  41. {
  42. l_int32 nalloc; /* size of ptr array */
  43. l_int32 n; /* number of stored elements */
  44. void **array; /* ptr array */
  45. struct L_Stack *auxstack; /* auxiliary stack */
  46. };
  47. typedef struct L_Stack L_STACK;
  48. #endif /* LEPTONICA_STACK_H */