Interface XGettingCollection<E>

    • Method Detail

      • get

        E get()
        Gets one element from the collection. If the collection is not ordered XGettingSequence, then it is undefined which element is returned. If the collection is ordered, the element at index 0 is returned.
        Returns:
        the first / any element.
      • toArray

        default Object[] toArray()
      • toArray

        default E[] toArray​(Class<E> type)
      • hasVolatileElements

        boolean hasVolatileElements()
        Tells if this collection contains volatile elements.
        An element is volatile, if it can become no longer reachable by the collection without being removed from the collection. Examples are WeakReference of SoftReference or implementations of collection entries that remove the element contained in an entry by some means outside the collection.
        Note that WeakReference instances that are added to a a simple (non-volatile) implementation of a collection do NOT make the collection volatile, as the elements themselves (the reference instances) are still strongly referenced.
        Specified by:
        hasVolatileElements in interface ExtendedCollection<E>
        Returns:
        true if the collection contains volatile elements.
      • size

        long size()
        Specified by:
        size in interface Sized
      • intSize

        default int intSize()
      • equals

        boolean equals​(XGettingCollection<? extends E> samples,
                       Equalator<? super E> equalator)
        Returns true if the passed collection is of the same type as this collection andthis.equalsContent(list, equalator) yields true.
        Parameters:
        equalator -
      • equalsContent

        boolean equalsContent​(XGettingCollection<? extends E> samples,
                              Equalator<? super E> equalator)
        Returns true if all elements of this list and the passed list are sequentially equal as defined by the passed equalator.

        Note that for colletion types that don't have a defined order of elements, this method is hardly usable (as is equals(Object) for them as defined in Collection). The core problem of comparing collections that have no defined order is that they aren't really reliably comparable to any other collection.

        Parameters:
        equalator - the equalator to use to determine the equality of each element
        Returns:
        true if this list is equal to the passed list, false otherwise
      • immure

        XImmutableCollection<E> immure()
        Provides an instance of an immutable collection type with equal behavior and data as this instance.

        If this instance already is of an immutable collection type, it returns itself.

        Returns:
        an immutable copy of this collection instance.
      • copy

        XGettingCollection<E> copy()
        Creates a true copy of this collection which references the same elements as this collection does at the time the method is called. The elements themselves are NOT copied (no deep copying).
        The type of the returned set is the same as of this list if possible.
        Specified by:
        copy in interface Copyable
        Returns:
        a copy of this list
      • nullContained

        boolean nullContained()
      • containsId

        boolean containsId​(E element)
        Special version of contains() that guarantees to use identity comparison (" == ") when searching for the given element regardless of the collection's internal logic.
        This method has the same behavior as containsSearched(Predicate) with a Predicate implementation that checks for object identity. The only difference is a performance and usability advantage
        Parameters:
        element - the element to be searched in the collection by identity.
        Returns:
        whether this collection contains exactely the given element.
      • contains

        boolean contains​(E element)
      • containsSearched

        boolean containsSearched​(Predicate<? super E> predicate)
      • applies

        boolean applies​(Predicate<? super E> predicate)
      • count

        long count​(E element)
      • countBy

        long countBy​(Predicate<? super E> predicate)
      • seek

        E seek​(E sample)
        Returns the first contained element matching the passed sample as defined by the collection's equality logic or null, if no fitting element is contained. (For collections using referential equality, this method is basically just a variation of contains(Object) with a different return type. For collections with data-dependant equality, the returned element might be the same as the passed one or a data-wise equal one, depending on the content of the collection)
        Parameters:
        sample -
      • distinct

        <T extends Consumer<? super E>> T distinct​(T target)
      • distinct

        <T extends Consumer<? super E>> T distinct​(T target,
                                                   Equalator<? super E> equalator)
      • copyTo

        <T extends Consumer<? super E>> T copyTo​(T target)
      • filterTo

        <T extends Consumer<? super E>> T filterTo​(T target,
                                                   Predicate<? super E> predicate)
      • join

        default <A> A join​(BiConsumer<? super E,​? super A> joiner,
                           A aggregate)
        Specified by:
        join in interface XJoinable<E>
      • equals

        @Deprecated
        boolean equals​(Object o)
        Deprecated.
        Performs an equality comparison according to the specification in Collection.

        Note that it is this interface's author opinion that the whole concept of equals() in standard Java, especially in the collection implementations, is flawed.
        The reason is because all different kinds of comparison types that actually depend on the situation have to be mixed up in a harcoded fashion in one method, from identity comparison over data indentity comparison to content comparison.
        In order to get the right behavior in every situation, one has to distinct between different types of equality

        This means several things:
        1.) You can't just say for example an ArrayList is the "same" as a LinkedList just because they contain the same content.
        There are different implementations for a good reason, so you have to distinct them when comparing. There are simple code examples which create massive misbehavior that will catastrophically ruin the runtime behavior of a programm due to this error in Java / JDK / Sun / whatever.
        2.) You can't always determine equality of two collections by determining equality of each element as Collection defines it.

        As a conclusion: don't use this method!
        Be clear what type of comparison you really need, then use one of the following methods and proper comparators:
        equals(XGettingCollection,Equalator)
        equalsContent(XGettingCollection,Equalator)

        Overrides:
        equals in class Object
        Parameters:
        o -