1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
/**************************************************************************
* *
* Regina - A Normal Surface Theory Calculator *
* Computational Engine *
* *
* Copyright (c) 1999-2011, Ben Burton *
* For further details contact Ben Burton (bab@debian.org). *
* *
* This program 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 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT 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 along with this program; if not, write to the Free *
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
**************************************************************************/
/* end stub */
/*! \file triangulation/npermit.h
* \brief Provides utilities for iterating through permutations.
*/
#ifndef __NPERMIT_H
#ifndef __DOXYGEN
#define __NPERMIT_H
#endif
#include "regina-core.h"
#include "maths/nperm4.h"
namespace regina {
/**
* \weakgroup triangulation
* @{
*/
/**
* An iterator class that runs through all 24 permutations of four
* elements.
*
* \deprecated This class will removed in a future release of Regina, since
* it is completely unnecessary. Just loop directly through the 24 elements
* of NPerm4::S4.
*
* \ifacespython Not present.
*/
class REGINA_API NPermItS4 {
private:
int permIndex;
public:
/**
* Creates a new iterator pointing at the first permutation.
*/
NPermItS4();
/**
* Points this iterator at the first permutation.
*/
void init();
/**
* Points this iterator at the next permutation after the one it
* is currently pointing to.
*
* \pre This iterator is not past-the-end.
*/
void operator ++ (int);
/**
* Returns the permutation at which this iterator is pointing.
*
* \pre This iterator is not past-the-end.
*
* @return the permutation at which this iterator is pointing.
*/
const NPerm4& operator * () const;
/**
* Determines if this iterator is past-the-end (has run through
* all possible permutations).
*
* @return \c true if and only if this iterator is past-the-end.
*/
bool done() const;
};
/*@}*/
// Inline functions for NPermItS4
inline NPermItS4::NPermItS4() : permIndex(0) {
}
inline void NPermItS4::init() {
permIndex = 0;
}
inline void NPermItS4::operator ++ (int) {
permIndex++;
}
inline const NPerm4& NPermItS4::operator * () const {
return NPerm4::S4[permIndex];
}
inline bool NPermItS4::done() const {
return (permIndex >= 24);
}
} // namespace regina
#endif
|