G
Guest
Hello,
I´ve a general question about the visibility and modification of an object.
I will try to explain it in my code, where I have the problem:
DocumentList dList = initDocuments(thesaurus);
for (int i = 0; i < testRuns_; i++)
{
Algo algo = new Algo(dList, 1.1, anzahlCluster, thesaurus, initType_);
run = algo.run(maxIter, epsilon);
tests.add(i, run);
}
In my DocumentList dList I have a List of objects which I create with
initDocuments().
In the for-loop I am removing some objects (documents) out of the
DocumentList with my method algo.run.
Let´s say my DocumentList has a size of 100 _before_ entering the loop.
If I call algo.run, I am removing 4 Documents out of my DocumentList.
So I have 96 Documents in my list.
But I thought, that I am removing these documents _only_ in my object
"Algo" and not in my object dList which I have created _before_ entering
the for-loop.
In other words:
I want to have 100 Documents in my DocumentList.
Then I am doing the first loop iteration, removing 4 but when I am doing
my second iteration, I want to have 100 Documents again and not 96.
But that is exactly what happens.
If I run my loop a second time, I only have 96 Documents and not 100
Documents.
Well.. I hope I explained it right and somebody understands my problem.
My general question is about visibility and modifications of objects.
How can I reach that my object "algo" does not change my object "dList"?
In other words... the object "algo" should work with it´s own copy of
the object dList.
Regards,
Martin
I´ve a general question about the visibility and modification of an object.
I will try to explain it in my code, where I have the problem:
DocumentList dList = initDocuments(thesaurus);
for (int i = 0; i < testRuns_; i++)
{
Algo algo = new Algo(dList, 1.1, anzahlCluster, thesaurus, initType_);
run = algo.run(maxIter, epsilon);
tests.add(i, run);
}
In my DocumentList dList I have a List of objects which I create with
initDocuments().
In the for-loop I am removing some objects (documents) out of the
DocumentList with my method algo.run.
Let´s say my DocumentList has a size of 100 _before_ entering the loop.
If I call algo.run, I am removing 4 Documents out of my DocumentList.
So I have 96 Documents in my list.
But I thought, that I am removing these documents _only_ in my object
"Algo" and not in my object dList which I have created _before_ entering
the for-loop.
In other words:
I want to have 100 Documents in my DocumentList.
Then I am doing the first loop iteration, removing 4 but when I am doing
my second iteration, I want to have 100 Documents again and not 96.
But that is exactly what happens.
If I run my loop a second time, I only have 96 Documents and not 100
Documents.
Well.. I hope I explained it right and somebody understands my problem.
My general question is about visibility and modifications of objects.
How can I reach that my object "algo" does not change my object "dList"?
In other words... the object "algo" should work with it´s own copy of
the object dList.
Regards,
Martin