Class YLongSet


  • public class YLongSet
    extends java.lang.Object
    Set that can hold long primitives.
    • Constructor Summary

      Constructors 
      Constructor Description
      YLongSet()
      Creates an empty set.
      YLongSet​(int initialCapacity)
      Creates an empty set with preallocated initial space for elements.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(long value)
      Adds element to the set.
      boolean contains​(long value)
      Checks if given elements is in the set.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      boolean isEmpty()
      Checks if the set is empty.
      boolean remove​(long value)
      Removes given element from the set.
      int size()
      Returns number of elements in the set.
      long[] toArray()
      Gets all elements from the set as an array.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • YLongSet

        public YLongSet()
        Creates an empty set.
      • YLongSet

        public YLongSet​(int initialCapacity)
        Creates an empty set with preallocated initial space for elements.
        Parameters:
        initialCapacity - initial capacity of the set
    • Method Detail

      • size

        public int size()
        Returns number of elements in the set.
        Returns:
        number of elements in the set
      • add

        public boolean add​(long value)
        Adds element to the set. Can be invoked for the same value multiple times.
        Parameters:
        value - value to add
        Returns:
        returns true if this set changed otherwise false is returned
      • remove

        public boolean remove​(long value)
        Removes given element from the set. Can be invoked for values that don't exist in the set.
        Parameters:
        value - value to remove
        Returns:
        returns true if this set changed otherwise false is returned
      • isEmpty

        public boolean isEmpty()
        Checks if the set is empty.
        Returns:
        true if the set is empty, false if set contains one or more elements
      • toArray

        public long[] toArray()
        Gets all elements from the set as an array. The order of elements in the array is unspecified.
        Returns:
        array with all elements from this set
      • contains

        public boolean contains​(long value)
        Checks if given elements is in the set.
        Parameters:
        value - value to test
        Returns:
        true if value is in the set or false otherwise
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object