new gstack, gqueue

The following are two new ADTs I would like to add to Glib.  Are there
any comments or suggestions before the initial commit?

Code is in the GLIB_1_3_HACKS branch.



/* Stacks
GStack * g_stack_new    (void);
void     g_stack_free   (GStack *stack);
void     _g_stack_push  (GStack *stack, gpointer data);
gpointer g_stack_pop    (GStack *stack);

#  define g_stack_push(stack) G_STMT_START {                            \
            if ((GStack *)(stack))                                      \
              ((GStack *)(stack))->list =                               \
                  g_list_prepend (((GStack *)(stack))->list, data);     \
          } G_STMT_END
#  define  g_stack_push _g_stack_push

/* Queues

GQueue *        g_queue_new             (void);
void            g_queue_free            (GQueue *q);
guint           g_queue_get_size        (GQueue *q);
void            g_queue_push_front      (GQueue *q, gpointer data);
void            g_queue_push_back       (GQueue *q, gpointer data);
gpointer        g_queue_pop_front       (GQueue *q);
gpointer        g_queue_pop_back        (GQueue *q);

#define         g_queue_push            g_queue_push_back
#define         g_queue_pop             g_queue_pop_front

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