Eneboo - Documentación para desarrolladores
src/libmysql_std/include/queues.h
Ir a la documentación de este archivo.
00001 /* Copyright (C) 2000 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00015 
00016 /*
00017   Code for generell handling of priority Queues.
00018   Implemention of queues from "Algoritms in C" by Robert Sedgewick.
00019   Copyright Monty Program KB.
00020   By monty.
00021 */
00022 
00023 #ifndef _queues_h
00024 #define _queues_h
00025 #ifdef  __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 typedef struct st_queue {
00030   byte **root;
00031   void *first_cmp_arg;
00032   uint elements;
00033   uint max_elements;
00034   uint offset_to_key;                   /* compare is done on element+offset */
00035   int max_at_top;                       /* Set if queue_top gives max */
00036   int  (*compare)(void *, byte *,byte *);
00037 } QUEUE;
00038 
00039 #define queue_top(queue) ((queue)->root[1])
00040 #define queue_element(queue,index) ((queue)->root[index+1])
00041 #define queue_end(queue) ((queue)->root[(queue)->elements])
00042 #define queue_replaced(queue) _downheap(queue,1)
00043 typedef int (*queue_compare)(void *,byte *, byte *);
00044 
00045 int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
00046                pbool max_at_top, queue_compare compare,
00047                void *first_cmp_arg);
00048 int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
00049                  pbool max_at_top, queue_compare compare,
00050                  void *first_cmp_arg);
00051 int resize_queue(QUEUE *queue, uint max_elements);
00052 void delete_queue(QUEUE *queue);
00053 void queue_insert(QUEUE *queue,byte *element);
00054 byte *queue_remove(QUEUE *queue,uint idx);
00055 #define queue_remove_all(queue) { (queue)->elements= 0; }
00056 void _downheap(QUEUE *queue,uint idx);
00057 void queue_fix(QUEUE *queue);
00058 #define is_queue_inited(queue) ((queue)->root != 0)
00059 
00060 #ifdef  __cplusplus
00061 }
00062 #endif
00063 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'