source: git/kernel/f5lists.cc @ e6d283f

spielwiese
Last change on this file since e6d283f was e6d283f, checked in by Christian Eder, 15 years ago
rTag stuff done for F5C git-svn-id: file:///usr/local/Singular/svn/trunk@11528 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 23.8 KB
Line 
1#include "mod2.h"
2
3#ifdef HAVE_F5
4#include "kutil.h"
5#include "structs.h"
6#include "omalloc.h"
7#include "polys.h"
8#include "p_polys.h"
9#include "ideals.h"
10#include "febase.h"
11#include "kstd1.h"
12#include "khstd.h"
13#include "kbuckets.h"
14#include "weight.h"
15#include "intvec.h"
16#include "pInline1.h"
17#include "f5gb.h"
18#include "f5data.h"
19#include "f5lists.h"
20
21/*
22====================================
23functions working on the class LNode
24====================================
25*/
26
27// generating new list elements (labeled / classical polynomial / LNode view)
28LNode::LNode() {
29    data                =   NULL;
30    next                =   NULL;
31}
32LNode::LNode(LPoly* lp) {
33    data                =   lp;
34    next                =   NULL;
35}
36       
37LNode::LNode(LPoly* lp, LNode* l) {
38//Print("HIER LNODE\n");
39    data                =   lp;
40    next                =   l;
41}
42
43LNode::LNode(poly t, int i, poly p, Rule* r) {
44LPoly* lp           =   new LPoly(t,i,p,r);
45data                =   lp;
46next                =   NULL;
47}
48       
49LNode::LNode(poly t, int i, poly p, Rule* r, LNode* l) {
50    LPoly* lp           =   new LPoly(t,i,p,r);
51    data                =   lp;
52    next                =   l;
53}
54
55LNode::LNode(LNode* ln) {
56    data                =   ln->getLPoly();
57    next                =   ln->getNext();
58}
59       
60LNode::~LNode() {
61    //delete next;
62    //Print("DELETE LNODE\n");
63    delete data;   
64}
65
66void LNode::deleteAll() {
67    while(NULL != next) {
68        //Print("%p\n",next);
69        //pWrite(next->data->getPoly());
70        next->deleteAll();
71    }
72    delete data;
73}
74
75// insert new elements to the list always at the end (labeled / classical polynomial view)
76// needed for list gPrev
77inline LNode* LNode::insert(LPoly* lp) {
78    //Print("INSERTION: \n");
79    //Print("LAST GPREV: ");
80    //pWrite(this->getPoly());
81    LNode* newElement   =   new LNode(lp, NULL);
82    this->next          =   newElement;
83    return newElement;
84}
85       
86inline LNode* LNode::insert(poly t, int i, poly p, Rule* r) {
87    LNode* newElement   =   new LNode(t, i, p, r, NULL);
88    this->next          =   newElement;
89    return newElement;
90}
91
92// insert new elements to the list always in front (labeled / classical polynomial view)
93// needed for sPolyList
94inline LNode* LNode::insertSP(LPoly* lp) {
95    LNode* newElement   =   new LNode(lp, this);
96    //Print("INSERTED IN SPOLYLIST: ");
97    //pWrite(lp->getTerm());
98    return newElement;
99}
100       
101inline LNode* LNode::insertSP(poly t, int i, poly p, Rule* r) {
102    LNode* newElement   =   new LNode(t, i, p, r, this);
103     //Print("INSERTED IN SPOLYLIST: ");
104  //pWrite(t);
105return newElement;
106}
107// insert new elemets to the list w.r.t. increasing labels
108// only used for the S-polys to be reduced (TopReduction building new S-polys with higher label)
109inline LNode* LNode::insertByLabel(poly t, int i, poly p, Rule* r) {
110    //Print("ADDING SOLYS TO THE LIST\n");
111    //Print("new element: ");
112    //pWrite(t);
113       if(NULL == this || NULL == data) {
114        LNode* newElement   =   new LNode(t, i, p, r, this);
115        return newElement;
116    }
117    else {
118         //Print("tested element1: ");
119    //pWrite(this->getTerm());
120        if(-1 == pLmCmp(t,this->getTerm())) {
121            //Print("HIERDRIN\n");
122            LNode* newElement   =   new LNode(t, i, p, r, this);
123            //Print("%p\n",this);
124            //Print("%p\n",newElement->next);
125            return newElement;
126        }
127        else {
128            LNode* temp = this;
129            while(NULL != temp->next && NULL != temp->next->data) {
130                //Print("tested element: ");
131                //pWrite(temp->getTerm());
132 if(-1 == pLmCmp(t,temp->next->getTerm())) {
133                    LNode* newElement   =   new LNode(t, i, p, r, temp->next);
134                    temp->next          =   newElement;
135                    return this;
136                }
137                else {
138                    temp = temp->next;
139                    //Print("%p\n",temp);
140                    //Print("%p\n",temp->data);
141                   
142                    //Print("%p\n",temp->next);
143                }
144            }
145        //Print("HIER\n");
146            LNode* newElement   =   new LNode(t, i, p, r, temp->next);
147            temp->next          =   newElement;
148            return this;
149        }
150    }
151}
152
153// deletes the first elements of the list with the same degree
154// only used for the S-polys, which are already sorted by increasing degree by CList
155LNode*  LNode::deleteByDeg() {
156    return this;
157}
158
159// get next from current LNode
160LNode* LNode::getNext() {
161    return next;
162}
163
164// get the LPoly* out of LNode*
165LPoly* LNode::getLPoly() {
166    return data;
167}
168
169// get the data from the LPoly saved in LNode
170poly LNode::getPoly() {
171    return data->getPoly();
172}
173
174poly LNode::getTerm() {
175    return data->getTerm();
176}
177
178int LNode::getIndex() {
179    return data->getIndex();
180}
181
182Rule* LNode::getRule() {
183    return data->getRule();
184}
185
186// set the data from the LPoly saved in LNode
187void LNode::setPoly(poly p) {
188    data->setPoly(p);
189}
190
191void LNode::setTerm(poly t) {
192    data->setTerm(t);
193}
194
195void LNode::setIndex(int i) {
196    data->setIndex(i);
197}
198
199void LNode::setNext(LNode* l) {
200    next    =   l;
201}
202
203// test if for any list element the polynomial part of the data is equal to *p
204bool LNode::polyTest(poly* p) {
205    LNode* temp = new LNode(this);
206    while(NULL != temp) {
207        if(pComparePolys(temp->getPoly(),*p)) {
208            return 1;
209        }
210        temp = temp->next;
211    }
212    return 0;
213}
214
215LNode* LNode::getNext(LNode* l) {
216    return l->next;
217}
218
219// for debugging
220void LNode::print() {
221    LNode* temp = this;
222    Print("___________________List of S-polynomials______________________:\n");
223    Print("%p\n",this);
224    while(NULL != temp && NULL != temp->data) {
225        Print("Index: %d\n",temp->getIndex());
226        Print("Term: ");
227        pWrite(temp->getTerm());
228        Print("Poly: ");
229        pWrite(temp->getPoly());
230        Print("%p\n",temp->next);
231        temp = temp->next;
232    }
233    Print("_______________________________________________________________\n");
234}
235
236
237/*
238====================================
239functions working on the class LList
240====================================
241*/
242
243LList::LList() {
244    first   =   new LNode();
245    last    =   first;
246    length  =   0;
247}
248
249LList::LList(LPoly* lp) {
250    first   =   new LNode(lp);
251    last    =   first;
252    length  =   1;
253}
254
255LList::LList(poly t,int i,poly p,Rule* r) {
256    first   =   new LNode(t,i,p,r);
257    last    =   first;
258    length  =   1;
259} 
260
261LList::~LList() {
262    LNode* temp;
263    while(first) {
264        temp    =   first;
265        first   =   first->getNext();
266        delete  temp;
267        //Print("%p\n",first);
268    }
269}
270
271// insertion at the end of the list, needed for gPrev
272void LList::insert(LPoly* lp) {
273    last = last->insert(lp);
274    //Print("NEW LAST GPREV: ");
275    //pWrite(last->getPoly());
276    length++;
277    //Print("LENGTH %d\n",length);
278}
279
280void LList::insert(poly t,int i, poly p, Rule* r) {
281    last = last->insert(t,i,p,r);
282    length++;
283    //Print("LENGTH %d\n",length);
284}
285
286// insertion in front of the list, needed for sPolyList
287void LList::insertSP(LPoly* lp) {
288    first = first->insertSP(lp);
289    length++;
290    //Print("LENGTH %d\n",length);
291}
292
293void LList::insertSP(poly t,int i, poly p, Rule* r) {
294    first = first->insertSP(t,i,p,r);
295    length++;
296    //Print("LENGTH %d\n",length);
297}
298
299
300void LList::insertByLabel(poly t, int i, poly p, Rule* r) {
301    first = first->insertByLabel(t,i,p,r);
302    length++;
303    //Print("LENGTH %d\n",length);
304}
305
306void LList::insertByLabel(LNode* l) {
307    first = first->insertByLabel(l->getTerm(),l->getIndex(),l->getPoly(),l->getRule());
308    length++;
309    //Print("LENGTH %d\n",length);
310}
311
312void LList::deleteByDeg() {
313    first = first->deleteByDeg();
314}
315
316bool LList::polyTest(poly* p) {
317    return first->polyTest(p);
318}
319
320LNode* LList::getFirst() {
321    return first;
322}
323
324LNode* LList::getLast() {
325    return last;
326}
327
328int LList::getLength() {
329    return length;
330}
331
332void LList::setFirst(LNode* l) {
333    LNode* temp =   first;
334    temp->setNext(NULL);
335    first       =   l;
336    length--;
337}
338
339void LList::print() {
340    first->print();
341}
342
343/*
344=======================================
345functions working on the class LTagNode
346=======================================
347*/
348LTagNode::LTagNode() {
349    data    =   NULL;
350    next    =   NULL;
351}
352
353LTagNode::LTagNode(LNode* l) {
354    data = l;
355    next = NULL;
356}
357       
358LTagNode::LTagNode(LNode* l, LTagNode* n) {
359    data = l;
360    next = n;
361}
362
363 LTagNode::~LTagNode() {
364    delete next;
365    delete data;   
366}
367       
368// declaration with first as parameter due to sorting of LTagList
369LTagNode* LTagNode::insert(LNode* l) {
370    LTagNode* newElement  = new LTagNode(l, this);
371    return newElement;
372}
373
374LNode* LTagNode::getLNode() {
375    return this->data;
376}
377
378LTagNode* LTagNode::getNext() {
379    return next;
380}
381
382// NOTE: We insert at the beginning of the list and length = i-1, where i is the actual index.
383//       Thus given actual index i and idx being the index of the LPoly under investigation
384//       the element on position length-idx is the right one
385LNode* LTagNode::get(int idx, int length) {
386    if(idx == 1) {
387        return NULL;
388    }
389    else {
390        int j;
391        LTagNode* temp = this; // last
392        for(j=1;j<=length-idx+1;j++) {
393            temp = temp->next;
394        }
395        return temp->data;
396    }
397}
398
399
400/*
401=======================================
402functions working on the class LTagList
403=======================================
404*/
405LTagList::LTagList() {
406    LTagNode* first =   new LTagNode();
407   
408    length          =   0;
409}
410
411LTagList::LTagList(LNode* l) {
412    LTagNode* first =   new LTagNode(l);
413    length          =   1;
414}
415
416// declaration with first as parameter in LTagNode due to sorting of LTagList
417void LTagList::insert(LNode* l) {
418    first   =   first->insert(l);
419    length++;
420}
421
422void LTagList::setFirstCurrentIdx(LNode* l) {
423    firstCurrentIdx =   l;
424}
425
426LNode* LTagList::get(int idx) {
427    return first->get(idx, length);
428}
429
430LNode* LTagList::getFirst() {
431    return first->getLNode();
432}
433
434LNode* LTagList::getFirstCurrentIdx() {
435    return firstCurrentIdx;
436}
437
438/*
439=====================================
440functions working on the class TopRed
441=====================================
442*/
443
444TopRed::TopRed() {
445    _completed  =   NULL;
446    _toDo       =   NULL;
447}
448
449TopRed::TopRed(LList* c, LList* t) {
450    _completed  =   c;
451    _toDo       =   t;
452}
453
454LList* TopRed::getCompleted() {
455    return _completed;
456}
457
458LList* TopRed::getToDo() {
459    return _toDo;
460}
461
462/*
463====================================
464functions working on the class CNode
465====================================
466*/
467
468CNode::CNode() {
469    data    =   NULL;   
470    next    =   NULL;   
471}
472
473CNode::CNode(CPair* c) {
474    data    =   c;   
475    next    =   NULL;   
476}
477
478CNode::CNode(CPair* c, CNode* n) {
479    data    =   c;   
480    next    =   n;   
481}
482
483CNode::~CNode() {
484    delete data;
485}
486
487// insert sorts the critical pairs firstly by increasing total degree, secondly by increasing label
488// note: as all critical pairs have the same index here, the second sort is done on the terms of the labels
489// working only with linked, but not doubly linked lists due to memory usage we have to check the
490// insertion around the first element separately from the insertion around all other elements in the list
491CNode* CNode::insert(CPair* c, CNode* last) {
492    if(NULL == this->data) {
493        CNode* newElement   =   new CNode(c, this);
494        return newElement;
495    }
496    else {
497        poly u1 = ppMult_qq(c->getT1(),c->getLp1Term());
498        if( c->getDeg() < this->data->getDeg() ) { // lower degree than the first list element
499            CNode* newElement   =   new CNode(c, this);
500            return newElement;
501        }
502        if( c->getDeg() == this->data->getDeg() ) { // same degree than the first list element
503            if(1 != pLmCmp(u1,ppMult_qq(this->data->getT1(), this->data->getLp1Term()))) {
504                //pWrite(u1);
505                //Print("Multi-Term in CritPairs Sortierung altes Element: ");
506                //pWrite(ppMult_qq(this->data->getT1(),this->data->getLp1Term()));
507                CNode* newElement   =   new CNode(c, this);
508                return newElement;
509            }
510            else {
511                //Print("Insert Deg\n");
512                CNode* temp = this;
513                while(  NULL != temp->next->data ) {
514                    if(temp->next->data->getDeg() == c->getDeg() ) { 
515                        if(1 == pLmCmp(u1,ppMult_qq(temp->next->data->getT1(),temp->next->data->getLp1Term()))) {
516                            temp = temp->next;
517                        }
518                        else {
519                            CNode* newElement   =   new CNode(c, temp->next);
520                            temp->next          =   newElement;
521                            return this;
522                        } 
523                    }
524                    else {
525                        CNode* newElement   =   new CNode(c, temp->next);
526                        temp->next          =   newElement;
527                        return this;
528                    }
529                }
530                CNode* newElement   =   new CNode(c, last);
531                temp->next          =   newElement;
532                return this;
533            }
534        } // outer if-clause
535        if( c->getDeg() > this->data->getDeg() ) { // greater degree than the first list element
536            CNode* temp =   this;
537            while( NULL != temp->next->data ) {   
538                if( c->getDeg() < temp->next->data->getDeg() ) {
539                    CNode* newElement   =   new CNode(c, temp->next);
540                    temp->next          =   newElement;
541                    return this;
542                }
543                if( c->getDeg() == temp->next->data->getDeg() ) {
544                    if(1 != pLmCmp(u1,ppMult_qq(temp->next->data->getT1(),temp->next->data->getLp1Term()))) { 
545                        CNode* newElement   =   new CNode(c, temp->next);
546                        temp->next          =   newElement;
547                        return this;
548                    }
549                    else {
550                        temp = temp->next;
551                        while(  NULL != temp->next->data ) {
552                            if( temp->next->data->getDeg() == c->getDeg() ) { 
553                                if(1 == pLmCmp(u1,ppMult_qq(temp->next->data->getT1(),
554                                               temp->next->data->getLp1Term()))) {
555                                    temp = temp->next;
556                                }
557                                else {
558                                    CNode* newElement   =   new CNode(c, temp->next);
559                                    temp->next          =   newElement;
560                                    return this;
561                                } 
562                            }
563                            else {
564                                CNode* newElement   =   new CNode(c, temp->next);
565                                temp->next          =   newElement;
566                                return this;
567                            }
568                        }
569                        CNode* newElement   =   new CNode(c, last);
570                        temp->next          =   newElement;
571                        return this;
572                    }
573                }
574                if( c->getDeg() > temp->next->data->getDeg() ) {
575                    temp    =   temp->next;
576                }
577            }
578            CNode* newElement   =   new CNode(c, last);
579            temp->next          =   newElement;
580            return this;
581        }
582    }
583}
584
585// get the first elements from CList which by the above sorting have minimal degree
586CNode* CNode::getMinDeg() {
587    CNode* temp = this;
588    while( NULL != temp->data ) {
589        while(NULL != temp->next->data && temp->next->data->getDeg() == this->data->getDeg()) {
590            temp = temp->next;
591        }
592        CNode* returnCNode  =   temp->next;   
593        // every CList should end with a (NULL,NULL) element for a similar behaviour
594        // using termination conditions throughout the algorithm
595        temp->next          =   new CNode();
596        return returnCNode;
597    }
598    return NULL;
599}
600
601CPair* CNode::getData() {
602    return data;
603}
604
605CNode* CNode::getNext() {
606    return next;
607}
608
609LPoly* CNode::getAdLp1() {
610    return this->data->getAdLp1();
611}
612
613LPoly* CNode::getAdLp2() {
614    return this->data->getAdLp2();
615}
616
617poly CNode::getLp1Poly() {
618    return this->data->getLp1Poly();
619}
620
621poly CNode::getLp2Poly() {
622    return this->data->getLp2Poly();
623}
624
625poly CNode::getLp1Term() {
626    return this->data->getLp1Term();
627}
628
629poly CNode::getLp2Term() {
630    return this->data->getLp2Term();
631}
632
633int CNode::getLp1Index() {
634    return this->data->getLp1Index();
635}
636
637int CNode::getLp2Index() {
638    return this->data->getLp2Index();
639}
640
641poly CNode::getT1() {
642    return this->data->getT1();
643}
644
645poly* CNode::getAdT1() {
646    return this->data->getAdT1();
647}
648
649poly CNode::getT2() {
650    return this->data->getT2();
651}
652
653poly* CNode::getAdT2() {
654    return this->data->getAdT2();
655}
656
657Rule* CNode::getTestedRule() {
658    return this->data->getTestedRule();
659}
660
661// for debugging
662void CNode::print() {
663    CNode* temp = this;
664    Print("___________________List of critical pairs______________________:\n");
665    while(NULL != temp->data) {
666        Print("LP1 Index: %d\n",temp->getLp1Index());
667        Print("T1: ");
668        pWrite(temp->getT1());
669        Print("LP1 Term: ");
670        pWrite(temp->getLp1Term());
671        Print("LP1 Poly: ");
672        pWrite(temp->getLp1Poly());
673        Print("LP2 Index: %d\n",temp->getLp2Index());
674        Print("T2: ");
675        pWrite(temp->getT2());
676        Print("LP2 Term: ");
677        pWrite(temp->getLp2Term());
678        Print("LP2 Poly: ");
679        pWrite(temp->getLp2Poly());
680        Print("\n");
681        temp = temp->next;
682    }
683}
684
685/*
686====================================
687functions working on the class CList
688====================================
689*/
690// for initialization of CLists, last element alwas has data=NULL and next=NULL
691CList::CList() {
692    first   =   new CNode();
693    last    =   first;
694}
695
696CList::CList(CPair* c) {
697    first   =   new CNode(c);
698    last    =   first;
699}
700
701CList::~CList() {
702    CNode* temp;
703    while(first) {
704        temp    =   first;
705        first   =   first->getNext();
706        delete  temp;
707    }
708}
709
710// insert sorts the critical pairs firstly by increasing total degree, secondly by increasing label
711// note: as all critical pairs have the same index here, the second sort is done on the terms of the labels
712void CList::insert(CPair* c) {
713    first = first->insert(c, last);
714}
715
716CNode* CList::getFirst() {
717    return first;
718}
719
720// get the first elements from CList which by the above sorting have minimal degree
721// returns the pointer on the first element of those
722CNode* CList::getMinDeg() {
723    CNode* temp     =   first;
724    first           =   first->getMinDeg();
725    return temp;
726}
727
728void CList::print() {
729    first->print();
730}
731
732/*
733====================================
734functions working on the class RNode
735====================================
736*/
737RNode::RNode() {
738    //Print("HIER RNODE CONSTRUCTOR\n");
739    data    =   NULL;
740    next    =   NULL;
741}
742
743RNode::RNode(Rule* r) {
744    data    =   r;
745    next    =   NULL;
746}
747
748RNode::~RNode() {
749    //Print("DELETE RULE\n");
750    delete  data;
751}
752
753RNode* RNode::insert(Rule* r) {
754    RNode* newElement   =   new RNode(r);
755    newElement->next    =   this;
756    return newElement;
757}
758
759RNode* RNode::insert(int i, poly t) {
760    //Print("IN INSERT: ");
761    //pWrite(t);
762    Rule*   r           =   new Rule(i,t);
763    //Print("ADDRESS OF RULE: %p\n",r);
764    RNode* newElement   =   new RNode(r);
765    //Print("ADDRESS OF RNODE: %p\n",newElement);
766    //Print("ADDRESS OF RNODE DATA: %p\n",newElement->getRule());
767    newElement->next    =   this;
768    return newElement;
769}
770
771RNode* RNode::getNext() {
772    return next;
773}   
774
775Rule* RNode::getRule() {
776    return data;
777}
778
779int RNode::getRuleIndex() {
780    return data->getIndex();
781}
782
783poly RNode::getRuleTerm() {
784    return data->getTerm();
785}
786
787/*
788====================================
789functions working on the class RList
790====================================
791*/
792RList::RList() {
793    first = new RNode();
794}
795
796RList::RList(Rule* r) {
797    first = new RNode(r);
798}
799
800RList::~RList() {
801    RNode* temp;
802    //Print("%p\n",first);
803    while(first->getRule()) {
804        temp    =   first;
805        first   =   first->getNext();
806        //Print("1 %p\n",first);
807        //if(first) {
808            //Print("1' %p\n",first->getRule());
809            //Print("2 %p\n",first->getNext());
810            //Print("3 %p\n",first->getNext()->getRule());
811            //Print("3 %p\n",first->getNext()->getRuleTerm());
812        //}
813        delete  temp;
814    }
815    //Print("FERTIG\n");
816} 
817
818void RList::insert(int i, poly t) {
819    first = first->insert(i,t);
820}
821
822void RList::insert(Rule* r) {
823    first = first->insert(r);
824}
825
826RNode* RList::getFirst() {
827    return first;
828}
829
830Rule* RList::getRule() {
831    return this->getRule();
832}
833
834/*
835=======================================
836functions working on the class RTagNode
837=======================================
838*/
839
840RTagNode::RTagNode() {
841    data = NULL;
842    next = NULL;
843}
844 
845RTagNode::RTagNode(RNode* r) {
846    data = r;
847    next = NULL;
848}
849       
850RTagNode::RTagNode(RNode* r, RTagNode* n) {
851   
852    data = r;
853    next = n;
854}
855
856RTagNode::~RTagNode() {
857    delete data;   
858}
859       
860// declaration with first as parameter due to sorting of RTagList
861RTagNode* RTagNode::insert(RNode* r) {
862    //Print("Hier1\n");
863    RTagNode* newElement  = new RTagNode(r, this);
864    //Print("Hier2\n");
865    return newElement;
866}
867
868RNode* RTagNode::getRNode() {
869    return this->data;
870}
871
872RTagNode* RTagNode::getNext() {
873    return next;
874}
875
876// NOTE: We insert at the beginning of the list and length = i-1, where i is the actual index.
877//       Thus given actual index i and idx being the index of the LPoly under investigation
878//       the element on position length-idx+1 is the right one
879RNode* RTagNode::get(int idx, int length) {
880    if(idx==1 || idx==0) {
881        // NOTE: We set this NULL as putting it the last element in the list, i.e. the element having
882        //       RNode* = NULL would cost lots of iterations at each step of F5inc, with increasing
883        //       length of the list this should be prevented
884        return NULL;
885    }
886    else {
887        int j;
888        RTagNode* temp = this; 
889    //Print("\n\nHIER IN GET IDX\n");
890    //Print("FOR LOOP: %d\n",length-idx+1);   
891    for(j=1; j<=length-idx+1; j++) {
892            temp = temp->next;
893        }
894        return temp->data;
895    }
896}
897
898void RTagNode::set(RNode* r) {
899    this->data  =   r;
900}
901
902void RTagNode::print() {
903    RTagNode* temp  =   this;
904    if(NULL != temp && NULL != temp->getRNode()) {
905        Print("1. element: %d,  ",getRNode()->getRule()->getIndex());
906        pWrite(getRNode()->getRule()->getTerm());
907        temp    =   temp->next;
908        int i   =   2;
909        while(NULL != temp->getRNode() && NULL != temp) {
910            Print("%d. element: %d,  ",i,getRNode()->getRule()->getIndex());
911            pWrite(getRNode()->getRule()->getTerm());
912            temp    =   temp->next;
913            i++;
914        }
915    }
916}
917/*
918=======================================
919functions working on the class LTagList
920=======================================
921*/
922
923RTagList::RTagList() {
924    RTagNode* first =   new RTagNode();
925    length          =   0;
926}
927
928RTagList::RTagList(RNode* r) {
929    RTagNode* first =   new RTagNode(r);
930    length          =   1;
931}
932
933RTagList::~RTagList() {
934    RTagNode* temp;
935    while(first->getRNode()) {
936        temp    =   first;
937        first   =   first->getNext();
938        delete  temp;
939    }
940}
941
942// declaration with first as parameter in LTagNode due to sorting of LTagList
943void RTagList::insert(RNode* r) {
944    first = first->insert(r);
945    //Print("LENGTH:%d\n",length);
946    length = length +1;
947    //Print("LENGTH:%d\n",length);
948}
949
950RNode* RTagList::getFirst() {
951    return first->getRNode();
952}
953
954RNode* RTagList::get(int idx) {
955    return first->get(idx, length);
956}
957
958void RTagList::setFirst(RNode* r) {
959    first->set(r);
960}
961
962void RTagList::print() {
963    first->print();
964}
965
966int RTagList::getLength() {
967    return length;
968}
969#endif
Note: See TracBrowser for help on using the repository browser.