2022-06-02 04:13:43 +02:00
|
|
|
var things = {}
|
|
|
|
|
|
|
|
func get_unique_count():
|
|
|
|
return things.size()
|
|
|
|
|
|
|
|
func add(thing):
|
2023-01-07 20:26:17 +01:00
|
|
|
if(things.has(thing)):
|
2022-06-02 04:13:43 +02:00
|
|
|
things[thing] += 1
|
|
|
|
else:
|
|
|
|
things[thing] = 1
|
|
|
|
|
|
|
|
func has(thing):
|
|
|
|
return things.has(thing)
|
|
|
|
|
|
|
|
func get(thing):
|
|
|
|
var to_return = 0
|
2023-01-07 20:26:17 +01:00
|
|
|
if(things.has(thing)):
|
2022-06-02 04:13:43 +02:00
|
|
|
to_return = things[thing]
|
|
|
|
return to_return
|
|
|
|
|
|
|
|
func sum():
|
|
|
|
var count = 0
|
|
|
|
for key in things:
|
|
|
|
count += things[key]
|
|
|
|
return count
|
|
|
|
|
|
|
|
func to_s():
|
|
|
|
var to_return = ""
|
|
|
|
for key in things:
|
|
|
|
to_return += str(key, ": ", things[key], "\n")
|
|
|
|
to_return += str("sum: ", sum())
|
|
|
|
return to_return
|
|
|
|
|
|
|
|
func get_max_count():
|
|
|
|
var max_val = null
|
|
|
|
for key in things:
|
2023-01-07 20:26:17 +01:00
|
|
|
if(max_val == null or things[key] > max_val):
|
2022-06-02 04:13:43 +02:00
|
|
|
max_val = things[key]
|
|
|
|
return max_val
|
|
|
|
|
|
|
|
func add_array_items(array):
|
|
|
|
for i in range(array.size()):
|
|
|
|
add(array[i])
|