Class AionSet<E>

  • Type Parameters:
    E - The type of elements within the set.
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

    public class AionSet<E>
    extends java.lang.Object
    implements java.util.Set<E>
    A simple Set implementation.

    This implementation is build directly on top of AionMap.

    • Constructor Summary

      Constructors 
      Constructor Description
      AionSet()
      Constructs a new, empty set; the backing AionMap instance has default order(4).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E e)
      Adds the specified element to this set if it is not already present.
      boolean addAll​(java.util.Collection<? extends E> c)
      This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.
      void clear()
      Removes all of the elements from this set.
      boolean contains​(java.lang.Object o)
      Returns true if this set contains the specified element.
      boolean containsAll​(java.util.Collection<?> c)
      This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection.
      boolean isEmpty()
      Returns true if this set contains no elements.
      java.util.Iterator<E> iterator()
      Returns an iterator over the elements in this set.
      boolean remove​(java.lang.Object o)
      Removes the specified element from this set if it is present.
      boolean removeAll​(java.util.Collection<?> c)  
      boolean retainAll​(java.util.Collection<?> c)  
      int size()
      Returns the number of elements in this set (its cardinality).
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] a)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        equals, hashCode, spliterator
    • Constructor Detail

      • AionSet

        public AionSet()
        Constructs a new, empty set; the backing AionMap instance has default order(4).
    • Method Detail

      • size

        public int size()
        Returns the number of elements in this set (its cardinality).
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.Set<E>
        Returns:
        the number of elements in this set (its cardinality)
      • isEmpty

        public boolean isEmpty()
        Returns true if this set contains no elements.
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface java.util.Set<E>
        Returns:
        true if this set contains no elements
      • contains

        public boolean contains​(java.lang.Object o)
        Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.Set<E>
        Parameters:
        o - element whose presence in this set is to be tested
        Returns:
        true if this set contains the specified element
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.Set<E>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.Set<E>
      • add

        public boolean add​(E e)
        Adds the specified element to this set if it is not already present. More formally, adds the specified element e to this set if this set contains no element e2 such that Objects.equals(e, e2). If this set already contains the element, the call leaves the set unchanged and returns false.
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.Set<E>
        Parameters:
        e - element to be added to this set
        Returns:
        true if this set did not already contain the specified element
      • remove

        public boolean remove​(java.lang.Object o)
        Removes the specified element from this set if it is present. More formally, removes an element e such that Objects.equals(o, e), if this set contains such an element. Returns true if this set contained the element (or equivalently, if this set changed as a result of the call). (This set will not contain the element once the call returns.)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.Set<E>
        Parameters:
        o - object to be removed from this set, if present
        Returns:
        true if the set contained the specified element
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. If all elements are so contained true is returned, otherwise false.
        Specified by:
        containsAll in interface java.util.Collection<E>
        Specified by:
        containsAll in interface java.util.Set<E>
        See Also:
        contains(Object)
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> c)
        This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface java.util.Set<E>
        See Also:
        add(Object)
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<E>
        Specified by:
        retainAll in interface java.util.Set<E>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface java.util.Set<E>
      • clear

        public void clear()
        Removes all of the elements from this set. The set will be empty after this call returns.
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.Set<E>
      • iterator

        public java.util.Iterator<E> iterator()
        Returns an iterator over the elements in this set. The elements are returned in no particular order.
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.Set<E>
        Returns:
        an Iterator over the elements in this set