Mon, 11 Nov 2019 20:43:31 -0600
closing merged branch
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
2 | * Purple |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
3 | * |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
5 | * numerous to list here. Please refer to the COPYRIGHT file distributed |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
6 | * with this source distribution |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
7 | * |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or (at |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
11 | * your option) any later version. |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
12 | * |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, but |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
16 | * General Public License for more details. |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
17 | * |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
21 | */ |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
22 | |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
23 | #ifndef PURPLE_TRIE_H |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
24 | #define PURPLE_TRIE_H |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
25 | /** |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
26 | * SECTION:trie |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
27 | * @include:trie.h |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
28 | * @section_id: libpurple-trie |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
29 | * @short_description: a structure for linear-time text searching |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
30 | * @title: Tries |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
31 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
32 | * A #PurpleTrie is a structure for quick searching of multiple phrases within |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
33 | * a text. It's intended for repeated searches of the same set of patterns |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
34 | * within multiple source texts (or a single, big one). |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
35 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
36 | * It's preparation time is <literal>O(p)</literal>, where <literal>p</literal> |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
37 | * is the total length of searched phrases. In current implementation, the |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
38 | * internal structure is invalidated after every modification of the |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
39 | * #PurpleTrie's contents, so it's not efficient to do alternating modifications |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
40 | * and searches. Search time does not depend on patterns being stored within |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
41 | * a trie and is always <literal>O(n)</literal>, where <literal>n</literal> is |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
42 | * the size of a text. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
43 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
44 | * Its main drawback is a significant memory usage - every internal trie node |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
45 | * needs about 1kB of memory on 32-bit machine and 2kB on 64-bit. Fortunately, |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
46 | * the trie grows slower when more words (with common prefixes) are added. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
47 | * We could avoid invalidating the whole tree when altering it, but it would |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
48 | * require figuring out, how to update <literal>longest_suffix</literal> fields |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
49 | * in satisfying time. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
50 | */ |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
51 | |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
52 | #include <glib-object.h> |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
53 | |
|
39544
8e488a91262f
Use G_DECLARE_FINAL_TYPE for PurpleTrie.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37401
diff
changeset
|
54 | #define PURPLE_TYPE_TRIE purple_trie_get_type() |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
55 | |
|
35658
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
56 | /** |
|
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
57 | * PurpleTrieReplaceCb: |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
58 | * @out: currently built output string, append replacement to it. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
59 | * @word: found word. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
60 | * @word_data: the user data bound with this word, when added with |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
61 | * #purple_trie_add. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
62 | * @user_data: the user supplied data passed when calling #purple_trie_replace. |
|
35658
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
63 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
64 | * A funtion called on every matching substring to be replaced. |
|
35658
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
65 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
66 | * If you decide to replace the word, append your text to @out and return %TRUE. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
67 | * Otherwise, you must not touch @out. In both cases, you must not do any |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
68 | * operations on @out other than appending text to it. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
69 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
70 | * Returns: %TRUE if the word was replaced, %FALSE otherwise. |
|
35658
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
71 | */ |
|
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
72 | typedef gboolean (*PurpleTrieReplaceCb)(GString *out, const gchar *word, |
|
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
73 | gpointer word_data, gpointer user_data); |
|
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
74 | |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
75 | /** |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
76 | * PurpleTrieFindCb: |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
77 | * @word: found word. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
78 | * @word_data: the user data bound with this word, when added with |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
79 | * #purple_trie_add. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
80 | * @user_data: the user data passed when calling #purple_trie_find. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
81 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
82 | * A function called on every matching substring. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
83 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
84 | * You can decide to count the match or not (for the total number of found |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
85 | * words, that is returned by #purple_trie_find). In both cases you can |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
86 | * obviously do some processing outside the #PurpleTrie object. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
87 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
88 | * If you decide to count the word and #PurpleTrie:reset-on-match property |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
89 | * is set, no overlapping words will be found - the processing will skip after |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
90 | * the end of this word. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
91 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
92 | * Returns: %TRUE if the word should be counter, %FALSE otherwise. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
93 | */ |
|
35756
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
94 | typedef gboolean (*PurpleTrieFindCb)(const gchar *word, gpointer word_data, |
|
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
95 | gpointer user_data); |
|
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
96 | |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
97 | G_BEGIN_DECLS |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
98 | |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
99 | /** |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
100 | * purple_trie_get_type: |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
101 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
102 | * Returns: the #GType for a #PurpleTrie. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
103 | */ |
|
39544
8e488a91262f
Use G_DECLARE_FINAL_TYPE for PurpleTrie.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37401
diff
changeset
|
104 | G_DECLARE_FINAL_TYPE(PurpleTrie, purple_trie, PURPLE, TRIE, GObject) |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
105 | |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
106 | /** |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
107 | * purple_trie_new: |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
108 | * |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
109 | * Creates a new trie. |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
110 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
111 | * Returns: the new #PurpleTrie. |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
112 | */ |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
113 | PurpleTrie * |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
114 | purple_trie_new(void); |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
115 | |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
116 | /** |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
117 | * purple_trie_get_reset_on_match: |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
118 | * @trie: the trie. |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
119 | * |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
120 | * Checks, if the trie will reset its internal state after every match. |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
121 | * |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
122 | * Returns: %TRUE, if trie will reset, %FALSE otherwise. |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
123 | */ |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
124 | gboolean |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
125 | purple_trie_get_reset_on_match(PurpleTrie *trie); |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
126 | |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
127 | /** |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
128 | * purple_trie_set_reset_on_match: |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
129 | * @trie: the trie. |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
130 | * @reset: %TRUE, if trie should reset, %FALSE otherwise. |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
131 | * |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
132 | * Enables or disables a feature of resetting trie's state after every match. |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
133 | * When enabled, it will not search for overlapping matches. |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
134 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
135 | * It's well defined for #purple_trie_find, but not for replace operations. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
136 | * Thus, for the latter, it's better to stay with this option enabled, because |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
137 | * its behavior may be changed in future. |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
138 | */ |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
139 | void |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
140 | purple_trie_set_reset_on_match(PurpleTrie *trie, gboolean reset); |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
141 | |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
142 | /** |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
143 | * purple_trie_add: |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
144 | * @trie: the trie. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
145 | * @word: the word. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
146 | * @data: the word-related data (may be %NULL). |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
147 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
148 | * Adds a word to the trie. Current implementation doesn't allow for duplicates, |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
149 | * so please avoid adding those. |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
150 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
151 | * Please note, that altering a trie invalidates its internal structure, so by |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
152 | * the occasion of next search, it will be rebuilt. It's done in |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
153 | * <literal>O(n)</literal>, where n is the total length of strings |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
154 | * in #PurpleTrie. |
|
35700
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
155 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
156 | * Returns: %TRUE if succeeded, %FALSE otherwise. |
|
35700
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
157 | */ |
|
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
158 | gboolean |
|
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
159 | purple_trie_add(PurpleTrie *trie, const gchar *word, gpointer data); |
|
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
160 | |
|
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
161 | /** |
|
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
162 | * purple_trie_remove: |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
163 | * @trie: the trie. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
164 | * @word: the word. |
|
35700
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
165 | * |
|
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
166 | * Removes a word from the trie. Depending on used memory pool, this may not |
|
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
167 | * free allocated memory (that will be freed when destroying the whole |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
168 | * collection), so use it wisely. See #purple_memory_pool_free. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
169 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
170 | * Please note, that altering a trie invalidates its internal structure. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
171 | * See #purple_trie_add. |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
172 | */ |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
173 | void |
|
35700
a032063e50c7
Trie: implement purple_trie_remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35665
diff
changeset
|
174 | purple_trie_remove(PurpleTrie *trie, const gchar *word); |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
175 | |
|
35766
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
176 | /** |
|
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
177 | * purple_trie_get_size: |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
178 | * @trie: the trie. |
|
35766
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
179 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
180 | * Returns the number of elements contained in the #PurpleTrie. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
181 | * |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
182 | * Returns: the number of stored words in @trie. |
|
35766
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
183 | */ |
|
35717
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35700
diff
changeset
|
184 | guint |
|
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35700
diff
changeset
|
185 | purple_trie_get_size(PurpleTrie *trie); |
|
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35700
diff
changeset
|
186 | |
|
35658
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
187 | /** |
|
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
188 | * purple_trie_replace: |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
189 | * @trie: the trie. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
190 | * @src: the source string. |
|
37401
11138a33d498
Add GIntrospection Annotations to Trie documentation
Jorge Villaseñor <salinasv@pidgin.im>
parents:
35790
diff
changeset
|
191 | * @replace_cb: (scope call): the replacement function. |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
192 | * @user_data: custom data to be passed to @replace_cb. |
|
35658
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
193 | * |
|
35665
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
194 | * Processes @src string and replaces all occuriences of words added to @trie. |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
195 | * It's <literal>O(strlen(src))</literal>, if @replace_cb runs in |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
196 | * <literal>O(strlen(word))</literal> and #PurpleTrie:reset-on-match is set. |
|
35658
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
197 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
198 | * Returns: resulting string. Must be #g_free'd when you are done using it. |
|
35658
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
199 | */ |
|
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
200 | gchar * |
|
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
201 | purple_trie_replace(PurpleTrie *trie, const gchar *src, |
|
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
202 | PurpleTrieReplaceCb replace_cb, gpointer user_data); |
|
799b62769bd3
Trie: implement search-and-replace (not yet tested)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35651
diff
changeset
|
203 | |
|
35665
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
204 | /** |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
205 | * purple_trie_multi_replace: |
|
37401
11138a33d498
Add GIntrospection Annotations to Trie documentation
Jorge Villaseñor <salinasv@pidgin.im>
parents:
35790
diff
changeset
|
206 | * @tries: (element-type PurpleTrie): the list of tries. |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
207 | * @src: the source string. |
|
37401
11138a33d498
Add GIntrospection Annotations to Trie documentation
Jorge Villaseñor <salinasv@pidgin.im>
parents:
35790
diff
changeset
|
208 | * @replace_cb: (scope call): the replacement function. |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
209 | * @user_data: custom data to be passed to @replace_cb. |
|
35665
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
210 | * |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
211 | * Processes @src and replaces all occuriences of words added to tries in list |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
212 | * @tries. Entries added to tries on the beginning of the list have higher |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
213 | * priority, than ones added further. |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
214 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
215 | * Different #GSList's can be combined to possess common parts, so you can create |
|
35665
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
216 | * a "tree of tries". |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
217 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
218 | * Returns: resulting string. Must be #g_free'd when you are done using it. |
|
35665
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
219 | */ |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
220 | gchar * |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
221 | purple_trie_multi_replace(const GSList *tries, const gchar *src, |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
222 | PurpleTrieReplaceCb replace_cb, gpointer user_data); |
|
f1310093e434
Implement and test multi-trie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35662
diff
changeset
|
223 | |
|
35766
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
224 | /** |
|
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
225 | * purple_trie_find: |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
226 | * @trie: the trie. |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
227 | * @src: the source string. |
|
37401
11138a33d498
Add GIntrospection Annotations to Trie documentation
Jorge Villaseñor <salinasv@pidgin.im>
parents:
35790
diff
changeset
|
228 | * @find_cb: (nullable) (scope call): the callback for the found entries (may be %NULL). |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
229 | * @user_data: custom data to be passed to @find_cb. |
|
35766
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
230 | * |
|
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
231 | * Processes @src string and finds all occuriences of words added to @trie. |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
232 | * It's <literal>O(strlen(src))</literal>, if find_cb runs |
|
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
233 | * in <literal>O(1)</literal>. |
|
35766
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
234 | * |
|
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
235 | * The word is counted as found if it's found and the callback returns %TRUE. |
|
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
236 | * |
|
35773
8c63d334ad44
Comments: PurpleTrie
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35766
diff
changeset
|
237 | * Returns: the number of found words. |
|
35766
f29bb25cfbd8
Smileys: fill comments for old files
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35756
diff
changeset
|
238 | */ |
|
35756
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
239 | gulong |
|
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
240 | purple_trie_find(PurpleTrie *trie, const gchar *src, |
|
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
241 | PurpleTrieFindCb find_cb, gpointer user_data); |
|
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
242 | |
|
35790
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
243 | /** |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
244 | * purple_trie_multi_find: |
|
37401
11138a33d498
Add GIntrospection Annotations to Trie documentation
Jorge Villaseñor <salinasv@pidgin.im>
parents:
35790
diff
changeset
|
245 | * @tries: (element-type PurpleTrie): the list of tries. |
|
35790
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
246 | * @src: the source string. |
|
37401
11138a33d498
Add GIntrospection Annotations to Trie documentation
Jorge Villaseñor <salinasv@pidgin.im>
parents:
35790
diff
changeset
|
247 | * @find_cb: (nullable) (scope call): the callback for the found entries (may be %NULL). |
|
35790
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
248 | * @user_data: custom data to be passed to @find_cb. |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
249 | * |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
250 | * Processes @src and replaces all occuriences of words added to tries in |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
251 | * list @tries. Entries added to tries on the beginning of the list have higher |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
252 | * priority, than ones added further. |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
253 | * |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
254 | * Different #GSList's can be combined to possess common parts, so you can create |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
255 | * a "tree of tries". |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
256 | * |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
257 | * Returns: the number of found words. |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
258 | */ |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
259 | gulong |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
260 | purple_trie_multi_find(const GSList *tries, const gchar *src, |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
261 | PurpleTrieFindCb find_cb, gpointer user_data); |
|
3118fb87573e
Trie: implement purple_trie_multi_find
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35773
diff
changeset
|
262 | |
|
35651
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
263 | G_END_DECLS |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
264 | |
|
95f34a3f4172
Initial trie class implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
265 | #endif /* PURPLE_MEMORY_POOL_H */ |