Kstars

MeshIterator.h
1 /*
2  SPDX-FileCopyrightText: 2007 James B. Bowlin <[email protected]>
3  SPDX-License-Identifier: BSD-3-Clause AND GPL-2.0-or-later
4 */
5 
6 #pragma once
7 
8 #include "typedef.h"
9 
10 class HTMesh;
11 
12 /**
13  * @class MeshIterator
14  * MeshIterator is a very lightweight class used to iterate over the
15  * result set of an HTMesh intersection. If you want to iterate over the same
16  * result set multiple times in the same block of code, you don't need to create
17  * a new MeshIterator, just call the reset() method and then re-use the iterator.
18  */
19 
21 {
22  public:
23  MeshIterator(HTMesh *mesh, BufNum bufNum = 0);
24 
25  /** @short true if there are more trixel to iterate over.
26  */
27  bool hasNext() const { return cnt < m_size; }
28 
29  /** @short returns the next trixel
30  */
31  Trixel next() const { return index[cnt++]; }
32 
33  /** @short returns the number of trixels stored
34  */
35  int size() const { return m_size; }
36 
37  /** @short sets the count back to zero so you can use this iterator
38  * to iterate again over the same result set.
39  */
40  void reset() const { cnt = 0; }
41 
42  private:
43  const Trixel *index;
44  int m_size;
45  mutable int cnt;
46 };
Definition: HTMesh.h:56
int size() const
returns the number of trixels stored
Definition: MeshIterator.h:35
bool hasNext() const
true if there are more trixel to iterate over.
Definition: MeshIterator.h:27
void reset() const
sets the count back to zero so you can use this iterator to iterate again over the same result set.
Definition: MeshIterator.h:40
Trixel next() const
returns the next trixel
Definition: MeshIterator.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:57:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.