hudson.util
Class CopyOnWriteList<E>

java.lang.Object
  extended by hudson.util.CopyOnWriteList<E>
All Implemented Interfaces:
Iterable<E>

public class CopyOnWriteList<E>
extends Object
implements Iterable<E>

List-like implementation that has copy-on-write semantics.

This class is suitable where highly concurrent access is needed, yet the write operation is relatively uncommon.

Author:
Kohsuke Kawaguchi

Nested Class Summary
static class CopyOnWriteList.ConverterImpl
          Converter implementation for XStream.
 
Constructor Summary
CopyOnWriteList()
           
CopyOnWriteList(List<E> core)
           
 
Method Summary
 void add(E e)
           
 void addAll(Collection<? extends E> items)
           
 void addAllTo(Collection<? super E> dst)
           
 void clear()
           
 boolean contains(Object item)
           
 E get(int index)
           
 List<E> getView()
           
 boolean isEmpty()
           
 Iterator<E> iterator()
          Returns an iterator.
 boolean remove(E e)
          Removes an item from the list.
 void replaceBy(Collection<? extends E> that)
          Completely replaces this list by the contents of the given list.
 void replaceBy(CopyOnWriteList<? extends E> that)
          Completely replaces this list by the contents of the given list.
 void replaceBy(E... that)
          Completely replaces this list by the contents of the given list.
 int size()
           
 E[] toArray(E[] array)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CopyOnWriteList

public CopyOnWriteList(List<E> core)

CopyOnWriteList

public CopyOnWriteList()
Method Detail

add

public void add(E e)

addAll

public void addAll(Collection<? extends E> items)

remove

public boolean remove(E e)
Removes an item from the list.

Returns:
true if the list contained the item. False if it didn't, in which case there's no change.

iterator

public Iterator<E> iterator()
Returns an iterator.

Specified by:
iterator in interface Iterable<E>

replaceBy

public void replaceBy(CopyOnWriteList<? extends E> that)
Completely replaces this list by the contents of the given list.


replaceBy

public void replaceBy(Collection<? extends E> that)
Completely replaces this list by the contents of the given list.


replaceBy

public void replaceBy(E... that)
Completely replaces this list by the contents of the given list.


clear

public void clear()

toArray

public E[] toArray(E[] array)

getView

public List<E> getView()

addAllTo

public void addAllTo(Collection<? super E> dst)

get

public E get(int index)

isEmpty

public boolean isEmpty()

size

public int size()

contains

public boolean contains(Object item)


Copyright © 2004-2013. All Rights Reserved.