source: git/kernel/lists.h @ d72b11

spielwiese
Last change on this file since d72b11 was d72b11, checked in by Christian Eder, 15 years ago
lists for LPolys, CritPairs & Rules git-svn-id: file:///usr/local/Singular/svn/trunk@11270 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.8 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: lists.h,v 1.1 2008-12-26 13:51:10 ederc Exp $ */
5/*
6* ABSTRACT: list interface
7*/
8#include "lpolynomial.h"
9#ifndef LISTS_HEADER
10#define LISTS_HEADER
11
12#ifdef HAVE_F5
13
14
15/*
16=======================
17=======================
18linked lists for LPolys
19=======================
20=======================
21*/
22
23
24/*
25===========================
26classes for lists of LPolys
27===========================
28*/
29class LNode;
30class LList;
31
32
33/*
34=======================================
35LNode class (nodes for lists of LPolys)
36=======================================
37*/
38class LNode {
39    private:
40        LPoly* data;
41        LNode* next;
42    public:
43        LNode(LPoly* lp, LNode* n) {
44            data = lp;
45            next = n;
46        }
47        LNode(poly* t, long* i, poly* p, LNode* n) {
48            data->set(t,i,p);
49            next = n;
50        }
51        ~LNode() {
52            delete next;
53            delete data;   
54        }
55        LNode* append(LPoly* lp) {
56            LNode* new_element = new LNode(lp,NULL);
57            next = new_element;
58            return new_element;
59        }
60        LNode* append(poly* t, long* i, poly* p) {
61            LNode* new_element = new LNode(t,i,p,NULL);
62            next = new_element;
63            return new_element;
64        }
65        LPoly* getLPoly() const {
66            return data;
67        }
68};
69
70
71/*
72============================
73class LList(lists of LPolys)
74============================
75*/
76class LList {
77    private:
78        LNode*  first;
79        LNode*  last;
80        long    length;
81    public:
82        LList(LPoly* lp) {
83            first = new LNode(lp,NULL);
84            last = first;
85            length = 1;
86        }
87        ~LList() {
88            delete first;
89        }
90        void append(LPoly* lp) {
91            last = last->append(lp);
92            length++;
93        }
94        void append(poly* t,long* i, poly* p) {
95            last = last->append(t,i,p);
96            length++;
97        }
98        long getLength() const {
99            return length;
100        }
101        LNode* getFirst() const {
102            return first;
103        }
104        LNode* getLast() const {
105            return last;
106        }
107};
108
109
110/*
111=======================
112=======================
113linked lists for CPairs
114=======================
115=======================
116*/
117
118
119/*
120===========================
121classes for lists of CPairs
122===========================
123*/
124class CNode;
125class CList;
126
127
128/*
129=======================================
130CNode class (nodes for lists of CPairs)
131=======================================
132*/
133class CNode {
134    private:
135        LPoly* data;
136        CNode* next;
137    public:
138        CNode(LPoly* lp, CNode* n) {
139            data = lp;
140            next = n;
141        }
142        ~CNode() {
143            delete next;
144            delete data;   
145        }
146        CNode* append(LPoly* lp) {
147            CNode* new_element = new CNode(lp,NULL);
148            next = new_element;
149            return new_element;
150        }
151        LPoly* getLPoly() const {
152            return data;
153        }
154};
155
156
157/*
158=============================
159class CPList(lists of CPairs)
160=============================
161*/
162class CList {
163    private:
164        CNode*  first;
165        CNode*  last;
166        long    length;
167    public:
168        CList(LPoly* lp) {
169            first = new CNode(lp,NULL);
170            last = first;
171            length = 1;
172        }
173        ~CList() {
174            delete first;
175        }
176        void append(LPoly* lp) {
177            last = last->append(lp);
178            length++;
179        }
180        long getLength() const {
181            return length;
182        }
183        CNode* getFirst() const {
184            return first;
185        }
186        CNode* getLast() const {
187            return last;
188        }
189};
190
191
192
193
194#endif
195#endif
196 
Note: See TracBrowser for help on using the repository browser.