core :: Collection :: count
item
Comparisons are done with ==
assert [10,20,10].count(10) == 2
# How many occurrences of `item` are in the collection? # Comparisons are done with == # # assert [10,20,10].count(10) == 2 fun count(item: nullable Object): Int do var nb = 0 for i in self do if i == item then nb += 1 return nb end
# assert [1..10].count(1) == 1 # assert [1..10].count(0) == 0 redef fun count(item) do if has(item) then return 1 else return 0 end end
redef fun count(e) do mutex.lock var r = real_collection.count(e) mutex.unlock return r end
redef fun count(an_item) do if item == an_item then return 1 else return 0 end end
redef fun count(item) do var res = 0 var i = 0 var l = length while i < l do if self[i] == item then res += 1 i += 1 end return res end
redef fun count(k) do if self.has(k) then return 1 else return 0
# O(n) redef fun count(item) do var nb = 0 for i in self.map._items do if i.second == item then nb += 1 return nb end
redef fun count(item) do var nb = 0 var c = self.map._first_item while c != null do if c._value == item then nb += 1 c = c._next_item end return nb end
# Only 0 or 1 redef fun count(item) do if has(item) then return 1 else return 0 end end
redef fun count(e) do var nb = 0 var node = _head while node != null do if node.item != e then nb += 1 node = node.next end return nb end