From 9e28024aeb0a31037280e3cc579e7c289287d8ee Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 1 Dec 2005 12:20:20 +0000 Subject: [PATCH] * vec.h (VEC_block_remove): New. From-SVN: r107817 --- gcc/ChangeLog | 4 ++++ gcc/vec.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e0715c43a857..17808f0f7387 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2005-12-01 Nathan Sidwell + + * vec.h (VEC_block_remove): New. + 2005-12-01 Gabriel Dos Reis PR c/13384 diff --git a/gcc/vec.h b/gcc/vec.h index 586797a6eec7..93453a895ed8 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -366,6 +366,15 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #define VEC_unordered_remove(T,V,I) \ (VEC_OP(T,base,unordered_remove)(VEC_BASE(V),I VEC_CHECK_INFO)) +/* Remove a block of elements + void VEC_T_block_remove (VEC(T) *v, unsigned ix, unsigned len); + + Remove LEN elements starting at the IXth. Ordering is retained. + This is an O(1) operation. */ + +#define VEC_block_remove(T,V,I,L) \ + (VEC_OP(T,base,block_remove)(VEC_BASE(V),I,L VEC_CHECK_INFO)) + /* Get the address of the array of elements T *VEC_T_address (VEC(T) v) @@ -636,6 +645,17 @@ static inline T VEC_OP (T,base,unordered_remove) \ return obj_; \ } \ \ +static inline void VEC_OP (T,base,block_remove) \ + (VEC(T,base) *vec_, unsigned ix_, unsigned len_ VEC_CHECK_DECL) \ +{ \ + T *slot_; \ + \ + VEC_ASSERT (ix_ + len_ <= vec_->num, "block_remove", T, base); \ + slot_ = &vec_->vec[ix_]; \ + vec_->num -= len_; \ + memmove (slot_, slot_ + len_, (vec_->num - ix_) * sizeof (T)); \ +} \ + \ static inline T *VEC_OP (T,base,address) \ (VEC(T,base) *vec_) \ { \ @@ -886,6 +906,17 @@ static inline void VEC_OP (T,base,unordered_remove) \ vec_->vec[ix_] = vec_->vec[--vec_->num]; \ } \ \ +static inline void VEC_OP (T,base,block_remove) \ + (VEC(T,base) *vec_, unsigned ix_, unsigned len_ VEC_CHECK_DECL) \ +{ \ + T *slot_; \ + \ + VEC_ASSERT (ix_ + len_ <= vec_->num, "block_remove", T, base); \ + slot_ = &vec_->vec[ix_]; \ + vec_->num -= len_; \ + memmove (slot_, slot_ + len_, (vec_->num - ix_) * sizeof (T)); \ +} \ + \ static inline T *VEC_OP (T,base,address) \ (VEC(T,base) *vec_) \ { \