subGraph.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  subGraph
26 
27 Description
28  This class provides access to a row of a graph
29 
30 SourceFiles
31  subGraphI.H
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef subGraph_H
36 #define subGraph_H
37 
38 #include "bool.H"
39 #include "Ostream.H"
40 #include "error.H"
41 #include "graphRow.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 template<class graphType> class subGraph;
49 template<class graphType>
51 
52 /*---------------------------------------------------------------------------*\
53  Class subGraph Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class graphType>
57 class subGraph
58 {
59  // Private data
60  //- reference to the graph
61  graphType& data_;
62 
63  //- starts at row
64  const label start_;
65 
66  //- number of rows in the subGraph
67  const label size_;
68 
69  // Private member functions
70  //- check index
71  inline void checkIndex(const label i) const;
72 
73 public:
74 
75  // Constructors
76 
77  //- Construct from graph and start row and size
78  inline subGraph(graphType&, const label, const label);
79 
80  //- Copy contructor
81  inline subGraph(const subGraph<graphType>&);
82 
83  // Destructor
84 
85  inline ~subGraph();
86 
87  // Member Functions
88 
89  //- Returns the number of rows
90  inline label size() const;
91 
92  //- Returns the size of a given row
93  inline label sizeOfRow(const label rowI) const;
94 
95  // Member Operators
96 
97  //- Append an element to the given row
98  inline void append(const label rowI, const label);
99 
100  //- Append an element to the given row if it does not exist there
101  inline void appendIfNotIn(const label rowI, const label);
102 
103  //- check if the element is in the given row (takes linear time)
104  inline bool contains(const label rowI, const label e) const;
105  inline label containsAtPosition(const label rowI, const label e) const;
106 
107  //- set and get operators
108  inline label operator()(const label i, const label j) const;
109  inline label& operator()(const label i, const label j);
110  inline const graphRow<const graphType> operator[](const label) const;
111  inline graphRow<graphType> operator[](const label);
112 
113  // IOstream operators
114 
115  // Write subGraph to Ostream.
116  friend Ostream& operator<< <graphType>
117  (
118  Ostream&,
119  const subGraph<graphType>&
120  );
121 };
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 } // End namespace Foam
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 #include "subGraphI.H"
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 #endif
134 
135 // ************************************************************************* //
Foam::subGraph::data_
graphType & data_
reference to the graph
Definition: subGraph.H:60
Foam::subGraph::contains
bool contains(const label rowI, const label e) const
check if the element is in the given row (takes linear time)
Definition: subGraphI.H:110
Foam::subGraph::start_
const label start_
starts at row
Definition: subGraph.H:63
Foam::subGraph::containsAtPosition
label containsAtPosition(const label rowI, const label e) const
Definition: subGraphI.H:120
graphRow.H
Foam::subGraph::subGraph
subGraph(graphType &, const label, const label)
Construct from graph and start row and size.
Definition: subGraphI.H:48
Foam::subGraph::append
void append(const label rowI, const label)
Append an element to the given row.
Definition: subGraphI.H:93
subGraphI.H
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::subGraph::size_
const label size_
number of rows in the subGraph
Definition: subGraph.H:66
Foam::subGraph::appendIfNotIn
void appendIfNotIn(const label rowI, const label)
Append an element to the given row if it does not exist there.
Definition: subGraphI.H:100
bool.H
System bool.
Foam::subGraph
Definition: subGraph.H:47
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::subGraph::size
label size() const
Returns the number of rows.
Definition: subGraphI.H:81
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
Ostream.H
Foam::subGraph::operator[]
const graphRow< const graphType > operator[](const label) const
Definition: subGraphI.H:158
Foam::subGraph::sizeOfRow
label sizeOfRow(const label rowI) const
Returns the size of a given row.
Definition: subGraphI.H:87
Foam::subGraph::checkIndex
void checkIndex(const label i) const
check index
Definition: subGraphI.H:30
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::subGraph::operator()
label operator()(const label i, const label j) const
set and get operators
Definition: subGraphI.H:132
Foam::subGraph::~subGraph
~subGraph()
Definition: subGraphI.H:73