Could you please keep all the discussion in a single thread?

On Fri, 29 May 2009 11:17:30 +0200
Joss 4 <gp...@abraerp.it> wrote:

> Hi Yu
> 
> I forget to say that I had problem with List object.  I mean. I confused 
> List with ArrayList even though I seen that ArrayList inherit from List.
> I need a container where save all the lines of a file and than order it 
> in alphabetical order.
> 
> so I created a test code like this :
> 
> List<string>  list  = new List<string>();
> 
> list.Append("uno");
> list.Append("due");
> list.Append("tre");
> list.Append("quattro");

Vala method names are usually lower case.

> list.Sort(Gtk.strcmp);

The same goes for List.sort(). strcmp is not in the Gtk namespace.

> with this code :
> 1. I wrong defining List in place of ArrayList, but :
> 2- This code doesn't compile at line   *List.Sort(Gtk.strcmp); *I don't 
> know why.
> 3. I read that to use ArrayList I must have Libgee-1.0 installed  and 
> have to define using Gee; directive.
> 4. I don't have Libgee-1.0 installed in windows env. nor I am able to 
> compile from  libgee-0.1.5.tar.gz package with Mingw.

Can't help you on this one, sorry.

> What could you suggest me either how to use List.Sort .... How to get 
> libgee-0.1.5 dll installed.

The following code works fine for me:

    using GLib;

    public class ListTest : GLib.Object {

        public static int main (string[] args) {

            List<string> list = new List<string> (); 

            list.append ("uno");
            list.append ("due");
            list.append ("tre");

            list.sort (strcmp);

            foreach (string item in list) {
                debug (item);
            }   

            return 0;
        }   
    }

Be aware, however, that it's been a while since I last coded in Vala.

-- 
Andrea Bolognani <e...@kiyuko.org>
Resistance is futile, you will be garbage collected.

Attachment: pgpBJIzD3vqkG.pgp
Description: PGP signature

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

Reply via email to