OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
dynamic-array.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_DYNAMIC_ARRAY_H
27 #define OPENF4_DYNAMIC_ARRAY_H
28 
30 #include "global.h"
31 #include <iostream>
32 #include <cassert>
38 namespace F4
39 {
44  template <typename dataType>
46  {
47  public:
48 
49  /* Constructor */
50 
56  DynamicArray(int width, int maxHeight);
57 
64  DynamicArray(int width, int maxHeight, int initialCapacity);
65 
66 
67  /* Destructor */
68 
72  ~DynamicArray();
73 
74 
75  /* Miscellaneous */
76 
80  void printDynamicArray(std::ostream & stream=std::cout) const;
81 
85  void reset();
86 
87 
88  /* Get / Set */
89 
93  int getWidth();
94 
98  int getMaxHeight();
99 
103  int getCurrentHeight();
104 
105 
106  /* Access */
107 
112  dataType & operator[](int index);
113 
118  dataType const & operator[](int index) const;
119 
124  dataType * getBegin();
125 
131  dataType * getNext(dataType * data);
132 
133 
134  private:
135 
136  int _width;
140  int _colIt;
141  int _rowIt;
142  dataType ** _array;
144  };
145 
150  template <typename dataType>
151  std::ostream & operator<<(std::ostream & stream, DynamicArray<dataType> const & dynamicArray);
152 
153 }
154 
156 #include "../src/dynamic-array.inl"
159 #endif // OPENF4_DYNAMIC_ARRAY_H
dataType ** _array
Wrapper for config.h in order to avoid multiple definitions.
Represent a dynamic array whose the width is fixed, the memory is allocated by blocs.
Definition: dynamic-array.h:45
int getMaxHeight()
Get the maximum height of the dynamic array.
void printDynamicArray(std::ostream &stream=std::cout) const
Print the dynamic array.
int getWidth()
Get the width of the dynamic array.
~DynamicArray()
Destructor.
void reset()
Reset the dynamic array, do not free the memory.
dataType & operator[](int index)
Overload the operator [].
int getCurrentHeight()
Get the current height of the dynamic array.
DynamicArray(int width, int maxHeight)
Constructor.
dataType * getNext(dataType *data)
Get an iterator to next data after data.
dataType * getBegin()
Get an iterator to the beginning of the array.