Example usage for java.util.concurrent.atomic AtomicReferenceArray get

List of usage examples for java.util.concurrent.atomic AtomicReferenceArray get

Introduction

In this page you can find the example usage for java.util.concurrent.atomic AtomicReferenceArray get.

Prototype

@SuppressWarnings("unchecked")
public final E get(int i) 

Source Link

Document

Returns the current value of the element at index i , with memory effects as specified by VarHandle#getVolatile .

Usage

From source file:Main.java

private static <T> Map<Integer, T> asMap(AtomicReferenceArray<T> a) {
    Map<Integer, T> map = new TreeMap<Integer, T>();
    for (int i = 0; i < a.length(); i++) {
        T t = a.get(i);
        if (t != null) {
            map.put(i, t);/*from w  w  w .jav  a 2s. com*/
        }
    }
    return map;
}