lib/fast-tcpn/hash_marking.rb
def each(key = nil, value = nil)
      return enum_for(:each, key, value) unless block_given?
      return if empty?
      list_for(key, value).lazy_shuffle do |token|
        yield clone token
      end
    end
def each(key = nil, value = nil)
      return enum_for(:each, key, value) unless block_given?
      return if empty?
      list_for(key, value).lazy_shuffle do |token|
        yield clone token
      end
    end
Creates new HashMarking with specified keys. At least
 one key must be specified. The keys are used to
 store tokens in Hashes -- one hash for each key. Thus
 finding tokens by the keys is fast.

 +keys+ is a hash of the form: { key_name => method }, where +key_name+ is a name that
 will be used to access tokens indexed by this key and +method+ is a method that should
 be called on token's value to get value that should be used group tokens indexed by this key.
 Allows to iterate over all values in marking or over all values for which
 specified +key+ has specified +value+. If no block is given, returns adequate
 Enumerator. Yielded values are deep-cloned so you can use them without fear of
 interfering with TCPN simulation.

 Values are yielded in random order -- each time each is called with block
 or a new Enumerator is created, the order is changed. Thus tokens are selection
 is `in some sense fair`. Current implementation assumes, that in most cases iteration
 will finish quickly, without yielding large number of tokens. In such cases the
 shuffling algorithm is efficient. But if for some reason most tokens from marking
 should be yielded, it will be less and less efficient, with every nxt token. In this
 case one should consider using standard +shuffle+ method here instead of +lazy_shuffle+.