Blame src/pqueue.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors.  All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_pqueue_h__
Packit Service 20376f
#define INCLUDE_pqueue_h__
Packit Service 20376f
Packit Service 20376f
#include "vector.h"
Packit Service 20376f
Packit Service 20376f
typedef git_vector git_pqueue;
Packit Service 20376f
Packit Service 20376f
enum {
Packit Service 20376f
	/* flag meaning: don't grow heap, keep highest values only */
Packit Service 20376f
	GIT_PQUEUE_FIXED_SIZE = (GIT_VECTOR_FLAG_MAX << 1),
Packit Service 20376f
};
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Initialize priority queue
Packit Service 20376f
 *
Packit Service 20376f
 * @param pq The priority queue struct to initialize
Packit Service 20376f
 * @param flags Flags (see above) to control queue behavior
Packit Service 20376f
 * @param init_size The initial queue size
Packit Service 20376f
 * @param cmp The entry priority comparison function
Packit Service 20376f
 * @return 0 on success, <0 on error
Packit Service 20376f
 */
Packit Service 20376f
extern int git_pqueue_init(
Packit Service 20376f
	git_pqueue *pq,
Packit Service 20376f
	uint32_t flags,
Packit Service 20376f
	size_t init_size,
Packit Service 20376f
	git_vector_cmp cmp);
Packit Service 20376f
Packit Service 20376f
#define git_pqueue_free  git_vector_free
Packit Service 20376f
#define git_pqueue_clear git_vector_clear
Packit Service 20376f
#define git_pqueue_size  git_vector_length
Packit Service 20376f
#define git_pqueue_get   git_vector_get
Packit Service 20376f
#define git_pqueue_reverse git_vector_reverse
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Insert a new item into the queue
Packit Service 20376f
 *
Packit Service 20376f
 * @param pq The priority queue
Packit Service 20376f
 * @param item Pointer to the item data
Packit Service 20376f
 * @return 0 on success, <0 on failure
Packit Service 20376f
 */
Packit Service 20376f
extern int git_pqueue_insert(git_pqueue *pq, void *item);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Remove the top item in the priority queue
Packit Service 20376f
 *
Packit Service 20376f
 * @param pq The priority queue
Packit Service 20376f
 * @return item from heap on success, NULL if queue is empty
Packit Service 20376f
 */
Packit Service 20376f
extern void *git_pqueue_pop(git_pqueue *pq);
Packit Service 20376f
Packit Service 20376f
#endif