import poset
# A counter counts occurrences of things
-# Use this instead of a HashMap[E, Int]
+# Use this instead of a `HashMap[E, Int]`
class Counter[E: Object]
super Map[E, Int]
private var map = new HashMap[E, Int]
- # The number of counted occurrences of `e'
+ # The number of counted occurrences of `e`
redef fun [](e: E): Int
do
var map = self.map
redef fun values do return map.values
- # Count one more occurrence of `e'
+ # Count one more occurrence of `e`
fun inc(e: E)
do
self.map[e] = self[e] + 1
# Use `element_to_s` to display the element
fun print_elements(count: Int)
do
- # Display most used types (ie the last of `types')
print " list:"
var list = self.sort
var min = count
end
end
-# Helper function to display n/d and handle division by 0
+# Helper function to display `n/d` and handle division by 0
fun div(n: Int, d: Int): String
do
if d == 0 then return "na"