Commit 6cfc352f authored by berenger-bramas's avatar berenger-bramas

Rename list & vector methods

(step1/2)

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@101 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 148bdf5c
......@@ -27,7 +27,7 @@ public:
* @param particle the new particle
*/
void push(const ParticleClass& particle){
this->particles.pushFront(particle);
this->particles.push(particle);
}
/**
......
......@@ -76,7 +76,7 @@ public:
typename FList<ParticleClass>::BasicIterator iter(*particles);
while( iter.isValide() ){
iter.value().setDataDown(iter.value().getDataDown() + local->getDataDown());
iter.progress();
iter.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -97,7 +97,7 @@ public:
typename FList<ParticleClass>::BasicIterator iter(*targets);
while( iter.isValide() ){
iter.value().setDataDown(iter.value().getDataDown() + inc);
iter.progress();
iter.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -120,7 +120,7 @@ public:
typename FList<ParticleClass>::BasicIterator iter(*targets);
while( iter.isValide() ){
iter.value().setDataDown(iter.value().getDataDown() + inc);
iter.progress();
iter.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -185,7 +185,7 @@ void ValidateFMMAlgo(FOctree<ParticleClass, CellClass, LeafClass, TreeHeight , S
(isUsingTsm && iter.value().getDataDown() != NbPart) ){
std::cout << "Problem L2P + P2P : " << iter.value().getDataDown() << "\n";
}
iter.progress();
iter.gotoNext();
}
} while(octreeIterator.moveRight());
}
......
......@@ -29,8 +29,8 @@ public:
* @param particle the new particle
*/
void push(const ParticleClass& particle){
if(particle.isTarget()) this->targets.pushFront(particle);
else if(particle.isSource()) this->sources.pushFront(particle);
if(particle.isTarget()) this->targets.push(particle);
else if(particle.isSource()) this->sources.push(particle);
else assert(false, "Error particle has undefined type.", __LINE__, __FILE__);
}
......
......@@ -95,10 +95,10 @@ public:
}
/**
* Push an element in the front of the list
* Push an element in the head of the list
* @param inObject the object to insert
*/
void pushFront(const Object& inObject){
void push(const Object& inObject){
Node* newNode = new Node;
newNode->target = inObject;
newNode->next = this->root;
......@@ -109,35 +109,35 @@ public:
/**
* To get front value (last pushed value)
* To get head value (last pushed value)
* if size == 0 then defaultValue is returned
* the list is unchanged after this function
* @param defaultValue as the returned value in case size == 0, equal Object() if no param as passed
* @return first value if exists or defaultValue otherwise
*/
Object& front(Object& defaultValue = Object()){
Object& head(Object& defaultValue = Object()){
if(this->size) return this->root->target;
else return defaultValue;
}
/**
* To get front value as const
* To get head value as const
* if size == 0 then defaultValue is return
* the list is unchanged after this function
* @param defaultValue as the returned value in case size == 0, equal Object() if no param as passed
* @return first value if exists or defaultValue otherwise
*/
const Object& front(const Object& defaultValue = Object()) const {
const Object& head(const Object& defaultValue = Object()) const {
if(this->size) return this->root->target;
else return defaultValue;
}
/**
* To get the front value and remove it from the list
* To get the head value and remove it from the list
* @return first value
* @warning you must check the list's size before calling this function!
*/
Object popFront(){
Object pop(){
--this->size;
Node* newNode = this->root;
this->root = this->root->next;
......@@ -166,7 +166,7 @@ public:
* FList<int>::BasicIterator iter(values); <br>
* while( iter.isValide() ){ <br>
* iter.value() += 1; <br>
* iter.progress(); <br>
* iter.gotoNext(); <br>
* } <br>
* </code>
*/
......@@ -182,8 +182,8 @@ public:
BasicIterator(FList& list) : iter(list.root){
}
/** To progress on the list */
void progress(){
/** To gotoNext on the list */
void gotoNext(){
if(this->iter) this->iter = this->iter->next;
}
......@@ -205,7 +205,7 @@ public:
/**
* To know if an iterator is at the end of the list
* @return true if the current iterator can progress and access to value, else false
* @return true if the current iterator can gotoNext and access to value, else false
*/
bool isValide() const{
return iter;
......@@ -223,7 +223,7 @@ public:
* FList<int>::ConstBasicIterator iter(values); <br>
* while( iter.isValide() ){ <br>
* iter.value() += 1; <br>
* iter.progress(); <br>
* iter.gotoNext(); <br>
* } <br>
* </code>
*/
......@@ -239,8 +239,8 @@ public:
ConstBasicIterator(const FList& list) : iter(list.root){
}
/** to progress on the list */
void progress(){
/** to gotoNext on the list */
void gotoNext(){
if(this->iter) this->iter = this->iter->next;
}
......@@ -262,7 +262,7 @@ public:
/**
* To know if an iterator is at the end of the list
* @return true if the current iterator can progress and access to value, else false
* @return true if the current iterator can gotoNext and access to value, else false
*/
bool isValide() const{
return iter;
......
......@@ -304,7 +304,7 @@ public:
* After that point we do not know where we are but we know that there is some data
* on the right (without knowing our position!)
*
* We progress on the brother to find an allocated cell (->)
* We gotoNext on the brother to find an allocated cell (->)
* for example if we are on index 2 we will look until 8 = 2 | 7 + 1
* if we arrive a 8 without finding a cell we go upper and do the same
* we know we will find something because we are not at the right limit
......
......@@ -112,7 +112,7 @@ public:
*@brief last data
*@return end->data
*/
const T& front() const {
const T& head() const {
return this->array[this->index - 1];
}
......@@ -120,7 +120,7 @@ public:
*@brief last data
*@return end->data
*/
T& front() {
T& head() {
return this->array[this->index - 1];
}
......@@ -145,15 +145,15 @@ public:
/**
*@brief pop the first node
*/
void popFront(){
void pop(){
(&this->array[--this->index])->~T();
}
/**
*@brief push a new node in front
*@brief push a new node in head
*@param inValue the new value
*/
void pushFront( const T & inValue ){
void push( const T & inValue ){
if( this->index == this->capacity ){
setCapacity(this->capacity * 1.5);
}
......@@ -174,7 +174,7 @@ public:
BasicIterator(FVector<T>& inVector) : vector(&inVector), index(0){}
void progress(){
void gotoNext(){
++this->index;
}
......@@ -205,7 +205,7 @@ public:
ConstBasicIterator(const FVector<T>& inVector) : vector(&inVector), index(0){}
void progress(){
void gotoNext(){
++this->index;
}
......
......@@ -666,7 +666,7 @@ public:
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
for(typename FList<ParticleClass>::ConstBasicIterator iterParticle(*inParticles);
iterParticle.isValide() ; iterParticle.progress()){
iterParticle.isValide() ; iterParticle.gotoNext()){
//std::cout << "Working on part " << iterParticle.value()->getPhysicalValue() << "\n";
......@@ -1283,7 +1283,7 @@ public:
iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());*/
//printf("p_potential = %lf\n", potential);
iterTarget.progress();
iterTarget.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -1344,26 +1344,26 @@ public:
while( iterSource.isValide() ){
DIRECT_COMPUTATION_MUTUAL_SOFT(iterTarget.value(),
iterSource.value());
iterSource.progress();
iterSource.gotoNext();
}
}
}
typename FList<ParticleClass>::BasicIterator iterSameBox = iterTarget;//(*targets);
iterSameBox.progress();
iterSameBox.gotoNext();
while( iterSameBox.isValide() ){
if(&iterSameBox.value() < &iterTarget.value()){
DIRECT_COMPUTATION_MUTUAL_SOFT(iterTarget.value(),
iterSameBox.value());
}
iterSameBox.progress();
iterSameBox.gotoNext();
}
//printf("x = %e \t y = %e \t z = %e \n",iterTarget.value()->getPosition().getX(),iterTarget.value()->getPosition().getY(),iterTarget.value()->getPosition().getZ());
//printf("\t P2P fx = %e \t fy = %e \t fz = %e \n",iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());
//printf("\t potential = %e \n",iterTarget.value()->getPotential());
iterTarget.progress();
iterTarget.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -1420,7 +1420,7 @@ public:
while( iterSource.isValide() ){
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(iterTarget.value(),
iterSource.value());
iterSource.progress();
iterSource.gotoNext();
}
}
......@@ -1430,14 +1430,14 @@ public:
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(iterTarget.value(),
iterSameBox.value());
}
iterSameBox.progress();
iterSameBox.gotoNext();
}
//printf("x = %e \t y = %e \t z = %e \n",iterTarget.value()->getPosition().getX(),iterTarget.value()->getPosition().getY(),iterTarget.value()->getPosition().getZ());
//printf("\t P2P fx = %e \t fy = %e \t fz = %e \n",iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());
//printf("\t potential = %e \n",iterTarget.value()->getPotential());
iterTarget.progress();
iterTarget.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......
......@@ -677,7 +677,7 @@ public:
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
for(typename FList<ParticleClass>::ConstBasicIterator iterParticle(*inParticles);
iterParticle.isValide() ; iterParticle.progress()){
iterParticle.isValide() ; iterParticle.gotoNext()){
//std::cout << "Working on part " << iterParticle.value()->getPhysicalValue() << "\n";
......@@ -1333,7 +1333,7 @@ public:
iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());*/
//printf("p_potential = %lf\n", potential);
iterTarget.progress();
iterTarget.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -1395,26 +1395,26 @@ public:
while( iterSource.isValide() ){
DIRECT_COMPUTATION_MUTUAL_SOFT(iterTarget.value(),
iterSource.value());
iterSource.progress();
iterSource.gotoNext();
}
}
}
typename FList<ParticleClass>::BasicIterator iterSameBox = iterTarget;//(*targets);
iterSameBox.progress();
iterSameBox.gotoNext();
while( iterSameBox.isValide() ){
if(&iterSameBox.value() < &iterTarget.value()){
DIRECT_COMPUTATION_MUTUAL_SOFT(iterTarget.value(),
iterSameBox.value());
}
iterSameBox.progress();
iterSameBox.gotoNext();
}
//printf("x = %e \t y = %e \t z = %e \n",iterTarget.value()->getPosition().getX(),iterTarget.value()->getPosition().getY(),iterTarget.value()->getPosition().getZ());
//printf("\t P2P fx = %e \t fy = %e \t fz = %e \n",iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());
//printf("\t potential = %e \n",iterTarget.value()->getPotential());
iterTarget.progress();
iterTarget.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -1471,7 +1471,7 @@ public:
while( iterSource.isValide() ){
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(iterTarget.value(),
iterSource.value());
iterSource.progress();
iterSource.gotoNext();
}
}
......@@ -1481,14 +1481,14 @@ public:
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(iterTarget.value(),
iterSameBox.value());
}
iterSameBox.progress();
iterSameBox.gotoNext();
}
//printf("x = %e \t y = %e \t z = %e \n",iterTarget.value()->getPosition().getX(),iterTarget.value()->getPosition().getY(),iterTarget.value()->getPosition().getZ());
//printf("\t P2P fx = %e \t fy = %e \t fz = %e \n",iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());
//printf("\t potential = %e \n",iterTarget.value()->getPotential());
iterTarget.progress();
iterTarget.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......
......@@ -854,7 +854,7 @@ public:
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
for(typename FList<ParticleClass>::ConstBasicIterator iterParticle(*inParticles);
iterParticle.isValide() ; iterParticle.progress()){
iterParticle.isValide() ; iterParticle.gotoNext()){
//std::cout << "Working on part " << iterParticle.value()->getPhysicalValue() << "\n";
......@@ -1587,7 +1587,7 @@ public:
iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());*/
//printf("p_potential = %lf\n", potential);
iterTarget.progress();
iterTarget.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -1648,26 +1648,26 @@ public:
while( iterSource.isValide() ){
DIRECT_COMPUTATION_MUTUAL_SOFT(iterTarget.value(),
iterSource.value());
iterSource.progress();
iterSource.gotoNext();
}
}
}
typename FList<ParticleClass>::BasicIterator iterSameBox = iterTarget;//(*targets);
iterSameBox.progress();
iterSameBox.gotoNext();
while( iterSameBox.isValide() ){
if(&iterSameBox.value() < &iterTarget.value()){
DIRECT_COMPUTATION_MUTUAL_SOFT(iterTarget.value(),
iterSameBox.value());
}
iterSameBox.progress();
iterSameBox.gotoNext();
}
//printf("x = %e \t y = %e \t z = %e \n",iterTarget.value()->getPosition().getX(),iterTarget.value()->getPosition().getY(),iterTarget.value()->getPosition().getZ());
//printf("\t P2P fx = %e \t fy = %e \t fz = %e \n",iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());
//printf("\t potential = %e \n",iterTarget.value()->getPotential());
iterTarget.progress();
iterTarget.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -1724,7 +1724,7 @@ public:
while( iterSource.isValide() ){
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(iterTarget.value(),
iterSource.value());
iterSource.progress();
iterSource.gotoNext();
}
}
......@@ -1734,14 +1734,14 @@ public:
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(iterTarget.value(),
iterSameBox.value());
}
iterSameBox.progress();
iterSameBox.gotoNext();
}
//printf("x = %e \t y = %e \t z = %e \n",iterTarget.value()->getPosition().getX(),iterTarget.value()->getPosition().getY(),iterTarget.value()->getPosition().getZ());
//printf("\t P2P fx = %e \t fy = %e \t fz = %e \n",iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());
//printf("\t potential = %e \n",iterTarget.value()->getPotential());
iterTarget.progress();
iterTarget.gotoNext();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......
......@@ -132,7 +132,7 @@ int main(int argc, char ** argv){
//printf("\t\t Sum Forces ( %e , %e , %e)\n",
//forces.getX(),forces.getY(),forces.getZ());
iter.progress();
iter.gotoNext();
}
} while(octreeIterator.moveRight());
......
......@@ -235,8 +235,8 @@ void ValidateFMMAlgoProc(FOctree<ParticleClass, CellClass, LeafClass, OctreeHeig
<< " y " << iterValide.value().getForces().getY() << " " << iter.value().getForces().getY()
<< " z " << iterValide.value().getForces().getZ() << " " << iter.value().getForces().getZ() << "\n";
}
iter.progress();
iterValide.progress();
iter.gotoNext();
iterValide.gotoNext();
}
octreeIterator.moveRight();
......@@ -365,9 +365,9 @@ int main(int argc, char ** argv){
#ifdef VALIDATE_FMM
potentialValide += iterValide.value().getPotential() * iterValide.value().getPhysicalValue();
forcesValide += iterValide.value().getForces();
iterValide.progress();
iterValide.gotoNext();
#endif
iter.progress();
iter.gotoNext();
}
octreeIterator.moveRight();
......
......@@ -136,7 +136,7 @@ int main(int argc, char ** argv){
//printf("\t\t Sum Forces ( %e , %e , %e)\n",
//forces.getX(),forces.getY(),forces.getZ());
iter.progress();
iter.gotoNext();
}
} while(octreeIterator.moveRight());
......
......@@ -133,7 +133,7 @@ int main(int argc, char ** argv){
//printf("\t\t Sum Forces ( %e , %e , %e)\n",
//forces.getX(),forces.getY(),forces.getZ());
iter.progress();
iter.gotoNext();
}
} while(octreeIterator.moveRight());
......
......@@ -185,7 +185,7 @@ void ValidateFMMAlgoProc(FOctree<ParticleClass, CellClass, LeafClass, OctreeHeig
(isUsingTsm && iter.value().getDataDown() != NbPart) ){
std::cout << "Problem L2P + P2P, value on particle is : " << iter.value().getDataDown() << "\n";
}
iter.progress();
iter.gotoNext();
}
octreeIterator.moveRight();
}
......
......@@ -128,7 +128,7 @@ int main(int argc, char ** argv){
printf("\tx = %e y = %e z = %e data = %c\n",iter.value().getPosition().getX(),iter.value().getPosition().getY(),iter.value().getPosition().getZ(),iter.value().getData());
iter.progress();
iter.gotoNext();
}
} while(octreeIterator.moveRight());
......
......@@ -42,9 +42,9 @@ class TestList : public FUTester<TestList> {
// test size
void TestSize(){
FList<TestObject> list;
list.pushFront(TestObject());
list.pushFront(TestObject());
list.pushFront(TestObject());
list.push(TestObject());
list.push(TestObject());
list.push(TestObject());
assert(list.getSize() == 3);
assert((TestObject::counter - TestObject::dealloced) == list.getSize());
......@@ -58,9 +58,9 @@ class TestList : public FUTester<TestList> {
// test copy
void TestCopy(){
FList<TestObject> list;
list.pushFront(TestObject());
list.pushFront(TestObject());
list.pushFront(TestObject());
list.push(TestObject());
list.push(TestObject());
list.push(TestObject());
FList<TestObject> list2 = list;
assert(list.getSize() == list2.getSize());
......@@ -76,15 +76,15 @@ class TestList : public FUTester<TestList> {
assert(!iter.isValide());
}
{
list.pushFront(TestObject());
list.pushFront(TestObject());
list.pushFront(TestObject());
list.push(TestObject());
list.push(TestObject());
list.push(TestObject());
FList<TestObject>::BasicIterator iter(list);
assert(iter.isValide());
int counter = 0;
while(iter.isValide()){ iter.progress(); ++counter; }
while(iter.isValide()){ iter.gotoNext(); ++counter; }
assert(!iter.isValide());
assert(counter == list.getSize());
}
......
......@@ -41,9 +41,9 @@ class TestVector : public FUTester<TestVector> {
// test size
void TestSize(){
FVector<TestObject> vector;
vector.pushFront(TestObject());
vector.pushFront(TestObject());
vector.pushFront(TestObject());
vector.push(TestObject());
vector.push(TestObject());
vector.push(TestObject());
assert(vector.getSize() == 3);
assert((TestObject::counter - TestObject::dealloced) == vector.getSize());
......@@ -57,9 +57,9 @@ class TestVector : public FUTester<TestVector> {
// test copy
void TestCopy(){
FVector<TestObject> vector;
vector.pushFront(TestObject());
vector.pushFront(TestObject());
vector.pushFront(TestObject());
vector.push(TestObject());
vector.push(TestObject());
vector.push(TestObject());
{
FVector<TestObject> vector2(vector);
......@@ -82,15 +82,15 @@ class TestVector : public FUTester<TestVector> {
assert(!iter.isValide());
}
{
vector.pushFront(TestObject());
vector.pushFront(TestObject());
vector.pushFront(TestObject());
vector.push(TestObject());
vector.push(TestObject());
vector.push(TestObject());
FVector<TestObject>::BasicIterator iter(vector);
assert(iter.isValide());
int counter = 0;
while(iter.isValide()){ iter.progress(); ++counter; }
while(iter.isValide()){ iter.gotoNext(); ++counter; }
assert(!iter.isValide());
assert(counter == vector.getSize());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment