Re: Upcoming GLib changes




> As to GStack's existence, it can be made a good wrapper.  GStack
> implementation is small and makes the code cleaner and more readable.
> ie. you need not determine from program behavior that a GSList is being
> used as a stack (because such usage is often not commented or obviously
> used as such).  Stuff like this saves code analysis time when you are
> reading lots of code.

I agree with this. I think:

 g_stack_push()
 g_stack_pop()
 g_stack_empty()
 g_stack_peek()

is much better than:

 g_slist_prepend()
 g_slist_remove()
 if (slist == NULL)
 slist ? slist->data


It's worth it just for the code readability.
(though I would have used a GPtrArray.)

I also think g_stack_index() is useful for a stack. Java stacks have a
search() method.

Damon




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