org.opcfoundation.ua.utils
Class SnapshotArray<T>

java.lang.Object
  extended by org.opcfoundation.ua.utils.SnapshotArray<T>
Type Parameters:
T -

public class SnapshotArray<T>
extends Object

SnapshotArray is synchronized list that provides copy-on-write-arraylist of its contents.

Author:
Toni Kalajainen

Constructor Summary
SnapshotArray(Class<T> componentType)
          Construct new Listener List
 
Method Summary
 void add(T item)
          add.
 void clear()
          clear.
 T[] getArray()
          Get a snapshot of the contents.
 boolean isEmpty()
          isEmpty.
 boolean remove(T item)
          Removes the first occurance of the item.
 int size()
          size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnapshotArray

public SnapshotArray(Class<T> componentType)
Construct new Listener List

Parameters:
componentType - the class of the listener type
Method Detail

getArray

public T[] getArray()
Get a snapshot of the contents. This method exposes an internal state which must not be modified.

Returns:
an array.

add

public void add(T item)

add.

Parameters:
item - a T object.

remove

public boolean remove(T item)
Removes the first occurance of the item. If the item is added multiple times, then it must be removed as many times.

Parameters:
item - an item
Returns:
true if the item was removed from the list

size

public int size()

size.

Returns:
a int.

isEmpty

public boolean isEmpty()

isEmpty.

Returns:
a boolean.

clear

public void clear()

clear.



Copyright © 2018. All rights reserved.