class NavigableIndex extends AbstractMapBasedAttributeIndex<A, O, ConcurrentNavigableMap<A, StoredResultSet<O>>> implements SortedKeyStatisticsAttributeIndex<A, O>, OnHeapTypeIndex {

    @Override
    public CloseableIterable<KeyStatistics<A>> getStatisticsForDistinctKeysDescending(final QueryOptions queryOptions) {
        final CloseableIterator<A> distinctKeysDescending = getDistinctKeysDescending(queryOptions).iterator();
        return wrapNonCloseable(new Iterable<KeyStatistics<A>>() {
            @Override
            public Iterator<KeyStatistics<A>> iterator() {
                return new LazyIterator<KeyStatistics<A>>() {
                    @Override
                    protected KeyStatistics<A> computeNext() {
                        if (distinctKeysDescending.hasNext()){
                            A key = distinctKeysDescending.next();
                            return new KeyStatistics<A>(key, getCountForKey(key, queryOptions));
                        }else{
                            return endOfData();
                        }
                    }
                };
            }
        });
    }

    protected  NavigableIndex(Factory<ConcurrentNavigableMap<A, StoredResultSet<O>>> indexMapFactory, Factory<StoredResultSet<O>> valueSetFactory, Attribute<O, A> attribute);

}