NeoPZ
tpzpermutation.h
Go to the documentation of this file.
1 
5 #ifndef TPZPERMUTATION_H
6 #define TPZPERMUTATION_H
7 
8 #include "pzmanvector.h"
9 #include "TPZSavable.h"
10 class TPZStream;
11 
17 class TPZPermutation : public TPZSavable {
18 public:
20  TPZPermutation(int n);
22  TPZPermutation(const TPZPermutation &copy);
25 
28 
30  void Permute(const TPZVec<int> &in, TPZVec<int> &out) const;
31  void Permute(const TPZVec<int64_t> &in, TPZVec<int64_t> &out) const;
32 
34  void operator++();
35 
36  void operator++(int) { operator++();}
37 
38  bool IsFirst();
39  int ClassId() const override;
40  void Read(TPZStream &buf, void *context) override;
41  void Write(TPZStream &buf, int withclassid) const override;
42 
45  {
46  return fCounter;
47  }
48 
50  {
51  return fOrder;
52  }
53 
54 protected:
55 
58 
61 };
62 
64 inline std::ostream &operator<<(std::ostream &out, TPZPermutation &obj)
65 {
66  out << "imprimindo TPZPermutation::fCounter\n";
67  for(int i = 0; i < obj.Counter().NElements(); i++)
68  {
69  out << obj.Counter()[i] << std::endl;
70  }
71  out << "\n\n";
72 
73  out << "imprimindo TPZPermutation::fOrder\n";
74  for(int i = 0; i < obj.Order().NElements(); i++)
75  {
76  out << obj.Order()[i] << std::endl;
77  }
78  out << "\n\n";
79 
80  return out;
81 }
82 
83 #endif
void Permute(const TPZVec< int > &in, TPZVec< int > &out) const
Applies the current permutation on the vector in and produces the vector out.
Contains declaration of the TPZSavable class which defines the interface to save and restore objects ...
void Read(TPZStream &buf, void *context) override
read objects from the stream
TPZManVector< int > fOrder
Variable which contains the current permutations.
TPZManVector< int > Order()
TPZPermutation(int n)
Constructor with number of permutations.
std::ostream & operator<<(std::ostream &out, TPZPermutation &obj)
Overloading operator << to print permutation object at ostream out.
Free store vector implementation.
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
TPZManVector< int > Counter()
Returns the counter of the permutations.
TPZManVector< int > fCounter
Variable which represents a counter for the permutations.
void operator++()
Operator increment.
TPZPermutation & operator=(const TPZPermutation &copy)
Operator attribution.
~TPZPermutation()
Default destructor.
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
int ClassId() const override
Define the class id associated with the class.
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
Definition: TPZSavable.h:67
void operator++(int)
This class generates all permutations of n values. Utility.
obj
Definition: test.py:225