OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
single-list.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Antoine Joux, Vanessa Vitse and Titouan Coladon
3  *
4  * This file is part of openf4.
5  *
6  * openf4 is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * openf4 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with openf4. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 #ifndef OPENF4_SINGLE_LIST_H
27 #define OPENF4_SINGLE_LIST_H
28 
30 #include "global.h"
31 #include <iostream>
32 #include <cassert>
34 #include "term.h"
35 
39 namespace F4
40 {
41 
46  template <typename Element>
47  struct NodeList
48  {
49  public:
50 
51  /* Constructor */
52 
56  NodeList();
57 
61  NodeList(Element coefficient, int numMonomial);
62 
66  NodeList(Term<Element> const & term);
67 
68 
69  /* Get / Set */
70 
75  Term<Element> const & getTerm() const;
76 
81  int getNumMonomial() const;
82 
87  Element getCoefficient() const;
88 
93  void setCoefficient(Element element);
94 
98  void setCoefficientOne();
99 
104  void setNumMonomial(int numMonomial);
105 
106  /* Attributes */
107 
110  };
111 
116  template <typename Element>
118  {
119  public:
120 
121  /* Constructor */
122 
126  SingleList();
127 
131  SingleList(SingleList const & toCopy);
132 
136  SingleList(SingleList && toCopy);
137 
138 
139  /* Destructor */
140 
144  ~SingleList();
145 
149  void clear();
150 
155  void deleteAfter(NodeList<Element> * it);
156 
157 
158  /* Miscellaneous */
159 
164  NodeList<Element> * getBegin() const;
165 
171 
177  bool empty() const;
178 
183  int getNbTerms() const;
184 
189  Term<Element> const & front() const;
190 
197  NodeList<Element> * emplaceBegin(Element coefficient, int numMonomial);
198 
206  NodeList<Element> * emplaceAfter(NodeList<Element> * it, Element coefficient, int numMonomial);
207 
215  NodeList<Element> * emplaceOn(NodeList<Element> * it, Element coefficient, int numMonomial);
216 
223 
231 
235  void printList(ostream & stream) const;
236 
242 
243 
244  /* Operator overload */
245 
251  SingleList & operator=(SingleList const & toCopy);
252 
258  SingleList & operator=(SingleList && toCopy);
259 
260 
261  private:
262 
265  int _nbTerms;
266  };
267 
272  template <typename Element>
273  std::ostream & operator<<(std::ostream & stream, SingleList<Element> const & list);
274 }
275 
277 #include "../src/single-list.inl"
280 #endif // OPENF4_SINGLE_LIST_H
NodeList< Element > * getBeforeBegin()
Return an iterator before the first element.
Element getCoefficient() const
Get the coefficient of the term.
NodeList< Element > * insertAfter(NodeList< Element > *it, Term< Element > const &term)
Construct a term in place after the node pointed by it.
void setCoefficient(Element element)
Set the coefficient of the term.
NodeList< Element > * getBegin() const
Return an iterator to the first element.
NodeList< Element > * insertBegin(Term< Element > const &term)
Construct a term in place at the beginning of the list.
int getNumMonomial() const
Get the number of the monomial of the term.
Term< Element > const & getTerm() const
Get the term of the node.
Represent a term.
Definition: term.h:50
Represent a single chained list.
Definition: single-list.h:117
bool empty() const
Test if the list is empty.
Wrapper for config.h in order to avoid multiple definitions.
void clear()
Erase all the terms.
void setNumMonomial(int numMonomial)
Set the number of the monomial of the term.
~SingleList()
Destructor.
NodeList< Element > * emplaceBegin(Element coefficient, int numMonomial)
Construct a term in place at the beginning of the list.
NodeList< Element > * popFront()
Remove the first element.
NodeList()
Constructor.
void deleteAfter(NodeList< Element > *it)
Erase all the terms after it, set it->_next to 0.
NodeList * _next
Definition: single-list.h:109
void printList(ostream &stream) const
Print the list.
Term< Element > _term
Definition: single-list.h:108
Represent a node of the single chained list.
Definition: single-list.h:47
void setCoefficientOne()
Set the coefficient of the term to one.
Declaration of class Term.
NodeList< Element > * _beforeBegin
Definition: single-list.h:264
NodeList< Element > * emplaceAfter(NodeList< Element > *it, Element coefficient, int numMonomial)
Construct a term in place after the node pointed by it.
NodeList< Element > * _list
Definition: single-list.h:263
NodeList< Element > * emplaceOn(NodeList< Element > *it, Element coefficient, int numMonomial)
Construct a term in place after the node pointed by it.
int getNbTerms() const
Get the number of terms.
SingleList()
Constructor.
SingleList & operator=(SingleList const &toCopy)
Overload the operator =.
Term< Element > const & front() const
Get the first term of the list.