Re: [Vala] ArrayList sort function



In my opinion this sort method should be supported the array in the
same way as move() and resize() are supported and ArrayList should use
that implementation.

In this way you just sort an array like:

string[] abc = {"c", "a", "b"};
abc.sort(Glib.strcmp);

Should be easily added for someone who know itself around in Vala. I
tried (not really hard enough) and failed.

Regards,
Tomaž

2008/11/21 Daniel Lucraft <dan fluentradical com>:
I cleaned up the comparison functions a bit after playing with Vala
pointers and begging on IRC.

best
Dan
___________________________
Daniel Lucraft
http://www.daniellucraft.com/



2008/11/21 Daniel Lucraft <dan fluentradical com>:
As requested on IRC, here are two patches that add a sort method to ArrayList.

Some notes:
 1. I wasn't sure where to put the vapi binding to the C stdlib
function qsort. But I saw that
   glib.vapi had the reference to the strcmp function so I put it next to that.
 2. There are two comparison functions - intcmp and strcmp - that can
be used with the qsort function.
   Again I wasn't sure where to put them so I put them in ArrayList
next to where they would be used.
 3. I hope it is possible to have nicer comparison functions that
don't have two levels of
   indirection for objects (see the test), but I just couldn't make
them work. (I tried hard!)

thanks
Dan

___________________________
Daniel Lucraft
http://www.daniellucraft.com/


_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list





-- 
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-a...


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]