]> git.lyx.org Git - lyx.git/blob - src/WordList.cpp
0bb06624ae49d39e5f31c71b36f4308d7e19c115
[lyx.git] / src / WordList.cpp
1 /**
2  * \file GuiCompleter.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Stefan Schimanski
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include <boost/assert.hpp>
14
15 #include <support/convert.h>
16 #include <support/debug.h>
17 #include <support/docstring.h>
18 #include <support/weighted_btree.h>
19
20 #include <WordList.h>
21
22 #include <algorithm>
23 #include <map>
24 #include <iostream>
25 #include <set>
26
27 namespace lyx {
28
29 ///
30 struct WordList::Impl {
31         ///
32         size_t c_;
33         ///
34         typedef stx::weighted_btree<docstring, size_t> Words;
35         ///
36         Words words_;
37 };
38
39
40 WordList::WordList()
41 {
42         d = new Impl;
43         d->c_ = 0;
44
45 #if 0
46         for (size_t i = 1000000; i > 0; --i) {
47                 d->words_.insert("a" + convert<docstring>(i), size_t(1), stx::Void());
48         }
49 #endif
50 }
51
52
53 WordList::~WordList()
54 {
55         delete d;
56 }
57
58
59 docstring const & WordList::word(size_t idx) const
60 {
61         Impl::Words::const_iterator it
62         = d->words_.find_summed_weight(idx);
63         BOOST_ASSERT(it != d->words_.end());
64         return it->first;
65 }
66
67
68 size_t WordList::size() const
69 {
70         return d->words_.size();
71 }
72
73
74 void WordList::insert(docstring const & w)
75 {
76         d->words_.insert(w, size_t(1), stx::Void());
77 }
78
79         
80 } // namespace lyx