Example usage for java.util Collections synchronizedNavigableSet

List of usage examples for java.util Collections synchronizedNavigableSet

Introduction

In this page you can find the example usage for java.util Collections synchronizedNavigableSet.

Prototype

public static <T> NavigableSet<T> synchronizedNavigableSet(NavigableSet<T> s) 

Source Link

Document

Returns a synchronized (thread-safe) navigable set backed by the specified navigable set.

Usage

From source file:ch.chrigu.datastructures.demo.instances.CollectionInstance.java

/**
 * The best matching {@link Collections}'s synchronized... function is applied.
 *///from w  ww .  j av a  2s.c  om
private Collection<T> synchronizedCollection(Collection<T> instance) {
    if (instance instanceof List) {
        return Collections.synchronizedList((List<T>) instance);
    }
    if (instance instanceof Set) {
        if (instance instanceof NavigableSet) {
            return Collections.synchronizedNavigableSet((NavigableSet<T>) instance);
        }
        return Collections.synchronizedSet((Set<T>) instance);
    }
    return Collections.synchronizedCollection(instance);
}