X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/20eb516fdebd2fb901e6a09ffa7e741cfb8e3a83..1ecb4530757072f552439ee4798929b3a4a6b89d:/darray.h diff --git a/darray.h b/darray.h index b8f17eb..a768c1d 100644 --- a/darray.h +++ b/darray.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: darray.h,v 1.5 2000/06/17 10:37:39 mdw Exp $ + * $Id: darray.h,v 1.7 2004/04/08 01:36:11 mdw Exp $ * * Dynamically growing dense arrays * @@ -27,26 +27,6 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: darray.h,v $ - * Revision 1.5 2000/06/17 10:37:39 mdw - * Add support for arena management. - * - * Revision 1.4 1999/12/10 23:42:04 mdw - * Change header file guard names. - * - * Revision 1.3 1999/11/05 14:32:43 mdw - * Minor change in argument naming. - * - * Revision 1.2 1999/10/29 22:59:22 mdw - * New array adjustment macros for unsigned arguments. - * - * Revision 1.1 1999/10/22 22:37:26 mdw - * New dynamic array implementation replaces `dynarray.h'. - * - */ - #ifndef MLIB_DARRAY_H #define MLIB_DARRAY_H @@ -410,6 +390,26 @@ typedef struct da_base { /*----- Stack-like operations ---------------------------------------------*/ +/* --- @DA_FIRST@ --- * + * + * Arguments: @a@ = pointer to an array block (multiply evaluated) + * + * Use: Evaluates to the initial element in array @a@. It is unsafe + * to do this if the array is empty. The array is not changed. + */ + +#define DA_FIRST(a) (DA(a)[0]) + +/* --- @DA_LAST@ --- * + * + * Arguments: @a@ = pointer to an array block (multiply evaluated) + * + * Use: Evaluates to the final element in array @a@. It is unsafe + * to do this if the array is empty. The array is not changed. + */ + +#define DA_LAST(a) (DA(a)[(a)->b.len - 1]) + /* --- @DA_PUSH@ --- * * * Arguments: @a@ = pointer to an array block (multiply evaluated) @@ -462,7 +462,7 @@ typedef struct da_base { */ #define DA_SHIFT(a) \ - ((a)->b.len ? ((void)0) : THROW(DAEXC_UFLOW), \ + ((a)->b.len ? ((void)0) : THROW(DAEXC_UFLOW), \ (a)->b.len--, \ (a)->b.sz--, \ (a)->b.off++, \