Re: [Vala] removing an element from a list

2009-09-01 Thread Jiří Zárevúcky

On 09/01/2009 08:51 AM, Didier Ptitjes wrote:

Jiří Zárevúcky wrote:
   

If the dependency concerns you, you can simply copy the class you use
into your application. :) Vala compiler itself includes a copy of the
whole library.
 

Jiří, please, remember that Valac includes that code for bootstrap
reasons! Libgee is written in Vala. Vala compiler depends on libgee.
Libgee's code is only copied inside the Vala compiler code in order to
simplify the bootstrap process for packagers and distro maintainers.

Copying code inside your application would just give you some more
maintainance work to keep that in sync with the library. (Not to mention
the plethora of reasons that made us use libraries...)

Best regards, Didier.

   


Actually, if you just need a single class and never expect to need 
anything else, you may just as well copy it and save yourself a lot of 
trouble.

I agree that Vala's inclusion of Gee was not a good example here.

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


Re: [Vala] removing an element from a list

2009-08-31 Thread jezra lickter
On Mon, 31 Aug 2009 03:07:57 +0200
Jiří Zárevúcky zarevucky.j...@gmail.com wrote:

 On 08/31/2009 03:05 AM, Jiří Zárevúcky wrote:
  On 08/31/2009 02:10 AM, jezra lickter wrote:
  The word test is not removed from the list. Am I doing something
  wrong, and is there a better way to do what I need?
 
 
  The problem is that GLib.List searches for items based on pointer 
  value, not the actual data. You have to either use remove_custom or
  (a much better possibility) use the Gee collection library. It is
  much easier to use from Vala then GLib collection classes, which
  were never intended for use in such high-level language.
 
 
 I meant find_custom()  :) Anyway, Gee is the way to go.
 ___
 Vala-list mailing list
 Vala-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/vala-list

Thanks, the Gee library worked like a charm although I would prefer to
not require another library for the application. If anyone is
interested, the updated code that uses Gee is 

using Gee;
public static void main(string[] args)
{
ArrayListstring? al= new ArrayListstring(str_equal);
al.add(this);
al.add(is);
al.add(a);
al.add(test);
//remove the test
al.remove(test);
foreach(string word in al)
{
stdout.printf(%s , word );
}
stdout.printf(\n);
}
___
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] removing an element from a list

2009-08-31 Thread Jiří Zárevúcky

On 08/31/2009 10:59 PM, jezra lickter wrote:

On Mon, 31 Aug 2009 03:07:57 +0200
Jiří Zárevúckyzarevucky.j...@gmail.com  wrote:

   

On 08/31/2009 03:05 AM, Jiří Zárevúcky wrote:
 

On 08/31/2009 02:10 AM, jezra lickter wrote:
   

The word test is not removed from the list. Am I doing something
wrong, and is there a better way to do what I need?

 

The problem is that GLib.List searches for items based on pointer
value, not the actual data. You have to either use remove_custom or
(a much better possibility) use the Gee collection library. It is
much easier to use from Vala then GLib collection classes, which
were never intended for use in such high-level language.

   

I meant find_custom()  :) Anyway, Gee is the way to go.
___
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list
 

Thanks, the Gee library worked like a charm although I would prefer to
not require another library for the application.
   


If the dependency concerns you, you can simply copy the class you use 
into your application. :) Vala compiler itself includes a copy of the 
whole library.

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


[Vala] removing an element from a list

2009-08-30 Thread jezra lickter
Hello,
For an application that I am working on, I need to keep a collection of
strings and possibly remove a string from the collection. A list seems
to be a good way to manage the strings but when I try to remove() or
remove_all(), the list doesn't change. for example:

public static void main(string[] args)
{
Liststring list = new Liststring();
list.append(this);
list.append(is);
list.append(a);
list.append(test);
//remove test
list.remove_all(test);

foreach(string word in list)
{
stdout.printf(%s , word );
}
stdout.printf(\n);
}

The word test is not removed from the list. Am I doing something
wrong, and is there a better way to do what I need?

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