TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Array_tools.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Array_tools_included
17#define Array_tools_included
18
19#include <TRUSTTab.h>
20
21/*! @brief Methode outil pour retirer les doublons dans un tableau.
22 *
23 */
24template <typename _TYPE_, typename _SIZE_>
25void array_trier_retirer_doublons(TRUSTArray<_TYPE_,_SIZE_>& array);
26
27/*! @brief Methode outil pour calculer l'intersection entre deux listes d'entiers.
28 *
29 */
30template <typename _TYPE_, typename _SIZE_>
31void array_calculer_intersection(TRUSTArray<_TYPE_,_SIZE_>& liste1, const TRUSTArray<_TYPE_,_SIZE_>& liste2);
32
33/*! @brief Methode outil pour calculer la difference entre deux listes d'entiers triees
34 *
35 */
36void array_retirer_elements(ArrOfInt& sorted_array, const ArrOfInt& sorted_elements_list);
37
38/*! @brief Methode outil pour chercher une valeur dans un tableau trie
39 *
40 */
41int array_bsearch(const ArrOfInt& tab, int valeur);
42
43/*! @brief Tri lexicographique d'un tableau
44 *
45 */
46template <typename _TYPE_, typename _SIZE_>
47int tri_lexicographique_tableau(TRUSTTab<_TYPE_,_SIZE_>& tab);
48
49/*! @brief Tri indirect (on trie le tableau index qui contient des numeros de lignes dans tab)
50 *
51 */
52template <typename _TYPE_, typename _SIZE_>
53int tri_lexicographique_tableau_indirect(const TRUSTTab<_TYPE_,_SIZE_>& tab, ArrOfInt_T<_SIZE_>& index);
54
55/*! @brief Methode outil pour retirer les doublons dans un tableau.
56 *
57 */
58template <typename _SIZE_>
59void tableau_trier_retirer_doublons(IntTab_T<_SIZE_>& tab);
60
61#if INT_is_64_ == 2
62// BigIntTab = TRUSTTab<int, trustIdType>: doesn't match IntTab_T<_SIZE_> since value/size types differ
63void tableau_trier_retirer_doublons(BigIntTab& tab);
64#endif
65
66/*! @brief Methode outil pour trouver les doublons (permet de retirer les doublons sans changer l'ordre des elements)
67 *
68 */
69void calculer_renum_sans_doublons(const IntTab& tab, ArrOfInt& renum, ArrOfInt& items_a_garder);
70
71
72template<typename _TYPE_, typename _SIZE_>
73inline void append_array_to_array(TRUSTArray<_TYPE_,_SIZE_>& dest, const TRUSTArray<_TYPE_,_SIZE_>& src)
74{
75 const int n1 = dest.size_array(), n2 = src.size_array();
76 dest.resize_array(n1+n2);
77 dest.inject_array(src, n2 /* nb elem */, n1 /* dest index */, 0 /* src index */);
78}
79
80#endif /* Array_tools_included */
Represents a an array of int/int64/double/... values.
Definition TRUSTArray.h:81
_SIZE_ size_array() const
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)
: Tableau a n entrees pour n<= 4.
Definition TRUSTTab.h:31