/*
 * frost_queue.h
 *
 *  Created on: Jul 1, 2012
 *      Author: ergino
 */

#ifndef FROST_QUEUE_H_
#define FROST_QUEUE_H_

#include "frost_common.h"
#include "frost_list.h"

/*
 * Queues
 */
typedef struct
{
    FROST_List *head;
    FROST_List *tail;
    frost_uint length;
} FROST_Queue;

#ifdef __cplusplus
extern "C"
{
#endif

frost_pointer frost_queue_peek_head (FROST_Queue *queue);
frost_pointer frost_queue_peek_tail (FROST_Queue *queue);
frost_pointer frost_queue_peek_nth (FROST_Queue *queue,
          frost_uint   n);
frost_int frost_queue_index (FROST_Queue        *queue,
           frost_constpointer  data);
frost_pointer frost_queue_pop_head  (FROST_Queue   *queue);
void     frost_queue_push_head (FROST_Queue   *queue,
                frost_pointer  data);
void     frost_queue_push_tail (FROST_Queue   *queue,
                frost_pointer  data);
frost_bool frost_queue_is_empty  (FROST_Queue   *queue);
FROST_Queue  *frost_queue_new       (void);
void     frost_queue_free      (FROST_Queue   *queue);
void     frost_queue_foreach   (FROST_Queue   *queue, FROSTFunc func, frost_pointer user_data);


#ifdef __cplusplus
}
#endif

#endif /* FROST_QUEUE_H_ */
