Class OrderedSet

  • All Implemented Interfaces:
    Serializable, Iterable, Collection, Set

    public class OrderedSet
    extends AbstractSet
    implements Set, Serializable
    This class extends from AbstractSet. It uses List for storing data so that data is stored in the order input. It overwrites add, iterator and size methods. All other methods it needs are in the base class.
    See Also:
    Serialized Form
    • Field Detail

      • list

        protected List list
    • Constructor Detail

      • OrderedSet

        public OrderedSet()
    • Method Detail

      • add

        public boolean add​(Object o)
        Adds the specified element to this set if it is not already present (optional operation).
        Specified by:
        add in interface Collection
        Specified by:
        add in interface Set
        Overrides:
        add in class AbstractCollection
        Parameters:
        o - Object to be added
      • size

        public int size()
        Returns the number of elements in this set (its cardinality).
        Specified by:
        size in interface Collection
        Specified by:
        size in interface Set
        Specified by:
        size in class AbstractCollection
        Returns:
        the number of elements in this set
      • addAll

        public boolean addAll​(Set s)
        Adds all entries in the given Set to this Set.
      • removeAll

        public void removeAll​(Integer[] array)
        Deletes entries of a given array of indices.
        Parameters:
        array - Array of indices.
      • get

        public Object get​(int index)
        Returns the object of an given index.
        Parameters:
        index - Index of which object resides
      • set

        public void set​(int index,
                        Object value)
        Set value to the list.
        Parameters:
        index - Index of object.
        value - Value of object.