summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-12-11 07:16:46 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-12-11 07:16:46 +0100
commit23c497886ebfbe95dbffa9320de4340d7a7445c9 (patch)
tree529313cb9ae6ce0a0d434a6e92e8a1ccaf4c8b36 /common
parent28573641c83b4e9c27c7a5b3ec0a3b10cf116eb8 (diff)
Added List::count().
Diffstat (limited to 'common')
-rw-r--r--common/list.h7
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);