1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* |
---|
5 | * ABSTRACT: list interface |
---|
6 | */ |
---|
7 | #ifdef HAVE_CONFIG_H |
---|
8 | #include "config.h" |
---|
9 | #endif /* HAVE_CONFIG_H */ |
---|
10 | #include <kernel/mod2.h> |
---|
11 | |
---|
12 | #ifdef HAVE_F5 |
---|
13 | |
---|
14 | #include <kernel/kutil.h> |
---|
15 | #include <kernel/structs.h> |
---|
16 | #include <omalloc/omalloc.h> |
---|
17 | #include <kernel/polys.h> |
---|
18 | #include <polys/monomials/p_polys.h> |
---|
19 | #include <kernel/ideals.h> |
---|
20 | #include <kernel/febase.h> |
---|
21 | #include <kernel/kstd1.h> |
---|
22 | #include <kernel/khstd.h> |
---|
23 | #include <polys/kbuckets.h> |
---|
24 | #include <polys/weight.h> |
---|
25 | #include <misc/intvec.h> |
---|
26 | #include <kernel/polys.h> |
---|
27 | #include <kernel/lpolynomial.h> |
---|
28 | #include <kernel/lplist.h> |
---|
29 | |
---|
30 | |
---|
31 | /* |
---|
32 | ========================================= |
---|
33 | ========================================= |
---|
34 | implementation of the functions of list.h |
---|
35 | ========================================= |
---|
36 | ========================================= |
---|
37 | */ |
---|
38 | |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | /* |
---|
43 | =========================== |
---|
44 | insert general node in list |
---|
45 | =========================== |
---|
46 | */ |
---|
47 | Node* GenNode::insert(LPoly* d) { |
---|
48 | int ret = data->compare(*d); |
---|
49 | switch(ret) { |
---|
50 | case 0: case -1: { |
---|
51 | next = next->insert(d); |
---|
52 | return this; |
---|
53 | } |
---|
54 | case 1: { |
---|
55 | GenNode* newNode = new GenNode(d,this); |
---|
56 | return newNode; |
---|
57 | } |
---|
58 | } |
---|
59 | return this; |
---|
60 | } |
---|
61 | |
---|
62 | /* |
---|
63 | ======================== |
---|
64 | get general node in list |
---|
65 | ======================== |
---|
66 | */ |
---|
67 | void GenNode::get() { |
---|
68 | data->get(); |
---|
69 | next->get(); |
---|
70 | } |
---|
71 | |
---|
72 | /* |
---|
73 | ========================= |
---|
74 | insert first node in list |
---|
75 | ========================= |
---|
76 | */ |
---|
77 | Node* FirstNode::insert(LPoly* d) { |
---|
78 | next = next->insert(d); |
---|
79 | return this; |
---|
80 | } |
---|
81 | |
---|
82 | /* |
---|
83 | =========================================================================================== |
---|
84 | get first node in list (no element in this place, so go on to the next element in the list) |
---|
85 | =========================================================================================== |
---|
86 | */ |
---|
87 | void FirstNode::get() { |
---|
88 | next->get(); |
---|
89 | } |
---|
90 | |
---|
91 | /* |
---|
92 | ======================= |
---|
93 | insert end node in list |
---|
94 | ======================= |
---|
95 | */ |
---|
96 | Node* EndNode::insert(LPoly* d) { |
---|
97 | GenNode* data = new GenNode(d,this); |
---|
98 | return data; |
---|
99 | } |
---|
100 | |
---|
101 | /* |
---|
102 | =============================================================================== |
---|
103 | get end node in list (nothing to do, as there are no more elements in the list) |
---|
104 | =============================================================================== |
---|
105 | */ |
---|
106 | void EndNode::get() { |
---|
107 | } |
---|
108 | |
---|
109 | /* |
---|
110 | ========================= |
---|
111 | insert an element in list |
---|
112 | ========================= |
---|
113 | */ |
---|
114 | void LpList::insert(LPoly* d) { |
---|
115 | start->insert(d); |
---|
116 | // there is no return value also we get the address of the new element in the list |
---|
117 | // returning this value in the other insert functions is due to their virtual |
---|
118 | // declaration in the base class Node |
---|
119 | } |
---|
120 | |
---|
121 | /* |
---|
122 | ============================== |
---|
123 | get all elements from the list |
---|
124 | ============================== |
---|
125 | */ |
---|
126 | void LpList::get() { |
---|
127 | start->get(); |
---|
128 | } |
---|
129 | |
---|
130 | #endif |
---|