1228060Sbapt/* This may look like C code, but it is really -*- C++ -*- */ 2228060Sbapt 3228060Sbapt/* Keyword list. 4228060Sbapt 5228060Sbapt Copyright (C) 2002 Free Software Foundation, Inc. 6228060Sbapt Written by Bruno Haible <bruno@clisp.org>. 7228060Sbapt 8228060Sbapt This file is part of GNU GPERF. 9228060Sbapt 10228060Sbapt GNU GPERF is free software; you can redistribute it and/or modify 11228060Sbapt it under the terms of the GNU General Public License as published by 12228060Sbapt the Free Software Foundation; either version 2, or (at your option) 13228060Sbapt any later version. 14228060Sbapt 15228060Sbapt GNU GPERF is distributed in the hope that it will be useful, 16228060Sbapt but WITHOUT ANY WARRANTY; without even the implied warranty of 17228060Sbapt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18228060Sbapt GNU General Public License for more details. 19228060Sbapt 20228060Sbapt You should have received a copy of the GNU General Public License 21228060Sbapt along with this program; see the file COPYING. 22228060Sbapt If not, write to the Free Software Foundation, Inc., 23228060Sbapt 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 24228060Sbapt 25228060Sbapt#ifndef keyword_list_h 26228060Sbapt#define keyword_list_h 1 27228060Sbapt 28228060Sbapt#include "keyword.h" 29228060Sbapt 30228060Sbapt/* List node of a linear list of Keyword. */ 31228060Sbaptclass Keyword_List 32228060Sbapt{ 33228060Sbaptpublic: 34228060Sbapt /* Constructor. */ 35228060Sbapt Keyword_List (Keyword *car); 36228060Sbapt 37228060Sbapt /* Access to first element of list. */ 38228060Sbapt Keyword * first () const; 39228060Sbapt /* Access to next element of list. */ 40228060Sbapt Keyword_List *& rest (); 41228060Sbapt 42228060Sbaptprotected: 43228060Sbapt Keyword_List * _cdr; 44228060Sbapt Keyword * const _car; 45228060Sbapt}; 46228060Sbapt 47228060Sbapt/* List node of a linear list of KeywordExt. */ 48228060Sbaptclass KeywordExt_List : public Keyword_List 49228060Sbapt{ 50228060Sbaptpublic: 51228060Sbapt /* Constructor. */ 52228060Sbapt KeywordExt_List (KeywordExt *car); 53228060Sbapt 54228060Sbapt /* Access to first element of list. */ 55228060Sbapt KeywordExt * first () const; 56228060Sbapt /* Access to next element of list. */ 57228060Sbapt KeywordExt_List *& rest (); 58228060Sbapt}; 59228060Sbapt 60228060Sbapt/* Copies a linear list, sharing the list elements. */ 61228060Sbaptextern Keyword_List * copy_list (Keyword_List *list); 62228060Sbaptextern KeywordExt_List * copy_list (KeywordExt_List *list); 63228060Sbapt 64228060Sbapt/* Deletes a linear list, keeping the list elements in memory. */ 65228060Sbaptextern void delete_list (Keyword_List *list); 66228060Sbapt 67228060Sbapt/* Sorts a linear list, given a comparison function. 68228060Sbapt Note: This uses a variant of mergesort that is *not* a stable sorting 69228060Sbapt algorithm. */ 70228060Sbaptextern Keyword_List * mergesort_list (Keyword_List *list, 71228060Sbapt bool (*less) (Keyword *keyword1, 72228060Sbapt Keyword *keyword2)); 73228060Sbaptextern KeywordExt_List * mergesort_list (KeywordExt_List *list, 74228060Sbapt bool (*less) (KeywordExt *keyword1, 75228060Sbapt KeywordExt *keyword2)); 76228060Sbapt 77228060Sbapt#ifdef __OPTIMIZE__ 78228060Sbapt 79228060Sbapt#define INLINE inline 80228060Sbapt#include "keyword-list.icc" 81228060Sbapt#undef INLINE 82228060Sbapt 83228060Sbapt#endif 84228060Sbapt 85228060Sbapt#endif 86