Auxiliary class to convert pair of indices to unique index and back.
More...
#include <JCombinatorics.hh>
Auxiliary class to convert pair of indices to unique index and back.
Definition at line 22 of file JCombinatorics.hh.
JTOOLS::JCombinatorics::JCombinatorics |
( |
| ) |
|
|
inline |
JTOOLS::JCombinatorics::JCombinatorics |
( |
const int |
numberOfIndices | ) |
|
|
inline |
Constructor.
- Parameters
-
numberOfIndices | number of indices |
Definition at line 43 of file JCombinatorics.hh.
void JTOOLS::JCombinatorics::configure |
( |
const int |
numberOfIndices | ) |
|
|
inline |
Configure.
- Parameters
-
numberOfIndices | number of indices |
Definition at line 54 of file JCombinatorics.hh.
58 zbuf2D.resize(numberOfIndices);
60 for (
int i = 0; i != numberOfIndices; ++i) {
61 zbuf2D[i].resize(numberOfIndices);
64 for (
int i = 0; i != numberOfIndices; ++i) {
68 for (
int j = i; ++j != numberOfIndices; ) {
unsigned int JTOOLS::JCombinatorics::getNumberOfIndices |
( |
| ) |
const |
|
inline |
Get number of indices.
- Returns
- number of indices
Definition at line 84 of file JCombinatorics.hh.
unsigned int JTOOLS::JCombinatorics::getNumberOfPairs |
( |
| ) |
const |
|
inline |
int JTOOLS::JCombinatorics::getIndex |
( |
const int |
first, |
|
|
const int |
second |
|
) |
| const |
|
inline |
Get index of pair of indices.
- Parameters
-
first | first address |
second | second address |
- Returns
- index (-1 if first and second address are equal)
Definition at line 108 of file JCombinatorics.hh.
110 return zbuf2D[first][second];
const pair_type& JTOOLS::JCombinatorics::getPair |
( |
const int |
index | ) |
const |
|
inline |
Get pair of indices for given index.
- Parameters
-
- Returns
- pair of indices
Definition at line 120 of file JCombinatorics.hh.
template<class JComparator_t >
void JTOOLS::JCombinatorics::sort |
( |
JComparator_t |
comparator | ) |
|
|
inline |
Sort address pairs.
- Parameters
-
comparator | comparator for pairs |
Definition at line 132 of file JCombinatorics.hh.
134 std::stable_sort(
zbuf1D.begin(),
zbuf1D.end(), comparator);
136 for (
int i = 0; i != (int)
zbuf1D.size(); ++i) {
140 zbuf2D[pair.first][pair.second] = i;
141 zbuf2D[pair.second][pair.first] = i;
144 for (
int i = 0; i != (int)
zbuf2D.size(); ++i) {
static int JTOOLS::JCombinatorics::getSign |
( |
const int |
first, |
|
|
const int |
second |
|
) |
| |
|
inlinestatic |
Sign of pair of indices.
- Parameters
-
first | first address |
second | second address |
- Returns
- +1 if second >= first; else -1
Definition at line 157 of file JCombinatorics.hh.
159 return (second >= first ? +1 : -1);
static int JTOOLS::JCombinatorics::getSign |
( |
const pair_type & |
pair | ) |
|
|
inlinestatic |
Sign of pair of indices.
- Parameters
-
- Returns
- +1 if second >= first; else -1
Definition at line 169 of file JCombinatorics.hh.
171 return getSign(pair.first, pair.second);
The documentation for this class was generated from the following file: