graphRowI.H 3.91 KB
Newer Older
Franjo's avatar
Franjo committed
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | cfMesh: A library for mesh generation
   \\    /   O peration     |
    \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
     \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
Andrew Heather's avatar
Andrew Heather committed
9
    This file is part of OpenFOAM.
Franjo's avatar
Franjo committed
10

Andrew Heather's avatar
Andrew Heather committed
11 12 13 14
    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
Franjo's avatar
Franjo committed
15

Andrew Heather's avatar
Andrew Heather committed
16
    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
Franjo's avatar
Franjo committed
17 18 19 20 21
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
Andrew Heather's avatar
Andrew Heather committed
22
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
Franjo's avatar
Franjo committed
23 24 25

\*---------------------------------------------------------------------------*/

26
#include "Ostream.H"
Andrew Heather's avatar
Andrew Heather committed
27

Franjo's avatar
Franjo committed
28 29 30 31 32 33 34
// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

template<class graphType>
inline Foam::graphRow<graphType>::graphRow(graphType& g, const label i)
:
    data_(g),
    rowI_(i)
Andrew Heather's avatar
Andrew Heather committed
35 36
{}

Franjo's avatar
Franjo committed
37 38 39 40

template<class graphType>
inline Foam::graphRow<graphType>::graphRow
(
41
    const graphRow<graphType>& r
Franjo's avatar
Franjo committed
42 43
)
:
44 45
    data_(r.data_),
    rowI_(r.rowI_)
Andrew Heather's avatar
Andrew Heather committed
46 47
{}

Franjo's avatar
Franjo committed
48 49 50 51 52 53 54 55 56

// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

template<class graphType>
inline Foam::label Foam::graphRow<graphType>::size() const
{
    return data_.sizeOfRow(rowI_);
}

Andrew Heather's avatar
Andrew Heather committed
57

Franjo's avatar
Franjo committed
58 59 60 61 62 63
template<class graphType>
inline void Foam::graphRow<graphType>::setSize(const label s)
{
    data_.setRowSize(rowI_, s);
}

Andrew Heather's avatar
Andrew Heather committed
64

Franjo's avatar
Franjo committed
65 66 67 68 69 70
template<class graphType>
inline void Foam::graphRow<graphType>::clear()
{
    data_.setRowSize(rowI_, 0);
}

Andrew Heather's avatar
Andrew Heather committed
71

Franjo's avatar
Franjo committed
72 73 74 75 76 77
template<class graphType>
inline void Foam::graphRow<graphType>::append(const label el)
{
    data_.append(rowI_, el);
}

Andrew Heather's avatar
Andrew Heather committed
78

Franjo's avatar
Franjo committed
79 80 81 82 83 84
template<class graphType>
inline void Foam::graphRow<graphType>::appendIfNotIn(const label el)
{
    data_.appendIfNotIn(rowI_, el);
}

Andrew Heather's avatar
Andrew Heather committed
85

Franjo's avatar
Franjo committed
86 87 88 89 90 91
template<class graphType>
inline bool Foam::graphRow<graphType>::contains(const label e) const
{
    return data_.contains(rowI_, e);
}

Andrew Heather's avatar
Andrew Heather committed
92

Franjo's avatar
Franjo committed
93
template<class graphType>
94 95 96 97 98 99 100 101
inline bool Foam::graphRow<graphType>::found(const label e) const
{
    return data_.found(rowI_, e);
}


template<class graphType>
inline Foam::label Foam::graphRow<graphType>::find
Franjo's avatar
Franjo committed
102 103 104 105
(
    const label e
) const
{
106
    return data_.find(rowI_, e);
Franjo's avatar
Franjo committed
107 108
}

Andrew Heather's avatar
Andrew Heather committed
109

Franjo's avatar
Franjo committed
110 111 112 113 114 115 116 117
// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //

template<class graphType>
inline Foam::label Foam::graphRow<graphType>::operator[](const label i) const
{
    return data_(rowI_, i);
}

Andrew Heather's avatar
Andrew Heather committed
118

Franjo's avatar
Franjo committed
119 120 121 122 123 124
template<class graphType>
inline Foam::label& Foam::graphRow<graphType>::operator[](const label i)
{
    return data_(rowI_, i);
}

Andrew Heather's avatar
Andrew Heather committed
125

Franjo's avatar
Franjo committed
126 127 128
template<class graphType>
inline void Foam::graphRow<graphType>::operator=
(
129
    const graphRow<graphType>& rhs
Franjo's avatar
Franjo committed
130 131
)
{
132 133 134 135
    const label len = rhs.size();

    data_.setRowSize(rowI_, len);
    for (label i = 0; i < len; ++i)
Andrew Heather's avatar
Andrew Heather committed
136
    {
137
        data_(rowI_, i) = rhs[i];
Andrew Heather's avatar
Andrew Heather committed
138
    }
Franjo's avatar
Franjo committed
139 140
}

Andrew Heather's avatar
Andrew Heather committed
141

Franjo's avatar
Franjo committed
142
template<class graphType>
143 144
template<class ListType>
inline void Foam::graphRow<graphType>::operator=(const ListType& rhs)
Franjo's avatar
Franjo committed
145
{
146 147 148 149
    const label len = rhs.size();

    data_.setRowSize(rowI_, len);
    for (label i = 0; i < len; ++i)
Andrew Heather's avatar
Andrew Heather committed
150
    {
151
        data_(rowI_, i) = rhs[i];
Andrew Heather's avatar
Andrew Heather committed
152
    }
Franjo's avatar
Franjo committed
153 154
}

Andrew Heather's avatar
Andrew Heather committed
155

Franjo's avatar
Franjo committed
156
template<class graphType>
157
inline Foam::Ostream& Foam::operator<<
Franjo's avatar
Franjo committed
158
(
159
    Ostream& os,
Franjo's avatar
Franjo committed
160 161 162
    const Foam::graphRow<graphType>& r
)
{
163 164 165 166
    const label len = r.size();

    os << len << '(';
    for (label i = 0; i < len; ++i)
Andrew Heather's avatar
Andrew Heather committed
167
    {
168 169
        if (i) os << ' ';
        os << r[i];
Andrew Heather's avatar
Andrew Heather committed
170
    }
171
    os << ')';
Andrew Heather's avatar
Andrew Heather committed
172

Franjo's avatar
Franjo committed
173 174 175
    return os;
}

Andrew Heather's avatar
Andrew Heather committed
176

Franjo's avatar
Franjo committed
177
// ************************************************************************* //