Class ZArrayNumberer<E extends Numberable>

  • All Implemented Interfaces:
    Iterable<E>, IterableNumberer<E>, Numberer<E>

    public class ZArrayNumberer<E extends Numberable>
    extends Object
    implements IterableNumberer<E>, Iterable<E>
    Similar to the ArrayNumberer class in soot. But, this class counts the objects from zero. And, we permit the deletion of objects from the array container. And most importantly, we permits the search for a particular object efficiently. Therefore, this class supports efficiently insert, lookup, deletion and traversal queries.
    Author:
    xiao
    • Constructor Detail

      • ZArrayNumberer

        public ZArrayNumberer()
      • ZArrayNumberer

        public ZArrayNumberer​(int initSize)
    • Method Detail

      • add

        public void add​(E o)
        Description copied from interface: Numberer
        Tells the numberer that a new object needs to be assigned a number.
        Specified by:
        add in interface Numberer<E extends Numberable>
      • clear

        public void clear()
        Clear the reference to the objects to help the garbage collection
      • get

        public long get​(E o)
        Input object o should be added to this container previously.
        Specified by:
        get in interface Numberer<E extends Numberable>
      • get

        public E get​(long number)
        Description copied from interface: Numberer
        Should return the object that was assigned the number number.
        Specified by:
        get in interface Numberer<E extends Numberable>
      • searchFor

        public E searchFor​(E o)
        Input object o is not required to be an object added previously.
        Parameters:
        o -
        Returns:
      • remove

        public boolean remove​(E o)
        Description copied from interface: Numberer
        Removes the number for a given object.
        Specified by:
        remove in interface Numberer<E extends Numberable>
        Parameters:
        o - the element
        Returns:
        true if the removal was successful, false when not
      • size

        public int size()
        Return how many objects are in the container but not the capacity of the container.
        Specified by:
        size in interface Numberer<E extends Numberable>
      • reassign

        public void reassign()
        The removed objects cause some empty slots. We shift the objects to the empty slots in order to ensure ids of the objects are less than the filledCells.