Class SoftTreeSet<E>

  • Type Parameters:
    E - is the type of the values.
    All Implemented Interfaces:
    Iterable<E>, Collection<E>, Set<E>

    public class SoftTreeSet<E>
    extends AbstractReferencedSet<E,​ComparableSoftReference<E>>
    A Set implementation with soft values. An entry in a SoftTreeSet will automatically be removed when its value is no longer in ordinary use or null.

    This class was inspirated from WeakHashMap and uses a TreeSet as its internal data structure.

    This class has a special flag which permits to control the way how the released references are expurged: AbstractReferencedSet.isDeeplyExpurge(), AbstractReferencedSet.setDeeplyExpurge(boolean). If this flag is true, all the released references will be immediately removed from the map even if they are not enqueued by the virtual machine (see AbstractReferencedSet.expurge(). If this flag is false, only the enqueued references will be removed from the map (see AbstractReferencedSet.expurgeQueuedReferences().

    If this map does not use a "deep expurge" of the released references, it could contains null values that corresponds to values that are released by the garbage collector. If a "deep expurge" is used, all the values released by the garbage collector will be removed from the map.

    "Deep expurge" consumes much more time that "No deep expurge". This is the reason why this feature is not activated by default.

    The "deep expurge" feature was added to fix the uncoherent behavior of the garbage collector which seems to not always enqueued the released values (sometimes the queue is empty even if a value was released).

    Since:
    5.9
    Version:
    17.0 2020-01-04 14:41:38
    Author:
    Stéphane GALLAND
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    references
    • Constructor Detail

      • SoftTreeSet

        public SoftTreeSet()
        Constructs an empty TreeSet.
      • SoftTreeSet

        public SoftTreeSet​(Collection<? extends E> collection)
        Constructs a new tree set containing the elements in the specified collection, sorted according to the natural ordering of its elements. All elements inserted into the set must implement the Comparable interface. Furthermore, all such elements must be mutually comparable: e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the set.
        Parameters:
        collection - collection whose elements will comprise the new set
        Throws:
        ClassCastException - if the elements in c are not Comparable, or are not mutually comparable
        NullPointerException - if the specified collection is null
      • SoftTreeSet

        public SoftTreeSet​(SortedSet<? extends E> set)
        Constructs a new tree set containing the same elements and using the same ordering as the specified sorted set.
        Parameters:
        set - sorted set whose elements will comprise the new set
        Throws:
        NullPointerException - if the specified sorted set is null
      • SoftTreeSet

        public SoftTreeSet​(Comparator<? super E> comparator)
        Constructs a new, empty tree set, sorted according to the specified comparator. All elements inserted into the set must be mutually comparable by the specified comparator: comparator.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the set. If the user attempts to add an element to the set that violates this constraint, the add call will throw a ClassCastException.
        Parameters:
        comparator - the comparator that will be used to order this set. If null, the natural ordering of the elements will be used.