Leptonica 1.68
C Image Processing Library

queue.h

Go to the documentation of this file.
00001 /*====================================================================*
00002  -  Copyright (C) 2001 Leptonica.  All rights reserved.
00003  -  This software is distributed in the hope that it will be
00004  -  useful, but with NO WARRANTY OF ANY KIND.
00005  -  No author or distributor accepts responsibility to anyone for the
00006  -  consequences of using this software, or for whether it serves any
00007  -  particular purpose or works at all, unless he or she says so in
00008  -  writing.  Everyone is granted permission to copy, modify and
00009  -  redistribute this source code, for commercial or non-commercial
00010  -  purposes, with the following restrictions: (1) the origin of this
00011  -  source code must not be misrepresented; (2) modified versions must
00012  -  be plainly marked as such; and (3) this notice may not be removed
00013  -  or altered from any source or modified source distribution.
00014  *====================================================================*/
00015 
00016 #ifndef  LEPTONICA_QUEUE_H
00017 #define  LEPTONICA_QUEUE_H
00018 
00019 /*
00020  *  queue.h
00021  *
00022  *      Expandable pointer queue for arbitrary void* data.
00023  *
00024  *      The L_Queue is a fifo that implements a queue of void* pointers.
00025  *      It can be used to hold a queue of any type of struct.
00026  *
00027  *      Internally, it maintains two counters:
00028  *          nhead:  location of head (in ptrs) from the beginning
00029  *                  of the array.
00030  *          nelem:  number of ptr elements stored in the queue.
00031  *
00032  *      The element at the head of the queue, which is the next to
00033  *      be removed, is array[nhead].  The location at the tail of the
00034  *      queue to which the next element will be added is
00035  *      array[nhead + nelem].
00036  *               
00037  *      As items are added to the queue, nelem increases.
00038  *      As items are removed, nhead increases and nelem decreases.
00039  *      Any time the tail reaches the end of the allocated array,
00040  *      all the pointers are shifted to the left, so that the head
00041  *      is at the beginning of the array.
00042  *      If the array becomes more than 3/4 full, it doubles in size.
00043  *
00044  *      The auxiliary stack can be used in a wrapper for re-using
00045  *      items popped from the queue.  It is not made by default.
00046  *
00047  *      For further implementation details, see queue.c.
00048  */
00049 
00050 struct L_Queue
00051 {
00052     l_int32          nalloc;     /* size of allocated ptr array            */
00053     l_int32          nhead;      /* location of head (in ptrs) from the    */
00054                                  /* beginning of the array                 */
00055     l_int32          nelem;      /* number of elements stored in the queue */
00056     void           **array;      /* ptr array                              */
00057     struct L_Stack  *stack;      /* auxiliary stack                        */
00058 
00059 };
00060 typedef struct L_Queue L_QUEUE;
00061 
00062 
00063 #endif  /* LEPTONICA_QUEUE_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines