Python Counter equivalent in other programming language?
Python has a class called Counter which is very useful especially in natural language processing (NLP), information retrieval (IR), and text mining (TM) problems. It finds the frequency of items in a collection. For example: >>> from collections import Counter >>> # Use a string as an argument >>> Counter("Mississippi") Counter({'i': 4, 's': 4, 'p': 2, 'm': 1}) We can implement this class using a defaultdict like: >>> from collections import defaultdict >>> counter = defaultdict(int) >>> word = "mississippi" >>> for letter in word: counter[letter] += 1 >>> counter defaultdict(<class 'int'>, {'m': 1, 'i': 4, 's': 4, 'p': 2}) or we can use a simple dictionary as the following: >>> counter = {} >>> word = "mississippi" >>> for letter in word: counter[letter] = counter.get(letter, 0) + 1 >>> counter {'m': 1, 'i': 4, 's': 4, 'p': 2} I want to know is there any built-in class in other programming languages like C, C++, C#, Java, Javascript, Typescript, etc.?