ListI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
28 template<class T>
30 {}
31 
32 
33 template<class T>
35 {
36  return autoPtr<List<T>>(new List<T>(*this));
37 }
38 
39 
40 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
41 
42 template<class T>
44 {
45  return NullObjectRef<List<T>>();
46 }
47 
48 
49 template<class T>
50 inline void Foam::List<T>::resize(const label newSize)
51 {
52  this->setSize(newSize);
53 }
54 
55 
56 template<class T>
57 inline void Foam::List<T>::resize(const label newSize, const T& a)
58 {
59  this->setSize(newSize, a);
60 }
61 
62 
63 template<class T>
64 inline T& Foam::List<T>::newElmt(const label i)
65 {
66  if (i >= this->size())
67  {
68  setSize(2*this->size());
69  }
70 
71  return UList<T>::operator[](i);
72 }
73 
74 
75 template<class T>
76 inline void Foam::List<T>::size(const label n)
77 {
79 }
80 
81 
82 template<class T>
84 {
85  return UList<T>::size_;
86 }
87 
88 
89 template<class T>
91 {
92  return xferMove(*this);
93 }
94 
95 
96 template<class T>
97 inline void Foam::List<T>::append(const T& t)
98 {
99  setSize(size()+1, t);
100 }
101 
102 
103 template<class T>
104 inline void Foam::List<T>::append(const UList<T>& lst)
105 {
106  if (this == &lst)
107  {
109  << "attempted appending to self" << abort(FatalError);
110  }
111 
112  label nextFree = this->size();
113  setSize(nextFree + lst.size());
114 
115  forAll(lst, elemI)
116  {
117  this->operator[](nextFree++) = lst[elemI];
118  }
119 }
120 
121 
122 template<class T>
124 {
125  label nextFree = this->size();
126  setSize(nextFree + lst.size());
127 
128  forAll(lst, elemI)
129  {
130  this->operator[](nextFree++) = lst[elemI];
131  }
132 }
133 
134 
135 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
136 
137 template<class T>
138 inline void Foam::List<T>::operator=(const T& t)
139 {
141 }
142 
143 
144 template<class T>
145 inline void Foam::List<T>::operator=(const zero)
146 {
148 }
149 
150 
151 // ************************************************************************* //
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Xfer< List< T > > xfer()
Transfer contents to the Xfer container.
Definition: ListI.H:90
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
T & newElmt(const label)
Return subscript-checked element of UList.
Definition: ListI.H:64
static const List< T > & null()
Return a null List.
Definition: ListI.H:43
void resize(const label)
Alias for setSize(const label)
Definition: ListI.H:50
points setSize(newPointi)
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
label size() const
Return the number of elements in the list.
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:97
static const zero Zero
Definition: zero.H:91
errorManip< error > abort(error &err)
Definition: errorManip.H:131
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
label size() const
Return the number of elements in the UList.
Definition: ListI.H:83
const volScalarField & T
List()
Null constructor.
Definition: ListI.H:29
void operator=(const UList< T > &)
Assignment from UList operator. Takes linear time.
Definition: List.C:399
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
A List with indirect addressing.
Definition: fvMatrix.H:106
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
label n
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
autoPtr< List< T > > clone() const
Clone.
Definition: ListI.H:34