Skip to main content

Counter

Standard library class collections.Counter View source
class Counter
@tuple
class Counter[T]
Fields 1
T type
Constructors 5
__new__
__new__(capacity: int = 8) -> Counter[T]
Defined in collections
__new__
__new__(elements: Generator[T], /) -> Counter[T]
Defined in collections
__new__
__new__(other: Counter[T], /) -> Counter[T]
Defined in collections
__new__
__new__(other: Dict[(T, int)], /) -> Counter[T]
Defined in collections
__new__
__new__[S: type](other: defaultdict[(T, int, S)], /) -> Counter[T]
Added by collections
Methods 17
keys
keys(self: Self, /)
Defined in collections
values
values(self: Self, /)
Defined in collections
items
items(self: Self, /)
Defined in collections
get
get(self: Self, key: T, /)
Defined in collections
get(self: Self, key: T, default: int, /)
Defined in collections
setdefault
setdefault(self: Self, key: T, value: int, /)
Defined in collections
pop
pop(self: Self, key: T, /)
Defined in collections
pop(self: Self, key: T, missing, /)
Defined in collections
popitem
popitem(self: Self, /)
Defined in collections
clear
clear(self: Self, /)
Defined in collections
resize
resize(self: Self, minused: int)
Defined in collections
increment
increment[Z: type](self: Self, key: T, by: Z = 1)
Defined in collections
copy
copy(self: Self)
Defined in collections
fromkeys
fromkeys[K: type, V: type](ks: Generator[K], v: V)
Defined in collections
elements
elements(self: Self) -> Generator[T]
Defined in collections
most_common
most_common(self: Self, n: Optional[int] = None) -> List[Tuple[(T, int)]]
Defined in collections
subtract
subtract(self: Self, elements: Generator[T], /)
Defined in collections
subtract(self: Self, other: Counter[T], /)
Defined in collections
subtract(self: Self, other: Dict[(T, int)], /)
Defined in collections
subtract[S: type](self: Self, other: defaultdict[(T, int, S)], /)
Added by collections
update
update(self: Self, elements: Generator[T], /)
Defined in collections
update(self: Self, other: Counter[T], /)
Defined in collections
update(self: Self, other: Dict[(T, int)], /)
Defined in collections
update(self: Self, /)
Defined in collections
update[S: type](self: Self, other: defaultdict[(T, int, S)], /)
Added by collections
total
total(self: Self) -> int
Defined in collections
Special methods 25
__len__
__len__(self: Self, /)
Defined in collections
__bool__
__bool__(self: Self)
Defined in collections
__iter__
__iter__(self: Self, /)
Defined in collections
__reversed__
__reversed__(self: Self, /)
Defined in collections
__contains__
__contains__(self: Self, key: T, /)
Defined in collections
__setitem__
__setitem__(self: Self, key: T, value: int, /)
Defined in collections
__deepcopy__
__deepcopy__(self: Self)
Defined in collections
__getitem__
__getitem__(self: Self, key: T, /) -> int
Defined in collections
__delitem__
__delitem__(self: Self, key: T)
Defined in collections
__eq__
__eq__(self: Self, other: Counter[T]) -> bool
Defined in collections
__eq__(self: Self, other: Dict[(T, int)]) -> bool
Defined in collections
__eq__[S: type](self: Self, other: defaultdict[(T, int, S)])
Added by collections
__ne__
__ne__(self: Self, other: Counter[T]) -> bool
Defined in collections
__ne__(self: Self, other: Dict[(T, int)]) -> bool
Defined in collections
__ne__[S: type](self: Self, other: defaultdict[(T, int, S)])
Added by collections
__copy__
__copy__(self: Self) -> Counter[T]
Defined in collections
__or__
__or__(self: Self, other)
Defined in collections
__or__(self: Self, other: Counter[T]) -> Counter[T]
Defined in collections
__ior__
__ior__(self: Self, other)
Defined in collections
__ior__(self: Self, other: Counter[T]) -> Counter[T]
Defined in collections
__iadd__
__iadd__(self: Self, other: Counter[T]) -> Counter[T]
Defined in collections
__isub__
__isub__(self: Self, other: Counter[T]) -> Counter[T]
Defined in collections
__iand__
__iand__(self: Self, other: Counter[T]) -> Counter[T]
Defined in collections
__pos__
__pos__(self: Self) -> Counter[T]
Defined in collections
__neg__
__neg__(self: Self) -> Counter[T]
Defined in collections
__add__
__add__(self: Self, other: Counter[T]) -> Counter[T]
Defined in collections
__sub__
__sub__(self: Self, other: Counter[T]) -> Counter[T]
Defined in collections
__and__
__and__(self: Self, other: Counter[T]) -> Counter[T]
Defined in collections
__repr__
__repr__(self: Self)
Defined in collections
__dict_do_op__
__dict_do_op__[F: type, Z: type](self: Self, key: T, other: Z, default: int, op: F)
Defined in collections
__dict_do_op_throws__
__dict_do_op_throws__[F: type, Z: type](self: Self, key: T, other: Z, op: F)
Defined in collections