From c821d9ea6552c641039df312a5d3122de25756de Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 23 Jun 2018 11:05:29 +0200 Subject: [PATCH] Add methods _front & _last for arrays. --- m-array.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/m-array.h b/m-array.h index 5f3d6a82..80e235cf 100644 --- a/m-array.h +++ b/m-array.h @@ -545,6 +545,22 @@ return M_CONST_CAST(type, &v->ptr[i]); \ } \ \ + static inline const type * \ + M_C(name, _front)(const array_t v) \ + { \ + ARRAYI_CONTRACT(v); \ + assert (v->size > 0); \ + return M_C(name, _cget)(v, 0); \ + } \ + \ + static inline const type * \ + M_C(name, _last)(const array_t v) \ + { \ + ARRAYI_CONTRACT(v); \ + assert (v->size > 0); \ + return M_C(name, _cget)(v, v->size-1); \ + } \ + \ static inline void \ M_C(name, _it)(array_it_t it, const array_t v) \ { \