5 WordList::WordList(unsigned init__Size
)
6 :__size(init__Size
),first(0),last(0)
8 for(unsigned i
= 0; i
< __size
; ++i
) {
10 first
= new NodeWord(0);
12 for(int i
= 1; i
< 4; ++i
)
15 last
->next
= new NodeWord(i
);
19 pos
[1] = pos
[1]->next
;
21 pos
[2] = pos
[2]->next
;
23 pos
[3] = pos
[3]->next
;
38 int WordList::scan() {
39 if(first
->status
== 0) {
48 int status
= first
->status
;
49 if( status
> 0 && status
< 4) //You should review it! status = 1,2,3
51 else if(status
== 4) //Put the word to the last to test whether you remember it.
53 else //You have remembered it! status = 0,5
56 } //end of function WordList::pass().
63 void WordList::moveToPos(unsigned i
) {
68 //pos[0] is a tempory variable.
69 pos
[0] = pos
[i
]->next
;
72 pos
[i
]->next
->next
= pos
[0];
77 void WordList::moveToLast() {
86 void WordList::pop() {
93 for(int i
= 0; i
< 4; ++i
)
103 void WordList::add(unsigned size
) {
104 NodeWord
*tmp
= new NodeWord(size
- 1);
110 void WordList::remove(unsigned size
) {
111 NodeWord
*tmp
= first
;
112 NodeWord
*max
= first
;
113 for(int i
= 0; i
< __size
; ++i
) {
115 if(max
->index
< tmp
->index
)
118 //Because the user should always call it after remove
119 //the word from the contain, it subtract 2 here.
120 if( max
->index
== (size
- 2) ){
121 max
->index
= first
->index
;
126 void WordList::advancePos(unsigned status
) {
130 pos
[3] = pos
[3]->next
;
133 pos
[2] = pos
[2]->next
;
136 pos
[1] = pos
[1]->next
;
140 } //Namespace freeRecite end.