initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / containers / Lists / List / ListLoopM.H
blob48b8c5d17e5336268f6fcd6ae7798c662d4b5233
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
26     List\<T\> is a 1D vector of objects of type T, where the size of the
27     vector is known and used for subscript bounds checking, etc.
29 \*---------------------------------------------------------------------------*/
31 #ifndef ListLoop_H
32 #define ListLoop_H
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 #ifdef vectorMachine
38 // Element access looping using [] for vector machines
40 #define List_FOR_ALL(f, i)                      \
41         register const label _n##i = (f).size();\
42         for (register label i=0; i<_n##i; i++)  \
43         {
45 #define List_END_FOR_ALL  }
47 #define List_ELEM(f, fp, i)  (fp[i])
49 #define List_ACCESS(type, f, fp) \
50     type* const __restrict__ fp = (f).begin()
52 #define List_CONST_ACCESS(type, f, fp) \
53     const type* const __restrict__ fp = (f).begin()
55 #else
57 // Pointer looping for scalar machines
59 #define List_FOR_ALL(f, i)                      \
60         register label i = (f).size();          \
61         while (i--)                             \
62         {                                       \
64 #define List_END_FOR_ALL  }
66 #define List_ELEM(f, fp, i)  (*fp++)
68 #define List_ACCESS(type, f, fp) \
69     register type* __restrict__ fp = (f).begin()
71 #define List_CONST_ACCESS(type, f, fp) \
72     register const type* __restrict__ fp = (f).begin()
74 #endif
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 #endif
81 // ************************************************************************* //