public Map<K, V> snapshot(boolean ascending, int limit, @NonNull Function<V, V> transformer) {
    requireArgument(limit >= 0);

    Map<K, V> map = new LinkedHashMap<>(Math.min(limit, cache.size()));
    int startLevel = ascending ? 0 : wheel.length - 1;
    for (int i = 0; i < wheel.length; i++) {
      int indexOffset = ascending ? i : -i;
      int index = startLevel + indexOffset;

      int ticks = (int) (nanos >> SHIFT[index]);
      int bucketMask = (wheel[index].length - 1);
      int startBucket = (ticks & bucketMask) + (ascending ? 1 : 0);
      for (int j = 0; j < wheel[index].length; j++) {
        int bucketOffset = ascending ? j : -j;
        Node<K, V> sentinel = wheel[index][(startBucket + bucketOffset) & bucketMask];

        for (Node<K, V> node = traverse(ascending, sentinel);
            node != sentinel; node = traverse(ascending, node)) {
          if (map.size() >= limit) {
            break;
          }

          K key = node.getKey();
          V value = transformer.apply(node.getValue());
          if ((key != null) && (value != null) && node.isAlive()) {
            map.put(key, value);
          }
        }
      }
    }
    return Collections.unmodifiableMap(map);
  }
public Map < K , V > snapshot ( boolean ascending , int limit , @ NonNull Function < V , V > transformer ) { requireArgument ( limit >= 0 ) ; Map < K , V > map = new LinkedHashMap < > ( Math . min ( limit , cache . size ( ) ) ) ; int startLevel = ascending ? 0 : wheel . length - 1 ; for ( int i = 0 ; i < wheel . length ; i ++ ) { int indexOffset = ascending ? i : - i ; int index = startLevel + indexOffset ; int ticks = ( int ) ( nanos > > SHIFT [ index ] ) ; int bucketMask = ( wheel [ index ] . length - 1 ) ; int startBucket = ( ticks & bucketMask ) + ( ascending ? 1 : 0 ) ; for ( int j = 0 ; j < wheel [ index ] . length ; j ++ ) { int bucketOffset = ascending ? j : - j ; Node < K , V > sentinel = wheel [ index ] [ ( startBucket + bucketOffset ) & bucketMask ] ; for ( Node < K , V > node = traverse ( ascending , sentinel ) ; node != sentinel ; node = traverse ( ascending , node ) ) { if ( map . size ( ) >= limit ) { break ; } K key = node . getKey ( ) ; V value = transformer . apply ( node . getValue ( ) ) ; if ( ( key != null ) && ( value != null ) && node . isAlive ( ) ) { map . put ( key , value ) ; } } } } return Collections . unmodifiableMap ( map ) ; }
Returns an unmodifiable snapshot map roughly ordered by the expiration time. The wheels are
evaluated in order, but the timers that fall within the bucket's range are not sorted. Beware
that obtaining the mappings is <em>NOT</em> a constant-time operation.

@param ascending the direction
@param limit the maximum number of entries
@param transformer a function that unwraps the value
@return an unmodifiable snapshot in the desired order