15#include <Static_Int_Lists.h>
16#include <TRUSTArrays.h>
20template <
typename _SIZE_>
23 index_.resize_array(0);
24 valeurs_.resize_array(0);
34template <
typename _SIZE_>
40 index_.resize_array(nb_listes + 1);
43 for (
int_t i = 0; i < nb_listes; i++)
45 assert(sizes[i] >= 0);
46 index_[i+1] = index_[i] + sizes[i];
48 const int_t somme_sizes = index_[nb_listes];
49 valeurs_.resize_array(somme_sizes);
57template <
typename _SIZE_>
60 assert(data.
size_array() == valeurs_.size_array());
61 valeurs_.inject_array(data);
66template <
typename _SIZE_>
67static bool check_index_data(
const ArrOfInt_T<_SIZE_>& index,
const ArrOfInt_T<_SIZE_>& data)
74 for (_SIZE_ i = 0; i < n; i++)
75 if (index[i+1] < index[i])
88template <
typename _SIZE_>
91 assert(check_index_data(index, data));
102template <
typename _SIZE_>
105 const int_t i_debut = (num_liste < 0) ? 0 : num_liste;
106 const int_t i_fin = (num_liste < 0) ? index_.size_array() - 1 : num_liste + 1;
109 for (
int_t i = i_debut; i < i_fin; i++)
111 const int_t index = index_[i];
112 const int_t size = index_[i+1] - index;
113 valeurs_liste.
ref_array(valeurs_, index, size);
123template <
typename _SIZE_>
128 const int_t index = index_[i];
132template <
typename _SIZE_>
136 os << index_ << tspace;
137 os << valeurs_ << tspace;
142template <
typename _SIZE_>
153template <
typename _SIZE_>
158 os <<
"sizes of lists : ";
169 for (
int_t j=0; j<sz; ++j)
170 os << valeurs_[(index_[i]+j)] <<
" ";
177template <
typename _SIZE_>
180 const int nb_lists = src.
size();
181 index_.resize_array(nb_lists + 1, RESIZE_OPTIONS::NOCOPY_NOINIT);
184 for (
int i = 0; i < nb_lists; i++)
186 idx += src[i].size_array();
190 valeurs_.resize_array(idx, RESIZE_OPTIONS::NOCOPY_NOINIT);
192 for (
int i = 0; i < nb_lists; i++)
196 valeurs_.inject_array(a, sz, idx , 0 );
Class defining operators and methods for all reading operation in an input flow (file,...
Base class for output streams.
This class allows storing lists of integers accessible in constant time.
void set(const ArrsOfInt_t &src)
Sortie & ecrire(Sortie &os) const
void copy_list_to_array(int_t i_liste, ArrOfInt_t &array) const
Copies the i-th list into the provided array. The array must be resizable.
void set_index_data(const ArrOfInt_t &index, const ArrOfInt_t &data)
Replaces index and data arrays.
ArrsOfInt_T< _SIZE_ > ArrsOfInt_t
void reset()
Destroys all lists.
int_t get_list_size(int_t i_liste) const
Returns the number of elements in list i.
void trier_liste(int_t i)
Sorts the values of the i-th list in ascending order.
void set_list_sizes(const ArrOfInt_t &sizes)
Destroys existing lists and creates new ones.
int_t get_nb_lists() const
Returns the number of stored lists.
Entree & readOn(Entree &is)
ArrOfInt_T< _SIZE_ > ArrOfInt_t
Sortie & printOn(Sortie &os) const
void set_data(const ArrOfInt_t &data)
Replaces the values stored in all lists with those from the data array.
_SIZE_ size_array() const
virtual void ref_array(TRUSTArray &, _SIZE_ start=0, _SIZE_ sz=-1)
TRUSTArray & inject_array(const TRUSTArray &source, _SIZE_ nb_elements=-1, _SIZE_ first_element_dest=0, _SIZE_ first_element_source=0)
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)