Hello all, i have problems with storing skip lists in a global array. Here is my pseudo code
Arry aryGLB = create(1,1)
void StoreAndSumup(Array& aryGLB, int iX, int iY, Skip& slFil) {
Skip slAry = createSTring()
Skip slRESULT = createString()
slAry = (Skip get(aryGLB, iX, iY)
if (null slAry) {
put(aryGLB, slFil, iX, iY)
}
else {
for iDATA_Fil in slFil do {
iDATA_ARY_Skip = 0
sKEY_slFil = (string key (slFil))
if(find(slARY, sKEY_slFil, iDATA_ARY_Skip)) {
int iSum = iDATA_ARY_Skip + iDATA_Fil
put(slRESULT, sKEY_slFil, iSum)
} else {
put(slRESULT, sKEY_slFil, iDATA_Fil)
}
} // end for
put(aryGLB, slRESULT, iX, iY)
}
}
void FilterFunc(Array& aryGLB, int iX, int iY, Filter f, Module m) {
Skip slFil = createString()
int iACC = 0, iREJ = 0
for value in enumeration do {
set(m, fil & value, iACC, iREJ)
put(slFil, value"", iACC)
}
StoreAndSumup(aryGLB, iX, iY, slFil)
}
// -----
for m in project do {
int iX = 0
FilterFunc(aryGLB, iX, 1, "somefilter", m)
iX++
}
After some debug sessions I found out that Doors doesn't want to store my initial Skip.
...
slAry = (Skip get(aryGLB, iX, iY)
if (null slAry) {
==> put(aryGLB, slFil, iX, iY)
}
...
Well it stores something but not my skip and therefore it crashes when the second module is processed. For the second module the readout from the array is not null so it enters the else path but then I crashes while trying to iterate the skips. What did I wrong or what do I have to do to make it running?
Thanks a lot Chris leporello - Thu Sep 22 05:16:51 EDT 2016 |
Re: How to store Skiplists in an Array Hey, the issue is that you put a reference to a Skip (Skip&) and not a Skip, change your void StoreAndSumup(Array& aryGLB, int iX, int iY, Skip& slFil) to void StoreAndSumup(Array& aryGLB, int iX, int iY, Skip slFil) and it should work |
Re: How to store Skiplists in an Array Hi,
I tried that before and it did not work too. But checking my code once again I realized that after returning into func "FilterFunc" I deleted the skip slFil. That caused the error.
So if I'm understanding right i would say that in case of sending a reference to "StoreAndSumup" it has to crash because I delete the source adr afterwards. But why does it only work when I send a copy?
Thank you and regards Chris |
Re: How to store Skiplists in an Array leporello - Thu Sep 22 08:29:19 EDT 2016 Hi,
I tried that before and it did not work too. But checking my code once again I realized that after returning into func "FilterFunc" I deleted the skip slFil. That caused the error.
So if I'm understanding right i would say that in case of sending a reference to "StoreAndSumup" it has to crash because I delete the source adr afterwards. But why does it only work when I send a copy?
Thank you and regards Chris It does not work when you put a reference in, and get a normal variable (non reference out).
int ref = 10;
Skip sk = create();
void add (int key, int &a) {
put (sk, key, a) // put a reference in
}
int val = 123
add(10, val) // puts reference in
find(sk, 10, val) // get reference out and put it to the non reference variable
Also notice that you will not create a copy of anything - Arrays, Buffers, Skips etc. are only "handles" to some other data structure. Passing them by value will not copy and data, just the "handle". If you pass a skip to a function and modify it from the function, you will modify the original one, the same thing is true for anything else, than a basic DXL types (int, string, char, etc.). Regards, Mathias |
Re: How to store Skiplists in an Array Thanks for clarification!
Regards Chris |