main logo
Subject: Re: Re-sorting FBL_ArraySet?
Author: Arthur Clemens
Posted: 2003/11/30 17:19:00
 
View Entire Thread
New Search



On 30-nov-03, at 23:14, Ruslan Zasukhin wrote:

> on 12/1/03 12:08 AM, Arthur Clemens at aclemens .AT. xs4all .DOT nl wrote:
>
>>>> Is it possible to sort an already sorted ArraySet with a different
>>>> sort
>>>> order?
>>>
>>> Of course you can!
>>> This is just array of longs.
>>>
>>
>> In the header file I only find a Sort() method, and no way to pass
>> parameters such as ascending or sort field.
>>
>> if I do (VDK_BaseObject)
>> FBL_ArraySet* Sort( FBL_Set* inSet, VDK_Field& inSortField, bool
>> inAscending = true );
>> ... I get a *new* ArraySet.
>>
>> What other options do I have?
>
> Aha, so you want sort some selection of records in other way.

Yes.

>
> Then you must then send your sorted ArraySet into first parameter of
> Sort().
> And yes, Valentina will create new ArraySet as result.

OK.

>
> This is because Valentina internally use other complex structures for
> sorting, and to keep RAM usage minimal original array is destroyed
> after
> Valentina copy data into own structures.
>
> What troubles you?

I keep having problems assigning the newly created sorted ArraySet to
my member variable ArraySet.

VDK_Field *sortField = [self
databaseDefinition]->getSloveneWordTable()->GetField("text");
bool ascending = ([self sortDirection] == 0) ? false : true;
FBL_ArraySet* sortedSet = [self
databaseDefinition]->getSloveneWordTable()->Sort( [[self displaySet]
shownSet], *sortField, ascending);

So I feed the Sort function my old shownSet (ArraySet). No problems
here, in my test of 8 records I can see that sortedSet counts 8 records
- iterating the set I get perfectly sorted words.

Now I immediately pass sortedSet to my DisplaySet's shownSet with:

[[self displaySet] setShownSetToArraySet:sortedSet];

and in DisplaySet.mm:

- (void)setShownSetToArraySet:(FBL_ArraySet*)arraySet
if (mShownSet != nil) {
delete mShownSet;
}
//NSLog(@"arraySet = %d", arraySet->GetCount()); // Cannot: get
crash: "pure virtual function called"
mShownSet = new FBL_ArraySet(*arraySet);
NSLog( .AT. "mShownSet = %d", mShownSet->GetCount()); // I get zero
count here!!!!
}

So in passing the arraySet, I cannot call GetCount() on it, and the
newly created mShownSet has zero items!
I use the same way of passing the bitset of all found records to
mShownSet, and I have no problems there .DOT

I am very puzzled. Perhaps a keen eye can help me out.



Arthur












_______________________________________________
Valentina mailing list
Valentina@lists.macserve.net
http://lists.macserve.net/mailman/listinfo/valentina

 
©2003 Arthur Clemens
<-- Prior Message New Search Next Message -->