2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Trie.h /main/1 1996/07/29 17:06:38 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
28 #define Trie_INCLUDED 1
34 #include "CopyOwner.h"
38 namespace SP_NAMESPACE {
45 Trie() : next_(0), nCodes_(0) { }
48 Trie &operator=(const Trie &);
49 const Trie *next(int i) const { return &next_[i]; }
50 Boolean hasNext() const { return next_ != 0; }
51 Token token() const { return token_; }
52 int tokenLength() const { return tokenLength_; }
53 const BlankTrie *blank() const;
54 Boolean includeBlanks() const {
55 return Priority::isBlank(priority_);
57 friend class TrieBuilder;
61 unsigned short token_;
62 unsigned char tokenLength_;
63 Priority::Type priority_;
64 CopyOwner<BlankTrie> blank_;
67 class BlankTrie : public Trie {
70 Boolean codeIsBlank(EquivCode c) const { return codeIsBlank_[c]; }
71 // maximum number of blanks to scan (minimum is 0)
72 size_t maxBlanksToScan() const { return maxBlanksToScan_; }
73 // length to add to tokenLengths in this trie (for those > 0).
74 int additionalLength() const { return additionalLength_; }
75 BlankTrie *copy() const { return new BlankTrie(*this); }
77 unsigned char additionalLength_;
78 size_t maxBlanksToScan_;
79 Vector<PackedBoolean> codeIsBlank_;
80 friend class TrieBuilder;
84 const BlankTrie *Trie::blank() const
86 return blank_.pointer();
93 #endif /* not Trie_INCLUDED */