TrioCFD 1.9.9_beta
TrioCFD documentation
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 Utility method to remove duplicates from an array.
22 *
23 */
24template <typename _TYPE_, typename _SIZE_>
25void array_trier_retirer_doublons(TRUSTArray<_TYPE_,_SIZE_>& array);
26
27/*! @brief Utility method to compute the intersection of two integer lists.
28 *
29 */
30template <typename _TYPE_, typename _SIZE_>
31void array_calculer_intersection(TRUSTArray<_TYPE_,_SIZE_>& liste1, const TRUSTArray<_TYPE_,_SIZE_>& liste2);
32
33/*! @brief Utility method to compute the difference between two sorted integer lists.
34 *
35 */
36void array_retirer_elements(ArrOfInt& sorted_array, const ArrOfInt& sorted_elements_list);
37
38/*! @brief Utility method to search for a value in a sorted array.
39 *
40 */
41int array_bsearch(const ArrOfInt& tab, int valeur);
42
43/*! @brief Lexicographic sort of an array.
44 *
45 */
46template <typename _TYPE_, typename _SIZE_>
47int tri_lexicographique_tableau(TRUSTTab<_TYPE_,_SIZE_>& tab);
48
49/*! @brief Indirect sort (sorts the index array which contains row numbers in 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 Utility method to remove duplicates from an array.
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 Utility method to find duplicates (allows removing duplicates without changing the order of 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)
N-dimensional array for N <= 4.
Definition TRUSTTab.h:31