Class AbstractKFList<T>

  • All Implemented Interfaces:
    FeatureStateListener, Iterable<T>, Collection<T>
    Direct Known Subclasses:
    KFList, KFList2

    public abstract class AbstractKFList<T>
    extends Object
    implements Collection<T>, FeatureStateListener
    Implementation of a Collection with multi-context support.

    This class can only be embedded in Kernel code. It cannot be embedded into Feature code.

    This collection does not allow to pass null elements.

    The semantic is the following:

    • Each context has its dedicated list, acting as an ArrayList.
    • A Feature can add Feature or Kernel objects to its list.
    • The Kernel can only add Kernel objects to its list. However it has the full control and visibility on all the elements of the collection. For example, the call of the Collection.clear() method clears the whole collection. The call to Collection.iterator() method return an iterator on all objects of the collection...

    See Also:
    KFList, KFList2
    • Constructor Detail

      • AbstractKFList

        public AbstractKFList()
    • Method Detail

      • addAll

        public boolean addAll​(Collection<? extends T> c)
        Description copied from interface: Collection
        Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.)
        Specified by:
        addAll in interface Collection<T>
        Parameters:
        c - collection containing elements to be added to this collection
        Returns:
        true if this collection changed as a result of the call
        See Also:
        Collection.add(Object)
      • containsAll

        public boolean containsAll​(Collection<?> c)
        Description copied from interface: Collection
        Returns true if this collection contains all of the elements in the specified collection.
        Specified by:
        containsAll in interface Collection<T>
        Parameters:
        c - collection to be checked for containment in this collection
        Returns:
        true if this collection contains all of the elements in the specified collection
        See Also:
        Collection.contains(Object)
      • removeAll

        public boolean removeAll​(Collection<?> c)
        Description copied from interface: Collection
        Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.
        Specified by:
        removeAll in interface Collection<T>
        Parameters:
        c - collection containing elements to be removed from this collection
        Returns:
        true if this collection changed as a result of the call
        See Also:
        Collection.remove(Object), Collection.contains(Object)
      • retainAll

        public boolean retainAll​(Collection<?> c)
        Description copied from interface: Collection
        Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.
        Specified by:
        retainAll in interface Collection<T>
        Parameters:
        c - collection containing elements to be retained in this collection
        Returns:
        true if this collection changed as a result of the call
        See Also:
        Collection.remove(Object), Collection.contains(Object)
      • toArray

        public Object[] toArray()
        Description copied from interface: Collection
        Returns an array containing all of the elements in this collection. If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

        The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.

        This method acts as bridge between array-based and collection-based APIs.

        Specified by:
        toArray in interface Collection<T>
        Returns:
        an array containing all of the elements in this collection
      • toArray

        public <E> E[] toArray​(E[] a)
        Description copied from interface: Collection
        Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.

        If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.)

        If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

        Like the Collection.toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

        Suppose x is a collection known to contain only strings. The following code can be used to dump the collection into a newly allocated array of String:

         String[] y = x.toArray(new String[0]);
         
        Note that toArray(new Object[0]) is identical in function to toArray().
        Specified by:
        toArray in interface Collection<T>
        Type Parameters:
        E - the runtime type of the array to contain the collection
        Parameters:
        a - the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
        Returns:
        an array containing all of the elements in this collection
      • removeAllElementsOwnedBy

        protected abstract void removeAllElementsOwnedBy​(Feature feature)
        Removed all elements owned by the given Feature.
        Parameters:
        feature - the owner of the elements to be removed
      • toArray

        protected abstract void toArray​(ArrayList<T> allList)
        Add all the elements of the collection to the given ArrayList.
        Parameters:
        allList - the list where all elements are added.