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