Debian Codegraph @

data/0.12-dev/impl/WordStream.h

raw
1 /*
2 * Aiksaurus - An open source thesaurus library
3 * Copyright (C) 2001 by Jared Davis
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 * 02111-1307, USA.
19 *
20 */
21
22 #ifndef INCLUDED_AIKSAURUS_WORDSTREAM_H
23 #define INCLUDED_AIKSAURUS_WORDSTREAM_H
24
25 #include <queue>
26
27 namespace AiksaurusImpl
28 {
29
30 class WordStream
31 {
32 private:
33
34 WordStream(WordStream& rhs);
35 WordStream& operator=(const WordStream& rhs);
36
37 std::queue<int> d_words;
38
39
40 public:
41
42 WordStream(int* words);
43 ~WordStream();
44
45 int next();
46 };
47
48 }
49
50
51 inline
52 AiksaurusImpl::WordStream::WordStream(int* words)
53 {
54 for(int i = 0;words[i] != -1;++i)
55 d_words.push(words[i]);
56 }
57
58
59 inline
60 AiksaurusImpl::WordStream::~WordStream()
61 {
62 // nothing to destroy.
63 }
64
65
66 inline
67 int AiksaurusImpl::WordStream::next()
68 {
69 if (d_words.empty())
70 return -1;
71
72 int ret(d_words.front());
73 d_words.pop();
74
75 return ret;
76 }
77
78 #endif // INCLUDED_AIKSAURUS_WORDSTREAM_H