KTextEditor

prefixstore.h
1 /* SPDX-License-Identifier: LGPL-2.0-or-later
2 
3  Copyright (C) 2008-2009 by Michel Ludwig <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef PREFIXSTORE_H
22 #define PREFIXSTORE_H
23 
24 #include <QHash>
25 #include <QList>
26 #include <QPair>
27 #include <QSet>
28 #include <QString>
29 #include <QVector>
30 
31 #include "katetextline.h"
32 
42 {
43 public:
45 
47  virtual ~KatePrefixStore();
48 
49  void addPrefix(const QString &prefix);
50  void removePrefix(const QString &prefix);
51 
56  QString findPrefix(const QString &s, int start = 0) const;
57 
62  QString findPrefix(const Kate::TextLine &line, int start = 0) const;
63 
64  int longestPrefixLength() const;
65 
66  void clear();
67 
68  void dump();
69 
70 protected:
71  int m_longestPrefixLength = 0;
72  QSet<QString> m_prefixSet;
73 
74  // State x Char -> Nr. of char occurrences in prefixes x State
77  TransitionFunction m_transitionFunction;
78  QSet<unsigned long long> m_acceptingStates;
79  QList<unsigned long long> m_stateFreeList;
80  unsigned long long m_lastAssignedState = 0;
81 
82  int computeLongestPrefixLength();
83  unsigned long long nextFreeState();
84  // bool containsPrefixOfLengthEndingWith(int length, const QChar& c);
85 };
86 
87 #endif
This class can be used to efficiently search for occurrences of strings in a given string...
Definition: prefixstore.h:41
QString findPrefix(const QString &s, int start=0) const
Returns the shortest prefix of the given string that is contained in this prefix store starting at po...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun May 24 2020 23:10:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.