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-2014 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  (
110  "List<T>::append(const UList<T>&)"
111  ) << "attempted appending to self" << abort(FatalError);
112  }
113 
114  label nextFree = this->size();
115  setSize(nextFree + lst.size());
116 
117  forAll(lst, elemI)
118  {
119  this->operator[](nextFree++) = lst[elemI];
120  }
121 }
122 
123 
124 template<class T>
126 {
127  label nextFree = this->size();
128  setSize(nextFree + lst.size());
129 
130  forAll(lst, elemI)
131  {
132  this->operator[](nextFree++) = lst[elemI];
133  }
134 }
135 
136 
137 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
138 
139 template<class T>
140 inline void Foam::List<T>::operator=(const T& t)
141 {
143 }
144 
145 
146 // ************************************************************************* //
static const List< T > & null()
Return a null List.
Definition: ListI.H:43
Xfer< List< T > > xfer()
Transfer contents to the Xfer container.
Definition: ListI.H:90
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
T & newElmt(const label)
Return subscript-checked element of UList.
Definition: ListI.H:64
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
autoPtr< List< T > > clone() const
Clone.
Definition: ListI.H:34
Xfer< T > xferMove(T &)
const volScalarField & T
Definition: createFields.H:25
List()
Null constructor.
Definition: ListI.H:29
label n
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
A List with indirect addressing.
Definition: fvMatrix.H:106
label size() const
Return the number of elements in the list.
#define forAll(list, i)
Definition: UList.H:421
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
points setSize(newPointi)
void resize(const label)
Alias for setSize(const label)
Definition: ListI.H:50
error FatalError
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
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:97
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
void operator=(const UList< T > &)
Assignment from UList operator. Takes linear time.
Definition: List.C:429