```
my $max_cs = 0;
foreach my $cs (values %{$j{$type}}) {
    $max_cs = length($cs) > $max_cs ? length($cs) : $max_cs;
}

```

Can the above be done in better than O(N)? Maybe in a different data structure other than a hash?

Is a priority queue shareable between threads?

Can [Hash::PriorityQueue](http://search.cpan.org/perldoc?Hash::PriorityQueue) be shared between threads using [threads::shared](http://search.cpan.org/perldoc?threads::shared)?