add constructors

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2227 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
boufaras 2011-05-12 14:01:31 +00:00
commit 61fe4bb4d4

View file

@ -35,7 +35,7 @@
#ifndef __moGPUPermutationVector_H_
#define __moGPUPermutationVector_H_
#include <GPUType/moGPUVector.h>
#include <GPUType/moGPUIntVector.h>
/**
* Implementation of Permutation vector representation on GPU.
@ -47,9 +47,27 @@ class moGPUPermutationVector: public moGPUIntVector<Fitness> {
public:
using moGPUVector<int, Fitness>::vect;
using moGPUVector<int, Fitness>::N;
using moGPUIntVector<Fitness>::vect;
using moGPUIntVector<Fitness>::N;
/**
* Default constructor.
*/
moGPUPermutationVector() :
moGPUIntVector<Fitness> () {
}
/**
*Constructor.
*@param _neighborhoodSize The neighborhood size.
*/
moGPUPermutationVector(unsigned _neighborhoodSize) :
moGPUIntVector<Fitness> (_neighborhoodSize) {
create();
}
/**
*Initializer of random permuatation vector.
*/
@ -68,6 +86,29 @@ public:
}
}
/**
*Function inline to set the size of vector, called from host.
*@param _size the vector size
*/
void setSize(unsigned _size) {
if (_size < N) {
moGPUPermutationVector<Fitness> tmp_vect(_size);
for (unsigned i = 0; i < tmp_vect.N; i++)
tmp_vect.vect[i] = vect[i];
(tmp_vect).invalidate();
(*this) = tmp_vect;
} else if (_size > N) {
moGPUPermutationVector<Fitness> tmp_vect(_size);
for (unsigned i = 0; i < N; i++)
tmp_vect.vect[i] = vect[i];
(tmp_vect).invalidate();
(*this) = tmp_vect;
}
}
};
#endif