Example usage for com.google.common.collect ImmutableSortedSet headSet

List of usage examples for com.google.common.collect ImmutableSortedSet headSet

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSortedSet headSet.

Prototype

ImmutableSortedSet<E> headSet(E toElement, boolean inclusive) 

Source Link

Usage

From source file:org.voltcore.utils.COWNavigableSet.java

@Override
public E pollLast() {
    while (true) {
        ImmutableSortedSet<E> snapshot = m_set.get();
        E last = null;/*from w ww . jav  a2  s  .co m*/
        if (snapshot.size() > 0) {
            last = snapshot.last();
        } else {
            return null;
        }
        ImmutableSortedSet.Builder<E> builder = ImmutableSortedSet.naturalOrder();
        builder.addAll(snapshot.headSet(last, false));
        if (m_set.compareAndSet(snapshot, builder.build())) {
            return last;
        }
    }
}