]> git.lyx.org Git - features.git/blob - src/WordList.cpp
Revert "* compile fix"
[features.git] / src / WordList.cpp
1 /**
2  * \file WordList.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 "WordList.h"
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 <boost/assert.hpp>
21
22 namespace lyx {
23
24 ///
25 struct WordList::Impl {
26         ///
27         size_t c_;
28         ///
29         typedef stx::weighted_btree<docstring, size_t> Words;
30         ///
31         Words words_;
32 };
33
34
35 WordList::WordList()
36 {
37         d = new Impl;
38         d->c_ = 0;
39
40 #if 0
41         for (size_t i = 1000000; i > 0; --i) {
42                 d->words_.insert("a" + convert<docstring>(i), size_t(1), stx::Void());
43         }
44 #endif
45 }
46
47
48 WordList::~WordList()
49 {
50         delete d;
51 }
52
53
54 docstring const & WordList::word(size_t idx) const
55 {
56         Impl::Words::const_iterator it = d->words_.find_summed_weight(idx);
57         BOOST_ASSERT(it != d->words_.end());
58         return it->first;
59 }
60
61
62 size_t WordList::size() const
63 {
64         return d->words_.size();
65 }
66
67
68 void WordList::insert(docstring const & w)
69 {
70         d->words_.insert(w, size_t(1), stx::Void());
71 }
72
73         
74 } // namespace lyx