Class ArraySparseSet<T>

  • All Implemented Interfaces:
    Iterable<T>, FlowSet<T>
    Direct Known Subclasses:
    MonitorSet

    public class ArraySparseSet<T>
    extends AbstractFlowSet<T>
    Reference implementation for a FlowSet. Items are stored in an Array.
    • Field Detail

      • numElements

        protected int numElements
      • maxElements

        protected int maxElements
      • elements

        protected T[] elements
    • Constructor Detail

      • ArraySparseSet

        public ArraySparseSet()
    • Method Detail

      • size

        public int size()
        Description copied from interface: FlowSet
        Returns the size of the current FlowSet.
        Specified by:
        size in interface FlowSet<T>
        Specified by:
        size in class AbstractFlowSet<T>
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: FlowSet
        Returns true if this FlowSet is the empty set.
        Specified by:
        isEmpty in interface FlowSet<T>
        Specified by:
        isEmpty in class AbstractFlowSet<T>
      • remove

        public void remove​(int idx)
      • union

        public void union​(FlowSet<T> otherFlow,
                          FlowSet<T> destFlow)
        Description copied from interface: FlowSet
        Returns the union (join) of this FlowSet and other, putting result into dest. dest, other and this could be the same object.
        Specified by:
        union in interface FlowSet<T>
        Overrides:
        union in class AbstractFlowSet<T>
      • intersection

        public void intersection​(FlowSet<T> otherFlow,
                                 FlowSet<T> destFlow)
        Description copied from interface: FlowSet
        Returns the intersection (meet) of this FlowSet and other, putting result into dest. dest, other and this could be the same object.
        Specified by:
        intersection in interface FlowSet<T>
        Overrides:
        intersection in class AbstractFlowSet<T>
      • difference

        public void difference​(FlowSet<T> otherFlow,
                               FlowSet<T> destFlow)
        Description copied from interface: FlowSet
        Returns the set difference (this intersect ~other) of this FlowSet and other, putting result into dest. dest, other and this could be the same object.
        Specified by:
        difference in interface FlowSet<T>
        Overrides:
        difference in class AbstractFlowSet<T>
      • contains

        @Deprecated
        public boolean contains​(Object obj)
        Deprecated.
        This method uses linear-time lookup. For better performance, consider using a HashSet instead, if you require this operation.
        Description copied from interface: FlowSet
        Returns true if this FlowSet contains obj.
        Specified by:
        contains in interface FlowSet<T>
        Specified by:
        contains in class AbstractFlowSet<T>
      • copyFreshToExisting

        public void copyFreshToExisting​(FlowSet<T> destFlow)
        Description copied from interface: FlowSet
        Copies a *fresh* copy of this to dest. The input (this) is not referenced somewhere else. This allows subclasses for a smarter and faster copying.
      • iterator

        public Iterator<T> iterator()
        Description copied from interface: FlowSet
        returns an iterator over the elements of the flowSet. Note that the iterator might be backed, and hence be faster in the creation, than doing toList().iterator().
        Specified by:
        iterator in interface FlowSet<T>
        Specified by:
        iterator in interface Iterable<T>
        Specified by:
        iterator in class AbstractFlowSet<T>