14#include "arcane/std/SimpleTableInternalMng.h"
30 m_simple_table_internal->clear();
42 Integer position = m_simple_table_internal->m_values.dim1Size();
43 m_simple_table_internal->m_values.resize(position + 1);
45 m_simple_table_internal->m_row_names.add(row_name);
46 m_simple_table_internal->m_row_sizes.add(0);
48 m_simple_table_internal->m_last_row = position;
59 Integer position = m_simple_table_internal->m_values.dim1Size();
60 m_simple_table_internal->m_values.resize(position + 1);
62 m_simple_table_internal->m_row_names.add(row_name);
63 m_simple_table_internal->m_row_sizes.add(0);
80 Integer position = m_simple_table_internal->m_values.dim1Size();
81 m_simple_table_internal->m_values.resize(position + size);
83 m_simple_table_internal->m_row_names.addRange(rows_names);
86 m_simple_table_internal->m_last_row = position;
97 if (column_name.
empty())
100 Integer position = m_simple_table_internal->m_values.dim2Size();
101 m_simple_table_internal->m_values.resize(m_simple_table_internal->m_values.dim1Size(), position + 1);
103 m_simple_table_internal->m_column_names.add(column_name);
104 m_simple_table_internal->m_column_sizes.add(0);
106 m_simple_table_internal->m_last_column = position;
114 if (column_name.
empty())
117 Integer position = m_simple_table_internal->m_values.dim2Size();
118 m_simple_table_internal->m_values.resize(m_simple_table_internal->m_values.dim1Size(), position + 1);
120 m_simple_table_internal->m_column_names.add(column_name);
121 m_simple_table_internal->m_column_sizes.add(0);
138 Integer position = m_simple_table_internal->m_values.dim2Size();
139 m_simple_table_internal->m_values.resize(m_simple_table_internal->m_values.dim1Size(), position + size);
141 m_simple_table_internal->m_column_names.addRange(columns_names);
144 m_simple_table_internal->m_last_column = position;
155 if (position < 0 || position >= m_simple_table_internal->m_values.dim1Size())
159 Integer size_row = m_simple_table_internal->m_row_sizes[position];
161 if (m_simple_table_internal->m_values.dim2Size() < size_row + 1)
166 m_simple_table_internal->m_last_row = position;
167 m_simple_table_internal->m_last_column = size_row;
169 m_simple_table_internal->m_row_sizes[position]++;
177 m_simple_table_internal->m_column_sizes[size_row] = std::max(position + 1, m_simple_table_internal->m_column_sizes[size_row]);
185 std::optional<Integer> position = m_simple_table_internal->m_row_names.span().findFirst(row_name);
189 else if (create_if_not_exist)
198 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1)
209 if (position < 0 || position >= m_simple_table_internal->m_values.dim1Size())
213 Integer size_row = m_simple_table_internal->m_row_sizes[position];
214 Integer min_size = (elements.
size() <= m_simple_table_internal->m_values.dim2Size() - size_row
216 : m_simple_table_internal->m_values.dim2Size() - size_row);
218 for (
Integer i = 0; i < min_size; i++) {
219 view[i + size_row] = elements[i];
220 m_simple_table_internal->m_column_sizes[i + size_row] = std::max(position + 1, m_simple_table_internal->m_column_sizes[i + size_row]);
222 m_simple_table_internal->m_row_sizes[position] += min_size;
224 m_simple_table_internal->m_last_row = position;
225 m_simple_table_internal->m_last_column = m_simple_table_internal->m_row_sizes[position] - 1;
227 return elements.
size() <= m_simple_table_internal->m_values.dim2Size() - size_row;
233 std::optional<Integer> position = m_simple_table_internal->m_row_names.span().findFirst(row_name);
238 else if (create_if_not_exist)
247 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1)
258 if (position < 0 || position >= m_simple_table_internal->m_values.dim2Size())
261 Integer size_column = m_simple_table_internal->m_column_sizes[position];
263 if (m_simple_table_internal->m_values.dim1Size() < size_column + 1)
266 m_simple_table_internal->m_values[size_column][position] =
element;
268 m_simple_table_internal->m_last_column = position;
269 m_simple_table_internal->m_last_row = size_column;
271 m_simple_table_internal->m_column_sizes[position]++;
272 m_simple_table_internal->m_row_sizes[size_column] = std::max(position + 1, m_simple_table_internal->m_row_sizes[size_column]);
280 std::optional<Integer> position = m_simple_table_internal->m_column_names.span().findFirst(column_name);
284 else if (create_if_not_exist)
293 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1)
304 if (position < 0 || position >= m_simple_table_internal->m_values.dim2Size())
307 Integer size_column = m_simple_table_internal->m_column_sizes[position];
308 Integer min_size = (elements.
size() <= m_simple_table_internal->m_values.dim1Size() - size_column
310 : m_simple_table_internal->m_values.dim1Size() - size_column);
312 for (
Integer i = 0; i < min_size; i++) {
313 m_simple_table_internal->m_values[i + size_column][position] = elements[i];
314 m_simple_table_internal->m_row_sizes[i + size_column] = std::max(position + 1, m_simple_table_internal->m_row_sizes[i + size_column]);
316 m_simple_table_internal->m_column_sizes[position] += min_size;
318 m_simple_table_internal->m_last_column = position;
319 m_simple_table_internal->m_last_row = m_simple_table_internal->m_column_sizes[position] - 1;
321 return elements.
size() <= m_simple_table_internal->m_values.dim1Size() - size_column;
327 std::optional<Integer> position = m_simple_table_internal->m_column_names.span().findFirst(column_name);
332 else if (create_if_not_exist)
341 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1)
352 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1 || m_simple_table_internal->m_last_row - 1 < 0)
354 m_simple_table_internal->m_last_row--;
357 if (m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] <= m_simple_table_internal->m_last_column)
358 m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] = m_simple_table_internal->m_last_column + 1;
360 m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column] =
element;
361 if (!update_last_position)
362 m_simple_table_internal->m_last_row++;
369 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1 || m_simple_table_internal->m_last_row + 1 >= m_simple_table_internal->m_values.dim1Size())
371 m_simple_table_internal->m_last_row++;
373 if (m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] <= m_simple_table_internal->m_last_column)
374 m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] = m_simple_table_internal->m_last_column + 1;
375 if (m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] <= m_simple_table_internal->m_last_row)
376 m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] = m_simple_table_internal->m_last_row + 1;
378 m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column] =
element;
379 if (!update_last_position)
380 m_simple_table_internal->m_last_row--;
387 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1 || m_simple_table_internal->m_last_column - 1 < 0)
389 m_simple_table_internal->m_last_column--;
392 if (m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] <= m_simple_table_internal->m_last_row)
393 m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] = m_simple_table_internal->m_last_row + 1;
395 m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column] =
element;
396 if (!update_last_position)
397 m_simple_table_internal->m_last_column++;
404 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1 || m_simple_table_internal->m_last_column + 1 >= m_simple_table_internal->m_values.dim2Size())
406 m_simple_table_internal->m_last_column++;
408 if (m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] <= m_simple_table_internal->m_last_column)
409 m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] = m_simple_table_internal->m_last_column + 1;
410 if (m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] <= m_simple_table_internal->m_last_row)
411 m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] = m_simple_table_internal->m_last_row + 1;
413 m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column] =
element;
414 if (!update_last_position)
415 m_simple_table_internal->m_last_column--;
425 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1 || m_simple_table_internal->m_last_row - 1 < 0)
430 if (update_last_position) {
431 m_simple_table_internal->m_last_row--;
433 if (m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] <= m_simple_table_internal->m_last_column)
434 m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] = m_simple_table_internal->m_last_column + 1;
435 return m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column];
438 return m_simple_table_internal->m_values[m_simple_table_internal->m_last_row - 1][m_simple_table_internal->m_last_column];
444 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1 || m_simple_table_internal->m_last_row + 1 >= m_simple_table_internal->m_values.dim1Size())
449 if (update_last_position) {
450 m_simple_table_internal->m_last_row++;
452 if (m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] <= m_simple_table_internal->m_last_column)
453 m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] = m_simple_table_internal->m_last_column + 1;
454 if (m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] <= m_simple_table_internal->m_last_row)
455 m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] = m_simple_table_internal->m_last_row + 1;
456 return m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column];
458 return m_simple_table_internal->m_values[m_simple_table_internal->m_last_row + 1][m_simple_table_internal->m_last_column];
464 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1 || m_simple_table_internal->m_last_column - 1 < 0)
469 if (update_last_position) {
470 m_simple_table_internal->m_last_column--;
473 if (m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] <= m_simple_table_internal->m_last_row)
474 m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] = m_simple_table_internal->m_last_row + 1;
475 return m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column];
477 return m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column - 1];
483 if (m_simple_table_internal->m_last_row == -1 || m_simple_table_internal->m_last_column == -1 || m_simple_table_internal->m_last_column + 1 >= m_simple_table_internal->m_values.dim2Size())
488 if (update_last_position) {
489 m_simple_table_internal->m_last_column++;
491 if (m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] <= m_simple_table_internal->m_last_column)
492 m_simple_table_internal->m_row_sizes[m_simple_table_internal->m_last_row] = m_simple_table_internal->m_last_column + 1;
493 if (m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] <= m_simple_table_internal->m_last_row)
494 m_simple_table_internal->m_column_sizes[m_simple_table_internal->m_last_column] = m_simple_table_internal->m_last_row + 1;
495 return m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column];
497 return m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column + 1];
506 m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column] =
element;
513 if (position_x < 0 || position_x >= m_simple_table_internal->m_values.dim2Size() || position_y < 0 || position_y >= m_simple_table_internal->m_values.dim1Size())
516 if (m_simple_table_internal->m_column_sizes[position_x] <= position_y)
517 m_simple_table_internal->m_column_sizes[position_x] = position_y + 1;
518 if (m_simple_table_internal->m_row_sizes[position_y] <= position_x)
519 m_simple_table_internal->m_row_sizes[position_y] = position_x + 1;
521 m_simple_table_internal->m_values[position_y][position_x] =
element;
523 m_simple_table_internal->m_last_row = position_y;
524 m_simple_table_internal->m_last_column = position_x;
532 std::optional<Integer> position_x = m_simple_table_internal->m_column_names.span().findFirst(column_name);
533 std::optional<Integer> position_y = m_simple_table_internal->m_row_names.span().findFirst(row_name);
535 if (position_x && position_y)
546 return m_simple_table_internal->m_values[m_simple_table_internal->m_last_row][m_simple_table_internal->m_last_column];
552 if (position_x < 0 || position_x >= m_simple_table_internal->m_values.dim2Size() || position_y < 0 || position_y >= m_simple_table_internal->m_values.dim1Size())
555 if (update_last_position) {
556 m_simple_table_internal->m_last_column = position_x;
557 m_simple_table_internal->m_last_row = position_y;
560 return m_simple_table_internal->m_values[position_y][position_x];
566 std::optional<Integer> position_x = m_simple_table_internal->m_column_names.span().findFirst(column_name);
567 std::optional<Integer> position_y = m_simple_table_internal->m_row_names.span().findFirst(row_name);
569 if (position_x && position_y)
570 return element(position_x.value(), position_y.value(), update_last_position);
582 for (
Integer i = 0; i < size; i++) {
583 copie[i] = m_simple_table_internal->m_values[position][i];
591 std::optional<Integer> position_y = m_simple_table_internal->m_row_names.
span().
findFirst(row_name);
593 return row(position_y.value());
606 for (
Integer i = 0; i < size; i++) {
607 copie[i] = m_simple_table_internal->m_values[i][position];
615 std::optional<Integer> position_x = m_simple_table_internal->m_column_names.
span().
findFirst(column_name);
617 return column(position_x.value());
627 if (position < 0 || position >= m_simple_table_internal->m_values.dim1Size())
629 return m_simple_table_internal->m_row_sizes[position];
635 std::optional<Integer> position_y = m_simple_table_internal->m_row_names.span().findFirst(row_name);
637 return rowSize(position_y.value());
647 if (position < 0 || position >= m_simple_table_internal->m_values.dim2Size())
649 return m_simple_table_internal->m_column_sizes[position];
655 std::optional<Integer> position_x = m_simple_table_internal->m_column_names.span().findFirst(column_name);
667 std::optional<Integer> position_y = m_simple_table_internal->m_row_names.span().findFirst(row_name);
669 return position_y.value();
676 std::optional<Integer> position_x = m_simple_table_internal->m_column_names.span().findFirst(column_name);
678 return position_x.value();
688 return m_simple_table_internal->m_values.dim1Size();
694 return m_simple_table_internal->m_values.dim2Size();
703 if (position < 0 || position >= m_simple_table_internal->m_values.dim1Size())
706 return m_simple_table_internal->m_row_names[position];
712 if (position < 0 || position >= m_simple_table_internal->m_values.dim2Size())
715 return m_simple_table_internal->m_column_names[position];
724 if (new_name.
empty() || position < 0 || position >= m_simple_table_internal->m_values.dim1Size())
726 m_simple_table_internal->m_row_names[position] = new_name;
733 std::optional<Integer> position_y = m_simple_table_internal->m_row_names.span().findFirst(row_name);
742 if (new_name.
empty() || position < 0 || position >= m_simple_table_internal->m_values.dim2Size())
744 m_simple_table_internal->m_column_names[position] = new_name;
751 std::optional<Integer> position_x = m_simple_table_internal->m_column_names.span().findFirst(column_name);
763 if (column_name.
empty())
767 for (
Integer i = 0; i < m_simple_table_internal->m_values.dim1Size(); i++) {
773 avg /= view.
size() - 1;
785 return m_simple_table_internal;
791 if (simple_table_internal.
isNull())
792 ARCANE_FATAL(
"The reference passed as a parameter is Null.");
793 m_simple_table_internal = simple_table_internal;
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Modifiable view of an array of type T.
Span< const T > span() const
Immutable view of this array.
Constant view of an array of type T.
bool contains(const_reference v) const
true if the array contains the element of value v
constexpr Integer size() const noexcept
Number of elements in the array.
bool isNull() const
Indicates if the counter references a non-null instance.
Reference to an instance.
bool editElementLeft(Real element, bool update_last_position) override
Method to edit an element to the left of the last element most recently manipulated (same row/column ...
bool addElementInRow(Integer position, Real element) override
Method to add an element to a row.
Ref< SimpleTableInternal > internal() override
Method allowing retrieval of a reference to the object SimpleTableInternal used.
Integer rowPosition(const String &row_name) override
Method allowing retrieval of the position of a row.
bool addElementInColumn(Integer position, Real element) override
Method to add an element to a column.
String columnName(Integer position) override
Method allowing retrieval of the name of a column from its position.
bool addElementsInColumn(Integer position, ConstArrayView< Real > elements) override
Method to add multiple elements to a column.
Integer numberOfRows() override
Method allowing retrieval of the number of rows in the table. This is, in a sense,...
RealUniqueArray column(Integer position) override
Method allowing retrieval of a copy of a column.
bool addElementsInSameColumn(ConstArrayView< Real > elements) override
Method to add multiple elements to the column most recently manipulated.
bool addRows(StringConstArrayView rows_names) override
Method to add multiple rows.
bool addElementsInSameRow(ConstArrayView< Real > elements) override
Method to add multiple elements to the row most recently manipulated.
Real elementDown(bool update_last_position) override
Method allowing retrieval of an element below the last element recently manipulated (row below/same c...
void clearInternal() override
Method to clear the content of the SimpleTableInternal.
void setInternal(const Ref< SimpleTableInternal > &simple_table_internal) override
Method allowing setting a reference to a SimpleTableInternal.
Real element() override
Method allowing retrieval of a copy of an element.
bool editElementDown(Real element, bool update_last_position) override
Method to edit an element below the last element most recently manipulated (row below/same column).
Integer addAverageColumn(const String &column_name) override
Method allowing creation of a column containing the average of elements of each row.
bool editColumnName(Integer position, const String &new_name) override
Method allowing changing the name of a column.
bool editRowName(Integer position, const String &new_name) override
Method allowing changing the name of a row.
bool addElementInSameColumn(Real element) override
Method to add an element to the column most recently manipulated.
String rowName(Integer position) override
Method allowing retrieval of the name of a row from its position.
Integer addColumn(const String &column_name) override
Method to add a column.
RealUniqueArray row(Integer position) override
Method allowing retrieval of a copy of a row.
Real elementUp(bool update_last_position) override
Method allowing retrieval of an element above the last element recently manipulated (row above/same c...
bool editElementRight(Real element, bool update_last_position) override
Method allowing editing an element to the right of the last element recently manipulated (same row/co...
bool addElementInSameRow(Real element) override
Method to add an element to the row most recently manipulated.
bool addElementsInRow(Integer position, ConstArrayView< Real > elements) override
Method to add multiple elements to a row.
Integer rowSize(Integer position) override
Method allowing retrieval of the size of a row. Including hypothetical 'gaps' in the row.
Integer columnSize(Integer position) override
Method allowing retrieval of the size of a column. Including hypothetical 'gaps' in the column.
bool editElement(Real element) override
Method allowing modification of an element in the table.
bool editElementUp(Real element, bool update_last_position) override
Method to edit an element above the last element most recently manipulated (row above/same column).
Integer numberOfColumns() override
Method allowing retrieval of the number of columns in the table. This is, in a sense,...
Integer columnPosition(const String &column_name) override
Method allowing retrieval of the position of a column.
Real elementRight(bool update_last_position) override
Method allowing retrieval of an element to the right of the last element recently manipulated (same r...
Integer addRow(const String &row_name) override
Method to add a row.
Real elementLeft(bool update_last_position) override
Method allowing retrieval of an element to the left of the last element recently manipulated (same ro...
bool addColumns(StringConstArrayView columns_names) override
Method to add multiple columns.
std::optional< SizeType > findFirst(const_reference v) const
Unicode character string.
bool empty() const
True if the string is empty (null or "").
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ConstArrayView< String > StringConstArrayView
C equivalent of a 1D array of strings.
Int32 Integer
Type representing an integer.
UniqueArray< Real > RealUniqueArray
Dynamic 1D array of reals.
double Real
Type representing a real number.
UniqueArray< Integer > IntegerUniqueArray
Dynamic 1D array of integers.