| 1 |
/* This may look like C code, but it is really -*- C++ -*- */ |
| 2 |
|
| 3 |
/* Keyword list. |
| 4 |
|
| 5 |
Copyright (C) 2002-2003, 2025 Free Software Foundation, Inc. |
| 6 |
Written by Bruno Haible <[email protected]>. |
| 7 |
|
| 8 |
This file is part of GNU GPERF. |
| 9 |
|
| 10 |
This program is free software: you can redistribute it and/or modify |
| 11 |
it under the terms of the GNU General Public License as published by |
| 12 |
the Free Software Foundation; either version 3 of the License, or |
| 13 |
(at your option) any later version. |
| 14 |
|
| 15 |
This program is distributed in the hope that it will be useful, |
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
GNU General Public License for more details. |
| 19 |
|
| 20 |
You should have received a copy of the GNU General Public License |
| 21 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 22 |
|
| 23 |
#ifndef keyword_list_h |
| 24 |
#define keyword_list_h 1 |
| 25 |
|
| 26 |
#include "keyword.h" |
| 27 |
|
| 28 |
/* List node of a linear list of KT, where KT is a subclass of Keyword. */ |
| 29 |
template <class KT> |
| 30 |
class Keyword_List |
| 31 |
{ |
| 32 |
public: |
| 33 |
/* Constructor. */ |
| 34 |
Keyword_List (KT *car); |
| 35 |
|
| 36 |
/* Access to first element of list. */ |
| 37 |
KT * first () const; |
| 38 |
/* Access to next element of list. */ |
| 39 |
Keyword_List<KT> *& rest (); |
| 40 |
|
| 41 |
protected: |
| 42 |
Keyword_List<KT> * _cdr; |
| 43 |
KT * const _car; |
| 44 |
}; |
| 45 |
|
| 46 |
/* List node of a linear list of KeywordExt. */ |
| 47 |
typedef Keyword_List<KeywordExt> KeywordExt_List; |
| 48 |
|
| 49 |
/* Copies a linear list, sharing the list elements. */ |
| 50 |
template <class KT> |
| 51 |
extern Keyword_List<KT> * copy_list (Keyword_List<KT> *list); |
| 52 |
|
| 53 |
/* Deletes a linear list, keeping the list elements in memory. */ |
| 54 |
template <class KT> |
| 55 |
extern void delete_list (Keyword_List<KT> *list); |
| 56 |
|
| 57 |
/* Sorts a linear list, given a comparison function. |
| 58 |
Note: This uses a variant of mergesort that is *not* a stable sorting |
| 59 |
algorithm. */ |
| 60 |
template <class KT> |
| 61 |
extern Keyword_List<KT> * mergesort_list (Keyword_List<KT> *list, |
| 62 |
bool (*less) (KT *keyword1, |
| 63 |
KT *keyword2)); |
| 64 |
|
| 65 |
#ifdef __OPTIMIZE__ |
| 66 |
|
| 67 |
#define INLINE inline |
| 68 |
#include "keyword-list.icc" |
| 69 |
#undef INLINE |
| 70 |
|
| 71 |
#endif |
| 72 |
|
| 73 |
#endif |