From ab093ddf204d59fd76668e675a489aff2271e5e3 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Mon, 19 Apr 2010 08:33:43 +0000 Subject: [PATCH] v1: add the possibility to remove an element using its iterator only the const iterators are necessary git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@132 a6f86f6d-0131-4f8e-9e7b-e335508773d5 --- ebml/EbmlMaster.h | 7 +++---- src/EbmlMaster.cpp | 5 +++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ebml/EbmlMaster.h b/ebml/EbmlMaster.h index d2b81a2..5e3eddd 100644 --- a/ebml/EbmlMaster.h +++ b/ebml/EbmlMaster.h @@ -119,10 +119,8 @@ class EBML_DLL_API EbmlMaster : public EbmlElement { size_t ListSize() const {return ElementList.size();} - inline std::vector::const_iterator begin() {return ElementList.begin();} - inline std::vector::const_iterator end() {return ElementList.end();} - inline std::vector::const_iterator begin() const {return ElementList.begin();} - inline std::vector::const_iterator end() const {return ElementList.end();} + inline EBML_MASTER_ITERATOR begin() const {return ElementList.begin();} + inline EBML_MASTER_ITERATOR end() const {return ElementList.end();} EbmlElement * operator[](unsigned int position) {return ElementList[position];} const EbmlElement * operator[](unsigned int position) const {return ElementList[position];} @@ -142,6 +140,7 @@ class EBML_DLL_API EbmlMaster : public EbmlElement { \brief Remove an element from the list of the master */ void Remove(size_t Index); + void Remove(const EBML_MASTER_ITERATOR & Itr); /*! \brief remove all elements, even the mandatory ones diff --git a/src/EbmlMaster.cpp b/src/EbmlMaster.cpp index f81857a..8680bda 100644 --- a/src/EbmlMaster.cpp +++ b/src/EbmlMaster.cpp @@ -480,6 +480,11 @@ void EbmlMaster::Remove(size_t Index) } } +void EbmlMaster::Remove(const std::vector::const_iterator & Itr) +{ + ElementList.erase(Itr); +} + bool EbmlMaster::VerifyChecksum() const { if (!bChecksumUsed)