1 /* $XConsortium: Trie.h /main/1 1996/07/29 17:06:38 cde-hp $ */
2 // Copyright (c) 1994 James Clark
3 // See the file COPYING for copying permission.
6 #define Trie_INCLUDED 1
12 #include "CopyOwner.h"
16 namespace SP_NAMESPACE {
23 Trie() : next_(0), nCodes_(0) { }
26 Trie &operator=(const Trie &);
27 const Trie *next(int i) const { return &next_[i]; }
28 Boolean hasNext() const { return next_ != 0; }
29 Token token() const { return token_; }
30 int tokenLength() const { return tokenLength_; }
31 const BlankTrie *blank() const;
32 Boolean includeBlanks() const {
33 return Priority::isBlank(priority_);
35 friend class TrieBuilder;
39 unsigned short token_;
40 unsigned char tokenLength_;
41 Priority::Type priority_;
42 CopyOwner<BlankTrie> blank_;
45 class BlankTrie : public Trie {
48 Boolean codeIsBlank(EquivCode c) const { return codeIsBlank_[c]; }
49 // maximum number of blanks to scan (minimum is 0)
50 size_t maxBlanksToScan() const { return maxBlanksToScan_; }
51 // length to add to tokenLengths in this trie (for those > 0).
52 int additionalLength() const { return additionalLength_; }
53 BlankTrie *copy() const { return new BlankTrie(*this); }
55 unsigned char additionalLength_;
56 size_t maxBlanksToScan_;
57 Vector<PackedBoolean> codeIsBlank_;
58 friend class TrieBuilder;
62 const BlankTrie *Trie::blank() const
64 return blank_.pointer();
71 #endif /* not Trie_INCLUDED */