root/software/fss-parallel-tools/vec.h @ 6267e2f6
| 7e8045d8 | David Sorber | /**
|
|
* Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
|
|||
*
|
|||
* Licensed under the Universal Permissive License v 1.0 as shown at
|
|||
* http://oss.oracle.com/licenses/upl
|
|||
*
|
|||
*/
|
|||
#ifndef VEC_H
|
|||
#define VEC_H
|
|||
#include <stddef.h>
|
|||
struct vec; // Defined by vec.c
|
|||
struct vecitem; // Defined by the caller
|
|||
struct vec *mk_vec(void);
|
|||
struct vec *vec_destroy(struct vec *vec);
|
|||
size_t vec_size(const struct vec *vec);
|
|||
struct vecitem *vec_fetch(const struct vec *vec, size_t i);
|
|||
void vec_push(struct vec *vec, struct vecitem *item);
|
|||
// Add item to the end of vec.
|
|||
struct vecitem* vec_pop(struct vec *vec);
|
|||
// Effect: If the vec is empty, return NULL, else remove and return
|
|||
// the last item in the vec.
|
|||
struct vecitem* vec_peek(struct vec *vec);
|
|||
// Effect: If the vec is empty, return NULL, else return the last item
|
|||
// in the vec (without removing it).
|
|||
void vec_sort(struct vec *vec,
|
|||
int (*compar)(const struct vecitem *, const struct vecitem *));
|
|||
// Effect: Sort the vector using compar (which has the same semantics
|
|||
// as the compar function in qsort, except for the type is struct
|
|||
// vecitem, not void*.
|
|||
#endif
|