com.levigo.util.base.glazedlists
Class CompositeList<E>

java.lang.Object
  extended by com.levigo.util.base.glazedlists.AbstractEventList<E>
      extended by com.levigo.util.base.glazedlists.TransformedList<S,E>
          extended by com.levigo.util.base.glazedlists.CollectionList<EventList<E>,E>
              extended by com.levigo.util.base.glazedlists.CompositeList<E>
All Implemented Interfaces:
ListEventListener<EventList<E>>, EventList<E>, Iterable<E>, Collection<E>, EventListener, List<E>

public class CompositeList<E>
extends CollectionList<EventList<E>,E>

An EventList composed of multiple source EventLists. This list shows the contents of its source lists.

Note that all contained EventLists must use the same ListEventPublisher and ReadWriteLock, particularly if this EventList is to be used my multiple threads concurrently. To construct an EventList that shares the ListEventPublisher and ReadWriteLock with this CompositeList, use createMemberList().

Warning: This class is thread ready but not thread safe. See EventList for an example of thread safe code.

Overview
EventList Overview
Writable: only CollectionList.set(int,Object) and CollectionList.remove(int)
Concurrency: not thread safe
Performance: reads: O(log N), writes O(log N)
Memory: 96 bytes per element
Unit Tests: N/A
Issues: 25 93 96 162

Author:
Jesse Wilson

Nested Class Summary
 
Nested classes/interfaces inherited from class com.levigo.util.base.glazedlists.CollectionList
CollectionList.Model<E,S>
 
Field Summary
 
Fields inherited from class com.levigo.util.base.glazedlists.TransformedList
source
 
Fields inherited from class com.levigo.util.base.glazedlists.AbstractEventList
publisher, readWriteLock, updates
 
Constructor Summary
CompositeList()
           
CompositeList(ListEventPublisher publisher, ReadWriteLock lock)
          Create a CompositeList that uses the given publisher and lock.
CompositeList(ReadWriteLock lock)
          Deprecated. replaced by CompositeList(ListEventPublisher, ReadWriteLock), because prebuilt member lists should share lock and publisher with the CompositeList.
 
Method Summary
 void addMemberList(EventList<E> list)
          Adds the specified EventList as a source to this CompositeList.
<E> EventList<E>
createMemberList()
          Creates a new EventList that shares its ReadWriteLock with this CompositeList.
 void removeMemberList(EventList<E> list)
          Removes the specified EventList as a source EventList to this CompositeList.
 
Methods inherited from class com.levigo.util.base.glazedlists.CollectionList
childEndingIndex, childStartingIndex, dispose, get, isWritable, listChanged, remove, set, size
 
Methods inherited from class com.levigo.util.base.glazedlists.TransformedList
add, addAll, clear, getSourceIndex, removeAll, retainAll
 
Methods inherited from class com.levigo.util.base.glazedlists.AbstractEventList
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompositeList

public CompositeList()

CompositeList

@Deprecated
public CompositeList(ReadWriteLock lock)
Deprecated. replaced by CompositeList(ListEventPublisher, ReadWriteLock), because prebuilt member lists should share lock and publisher with the CompositeList.

Create a CompositeList that uses the given lock. Note that this lock will also be used when building new member lists.

This can be a convenient constructor to use when the member lists are prebuilt ahead of time with a common ReadWriteLock and it is desirable to compose their union with a CompositeList.

Parameters:
lock - the ReadWriteLock to use within the CompositeList

CompositeList

public CompositeList(ListEventPublisher publisher,
                     ReadWriteLock lock)
Create a CompositeList that uses the given publisher and lock. Note that this publisher and lock will also be used when building new member lists.

This can be a convenient constructor to use when the member lists are prebuilt ahead of time with a common ListEventPublisher and ReadWriteLock and it is desirable to compose their union with a CompositeList.

Parameters:
publisher - the ListEventPublisher to use within the CompositeList
lock - the ReadWriteLock to use within the CompositeList
Method Detail

addMemberList

public void addMemberList(EventList<E> list)
Adds the specified EventList as a source to this CompositeList.

To ensure correct behaviour when this CompositeList is used by multiple threads, the specified EventList has to share the same ReadWriteLock and ListEventPublisher with this CompositeList.

Throws:
IllegalArgumentException - if the specified EventList uses a different ReadWriteLock or ListEventPublisher
See Also:
createMemberList()

createMemberList

public <E> EventList<E> createMemberList()
Creates a new EventList that shares its ReadWriteLock with this CompositeList. This is necessary when this CompositeList will be used by multiple threads.

Note that the created EventList must be explicitly added as a member to this CompositeList using addMemberList(EventList).


removeMemberList

public void removeMemberList(EventList<E> list)
Removes the specified EventList as a source EventList to this CompositeList.



Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.