]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/gperf/src/keyword-list.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / gperf / src / keyword-list.h
1 /* This may look like C code, but it is really -*- C++ -*- */
2
3 /* Keyword list.
4
5    Copyright (C) 2002 Free Software Foundation, Inc.
6    Written by Bruno Haible <bruno@clisp.org>.
7
8    This file is part of GNU GPERF.
9
10    GNU GPERF 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 2, or (at your option)
13    any later version.
14
15    GNU GPERF 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; see the file COPYING.
22    If not, write to the Free Software Foundation, Inc.,
23    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
24
25 #ifndef keyword_list_h
26 #define keyword_list_h 1
27
28 #include "keyword.h"
29
30 /* List node of a linear list of Keyword.  */
31 class Keyword_List
32 {
33 public:
34   /* Constructor.  */
35                         Keyword_List (Keyword *car);
36
37   /* Access to first element of list.  */
38   Keyword *             first () const;
39   /* Access to next element of list.  */
40   Keyword_List *&       rest ();
41
42 protected:
43   Keyword_List *        _cdr;
44   Keyword * const       _car;
45 };
46
47 /* List node of a linear list of KeywordExt.  */
48 class KeywordExt_List : public Keyword_List
49 {
50 public:
51   /* Constructor.  */
52                         KeywordExt_List (KeywordExt *car);
53
54   /* Access to first element of list.  */
55   KeywordExt *          first () const;
56   /* Access to next element of list.  */
57   KeywordExt_List *&    rest ();
58 };
59
60 /* Copies a linear list, sharing the list elements.  */
61 extern Keyword_List * copy_list (Keyword_List *list);
62 extern KeywordExt_List * copy_list (KeywordExt_List *list);
63
64 /* Deletes a linear list, keeping the list elements in memory.  */
65 extern void delete_list (Keyword_List *list);
66
67 /* Sorts a linear list, given a comparison function.
68    Note: This uses a variant of mergesort that is *not* a stable sorting
69    algorithm.  */
70 extern Keyword_List * mergesort_list (Keyword_List *list,
71                                       bool (*less) (Keyword *keyword1,
72                                                     Keyword *keyword2));
73 extern KeywordExt_List * mergesort_list (KeywordExt_List *list,
74                                          bool (*less) (KeywordExt *keyword1,
75                                                        KeywordExt *keyword2));
76
77 #ifdef __OPTIMIZE__
78
79 #define INLINE inline
80 #include "keyword-list.icc"
81 #undef INLINE
82
83 #endif
84
85 #endif