diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-12-11 07:16:46 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-12-11 07:16:46 +0100 |
commit | 23c497886ebfbe95dbffa9320de4340d7a7445c9 (patch) | |
tree | 529313cb9ae6ce0a0d434a6e92e8a1ccaf4c8b36 /common | |
parent | 28573641c83b4e9c27c7a5b3ec0a3b10cf116eb8 (diff) |
Added List::count().
Diffstat (limited to 'common')
-rw-r--r-- | common/list.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/common/list.h b/common/list.h index 2ad41fd..513f79c 100644 --- a/common/list.h +++ b/common/list.h @@ -22,10 +22,15 @@ class List : public B { } //! Check if specified item is present in list. - bool contains(T item) { + bool contains(const T& item) { return std::find(B::begin(), B::end(), item) != B::end(); } + //! Count number of instances of specified item in list. + std::size_t count(const T& item) { + return std::count(B::begin(), B::end(), item); + } + //! Delete item by index. void del(std::size_t index) { erase(B::begin() + index); |