TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
RTabInt.h
1/****************************************************************************
2* Copyright (c) 2022, 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 RTabInt_included
17#define RTabInt_included
18
19
20#include <TRUSTArray.h>
21
22
23/*! @brief class RTabInt
24 *
25 * La classe RTabInt implemente la notion de vecteur
26 * d'entier redimensionnable.
27 *
28 *
29 *
30 */
31
32class RTabInt : public Objet_U
33{
34
35 Declare_instanciable_sans_constructeur(RTabInt);
36
37
38public:
39
40 // Constructeurs et destructeur
41 RTabInt(int n=0, int x=0);
42
43 // Tailles
44 inline int size() const;
45
46 inline void resize(int);
47 int search(int);
48 void add(int);
49 inline int& operator[](int i);
50 inline const int& operator[](int i) const ;
51 inline int& operator()(int i);
52 inline const int& operator()(int i) const ;
53
54 const ArrOfInt& donnees() const;
55
56private:
57 static int TB_;
58 int size_r_;
59 ArrOfInt data;
60 int min_data;
61 int max_data;
62
63};
64/*! @brief operateur []
65 *
66 */
67inline int RTabInt::size() const
68{
69 return size_r_;
70}
71
72/*! @brief operateur []
73 *
74 */
75inline void RTabInt::resize(int n)
76{
77 if(n>data.size_array())
78 {
79 int sz = data.size_array();
80 data.resize_array(n);
81 data.resize_array(sz+TB_);
82 for(int j=sz; j< sz+TB_; j++)
83 data[j] = -1;
84 }
85}
86
87
88/*! @brief operateur []
89 *
90 */
91inline int& RTabInt::operator[](int i)
92{
93 return data[i];
94}
95inline const int& RTabInt::operator[](int i) const
96{
97 return data[i];
98}
99
100/*! @brief idem operator[]
101 *
102 */
103inline int& RTabInt::operator()(int i)
104{
105 return data[i];
106}
107inline const int& RTabInt::operator()(int i) const
108{
109 return data[i];
110}
111
112#endif//RTABINT
113
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55
int size() const
operateur []
Definition RTabInt.h:67
void resize(int)
operateur []
Definition RTabInt.h:75
const ArrOfInt & donnees() const
Renvoi le tableau porte.
Definition RTabInt.cpp:62
int & operator()(int i)
idem operator[]
Definition RTabInt.h:103
int & operator[](int i)
operateur []
Definition RTabInt.h:91
RTabInt(int n=0, int x=0)
constructeur
Definition RTabInt.cpp:45
void add(int)
Ajoute TB_ cases si i > size_r_ sinon ajoute i en queue.
Definition RTabInt.cpp:70
int search(int)
Recherche un element egal a i dans le tableau Renvoi la valeur si elle existe, -1 sinon.
Definition RTabInt.cpp:95