3 * Used to define the class WordList which is used to creat a circular
4 * reviewing system for the user, and help them recite something quickly.
6 * Copyright (C) 2008 Kermit Mei <kermit.mei@gmail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 3 as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
22 * Written by Kermit Mei <kermit.mei@gmail.com>
24 * Many of the ideas implemented here are from the author's experiment.
25 * But the dictionary's format coincide with the other word recite software
26 * to help the users get more available data. And the review times designed
27 * by means of the theory named Forgetting Curve which dicoveried by the
28 * German psychologist named Hermann Ebbinghaus(1850–1909).
35 namespace freeRecite
{
38 * To use this class you should put something in an Random Accessing
39 * Container such as std::vector or an array.
45 //Initialize WordList using the size of the container object.
46 WordList(size_t initSize
= 0, const std::vector
<unsigned> *initPt
= 0);
51 //Return the size of word list, put it here to make it inline.
52 unsigned size() const;
57 //Detect whether it is valid.
61 * Get the Next word's index.
62 * Note: It's undefined to call this method on an unvalid object.
63 * So you must always call isValid() before using it.
65 unsigned getNext() const;
67 //Get the first word's status.
71 * If the input word is true, then you must call pass().
72 * This method will updata the WordList to help you get
73 * the correct index of the next word, when you call
74 * getNext() next time.:P
75 * If it return 0, then the word is tested first.
80 * If the input word is false, then you must call lose().
81 * The return value is the status of the current word.
86 * After you add one word to the contain, you must call
87 * this method to synchronize the the contain withe the list.
88 * The argument 'size' is the size of the new contain.
93 * After you remove one word from the contain, you must call
94 * this method to synchronize the the contain withe the list.
95 * The argument 'size' is the size of the new contain.
101 //Move the first element one afterward, advance all the pointers
102 void moveAfter(unsigned i
);
104 //The element is passed, remove it form the WordList;
109 NodeWord(unsigned initValue
)
110 :index(initValue
),status(0),next(0)
111 { /* Do Nothing Here! */ }
119 const std::vector
<unsigned> *posToStatus
;
126 unsigned WordList::size() const {
131 int WordList::times() const {
136 unsigned WordList::getNext() const {
141 int WordList::status() const {
142 return first
->status
;
146 bool WordList::isValid() const {
147 return (__size
> 0 && posToStatus
!= 0);
150 } //namespace freeRecite end.