Class FixedSizeList

java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.util.FixedSizeList
All Implemented Interfaces:
ToHuman
Direct Known Subclasses:
AnnotationsList, BootstrapMethodArgumentsList, BootstrapMethodsList, ByteCatchList, CatchHandlerList, CatchTable, CstArray.List, DalvInsnList, InnerClassList, InsnList, LabeledList, LineNumberList, LocalList, LocalVariableList, PositionList, RegisterSpecList, StdAttributeList, StdFieldList, StdMethodList, StdTypeList

public class FixedSizeList extends MutabilityControl implements ToHuman
Simple (mostly) fixed-size list of objects, which may be made immutable.
  • Constructor Details

    • FixedSizeList

      public FixedSizeList(int size)
      Constructs an instance. All indices initially contain null.
      Parameters:
      size - the size of the list
  • Method Details

    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toHuman

      public String toHuman()
      Return the "human" string form of this instance. This is generally less "debuggy" than toString(). This method will only work if every element of the list implements ToHuman.
      Specified by:
      toHuman in interface ToHuman
      Returns:
      non-null; the human string form
    • toString

      public String toString(String prefix, String separator, String suffix)
      Gets a customized string form for this instance.
      Parameters:
      prefix - null-ok; prefix for the start of the result
      separator - null-ok; separator to insert between each item
      suffix - null-ok; suffix for the end of the result
      Returns:
      non-null; the custom string
    • toHuman

      public String toHuman(String prefix, String separator, String suffix)
      Gets a customized human string for this instance. This method will only work if every element of the list implements ToHuman.
      Parameters:
      prefix - null-ok; prefix for the start of the result
      separator - null-ok; separator to insert between each item
      suffix - null-ok; suffix for the end of the result
      Returns:
      non-null; the custom string
    • size

      public final int size()
      Gets the number of elements in this list.
    • shrinkToFit

      public void shrinkToFit()
      Shrinks this instance to fit, by removing any unset (null) elements, leaving the remaining elements in their original order.
    • get0

      protected final Object get0(int n)
      Gets the indicated element. It is an error to call this with the index for an element which was never set; if you do that, this will throw NullPointerException. This method is protected so that subclasses may offer a safe type-checked public interface to their clients.
      Parameters:
      n - >= 0, < size(); which element
      Returns:
      non-null; the indicated element
    • getOrNull0

      protected final Object getOrNull0(int n)
      Gets the indicated element, allowing nulls to be returned. This method is protected so that subclasses may (optionally) offer a safe type-checked public interface to their clients.
      Parameters:
      n - >= 0, < size(); which element
      Returns:
      null-ok; the indicated element
    • set0

      protected final void set0(int n, Object obj)
      Sets the element at the given index, but without doing any type checks on the element. This method is protected so that subclasses may offer a safe type-checked public interface to their clients.
      Parameters:
      n - >= 0, < size(); which element
      obj - null-ok; the value to store