From 83b552faf649f089b0da76137e41dafedeaf05d0 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Thu, 10 Jul 2014 16:48:42 +0100 Subject: [PATCH] refs #290 added CSequence::truncate method --- src/blackmisc/sequence.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/blackmisc/sequence.h b/src/blackmisc/sequence.h index 2414ce5e1..e9518dab2 100644 --- a/src/blackmisc/sequence.h +++ b/src/blackmisc/sequence.h @@ -200,6 +200,11 @@ namespace BlackMisc */ void clear() { if (pimpl()) pimpl()->clear(); } + /*! + * \brief Changes the size of the sequence, if it is bigger than the given size. + */ + void truncate(size_type maxSize) { if (size() > maxSize) { erase(begin() + maxSize, end()); } } + /*! * \brief Inserts an element into the sequence. * \return An iterator to the position where value was inserted.