Interface ILcdList<T>

All Superinterfaces:
Collection<T>, ILcdCollection<T>, Iterable<T>, List<T>, SequencedCollection<T>
All Known Implementing Classes:
TLcdArrayList

public interface ILcdList<T> extends ILcdCollection<T>, List<T>

An extension of the Java List which fires a TLcdCollectionEvent and TLcdListEvent for every element that is added to or removed from the list.

Due to those events, there is a decrease in performance compared to the traditional List when adding and/or removing multiple elements at once (e.g. addAll(java.util.Collection) or removeAll(java.util.Collection) ). For every element that is added or removed, those methods should fire an individual event. An example implementation for such a method is:

public boolean addAll(Collection<? extends T> aCollection) {
  boolean result = false;
  for (T element : aCollection) {
    result = add(element) || result;
  }
  return result;
}
The firing of events can also be postponed, by means of the methods that take an ILcdFireEventMode parameter. This is useful for example when the list is protected by a read/write lock. In that case, the actual modifications must be performed within the write lock, while the change events are only fired afterwards when the lock has been released, in order to avoid potential deadlocks down the line. For example, as follows:
    try (TLcdLockUtil.Lock writeLock = TLcdLockUtil.writeLock(collection)) {
      collection.add(element, ILcdFireEventMode.FIRE_LATER);
    } finally {
      collection.fireCollectedChanges();
    }
Since:
9.1
See Also: