graphRow.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh 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 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  graphRow
26 
27 Description
28  This class provides access to a row of a graph
29 
30 SourceFiles
31  graphRowI.H
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef graphRow_H
36 #define graphRow_H
37 
38 #include "bool.H"
39 #include "Ostream.H"
40 #include "error.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 class VRWGraph;
48 
49 template<class graphType> class graphRow;
50 template<class graphType>
52 
53 /*---------------------------------------------------------------------------*\
54  Class graphRow Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template<class graphType>
58 class graphRow
59 {
60  // Private data
61  //- reference to the graph
62  graphType& data_;
63 
64  //- row number
65  const label rowI_;
66 
67  // Private member functions
68  //- check index
69  inline void checkIndex(const label i) const;
70 
71 public:
72 
73  // Constructors
74 
75  //- Construct from graph and row number
76  inline graphRow(graphType&, const label);
77 
78  //- Copy contructor
79  inline graphRow(const graphRow<graphType>&);
80 
81  // Destructor
82 
83  inline ~graphRow();
84 
85  // Member Functions
86 
87  //- Returns the number of rows
88  inline label size() const;
89 
90  //- Reset the number of rows
91  inline void setSize(const label size);
92 
93  //- Clear the graph
94  inline void clear();
95 
96  // Member Operators
97 
98  //- Append an element to the given row
99  inline void append(const label);
100 
101  //- Append an element to the given row if it does not exist there
102  inline void appendIfNotIn(const label);
103 
104  //- check if the element is in the given row (takes linear time)
105  inline bool contains(const label e) const;
106  inline label containsAtPosition(const label e) const;
107 
108  //- set and get operators
109  inline label operator[](const label) const;
110  inline label& operator[](const label);
111 
112  //- Assignment operator
113  inline void operator=(const graphRow<graphType>&);
114  template<class listType>
115  inline void operator=(const listType&);
116 
117  // IOstream operators
118 
119  // Write graphRow to Ostream.
120  friend Ostream& operator<< <graphType>
121  (
122  Ostream&,
123  const graphRow<graphType>&
124  );
125 
126  //- Read from Istream, discarding contents of existing graphRow.
127 /* friend Istream& operator>> <T, width>
128  (
129  Istream&,
130  graphRow<T, width>&
131  );
132 */
133 };
134 
136 typedef graphRow<VRWGraph> row;
137 
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 } // End namespace Foam
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #include "graphRowI.H"
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 #endif
150 
151 // ************************************************************************* //
Foam::graphRow::checkIndex
void checkIndex(const label i) const
check index
Definition: graphRowI.H:30
Foam::graphRow::appendIfNotIn
void appendIfNotIn(const label)
Append an element to the given row if it does not exist there.
Definition: graphRowI.H:98
Foam::row
graphRow< VRWGraph > row
Definition: graphRow.H:135
Foam::graphRow::~graphRow
~graphRow()
Definition: graphRowI.H:66
Foam::graphRow::data_
graphType & data_
reference to the graph
Definition: graphRow.H:61
Foam::graphRow::append
void append(const label)
Append an element to the given row.
Definition: graphRowI.H:92
Foam::graphRow::rowI_
const label rowI_
row number
Definition: graphRow.H:64
Foam::graphRow::setSize
void setSize(const label size)
Reset the number of rows.
Definition: graphRowI.H:80
graphRowI.H
Foam::constRow
const typedef graphRow< const VRWGraph > constRow
Definition: graphRow.H:134
Foam::label
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.H
Foam::graphRow::size
label size() const
Returns the number of rows.
Definition: graphRowI.H:74
Foam::graphRow::clear
void clear()
Clear the graph.
Definition: graphRowI.H:86
bool.H
System bool.
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::graphRow::operator[]
label operator[](const label) const
set and get operators
Definition: graphRowI.H:121
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::graphRow
Definition: graphRow.H:48
Foam::graphRow::graphRow
graphRow(graphType &, const label)
Construct from graph and row number.
Definition: graphRowI.H:47
Ostream.H
VRWGraph
This class is an implementation of a graph with variable column width. The imoplementation is memory ...
Foam::graphRow::containsAtPosition
label containsAtPosition(const label e) const
Definition: graphRowI.H:111
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::graphRow::contains
bool contains(const label e) const
check if the element is in the given row (takes linear time)
Definition: graphRowI.H:104
Foam::graphRow::operator=
void operator=(const graphRow< graphType > &)
Assignment operator.
Definition: graphRowI.H:134