Class IntArrayList

java.lang.Object
ghidra.util.datastruct.IntArrayList
All Implemented Interfaces:
Saveable, Serializable

public class IntArrayList extends Object implements Serializable, Saveable
An ArrayList type object for ints.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates new intArrayList
    IntArrayList(boolean useZeroSize)
     
    IntArrayList(int[] arr)
    Creates a new intArrayList using the values in the given array
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int value)
    Adds a new int value at the end of the list.
    void
    add(int index, int value)
    Puts the given int value in the int array at the given index
    void
    Clears the entire array of data.
    int
    get(int index)
    Returns the int at the given index
    Class<?>[]
    Returns the field classes, in Java types, in the same order as used Saveable.save(ghidra.util.ObjectStorage) and Saveable.restore(ghidra.util.ObjectStorage).
    int
    Get the storage schema version.
    boolean
     
    boolean
    Returns true if this saveable should not have it's changes broadcast.
    boolean
    isUpgradeable(int oldSchemaVersion)
    Determine if the implementation supports an storage upgrade of the specified oldSchemaVersion to the current schema version.
    void
    removeValue(int value)
    Removes the first occurrence of the given value.
    void
    removeValueAt(int index)
    Removes the value at the given index decreasing the array list size by 1.
    void
    restore(ObjectStorage objStorage)
    Restore from the given ObjectStorage.
    void
    save(ObjectStorage objStorage)
    Save to the given ObjectStorage.
    void
    set(int index, int value)
    Sets the array value at index to value.
    int
    Returns the size of this virtual array.
    int[]
    Converts to a primitive array.
    boolean
    upgrade(ObjectStorage oldObjStorage, int oldSchemaVersion, ObjectStorage currentObjStorage)
    Upgrade an older stored object to the current storage schema.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • IntArrayList

      public IntArrayList()
      Creates new intArrayList
    • IntArrayList

      public IntArrayList(boolean useZeroSize)
    • IntArrayList

      public IntArrayList(int[] arr)
      Creates a new intArrayList using the values in the given array
      Parameters:
      arr - array of ints to initialize to.
  • Method Details

    • add

      public void add(int value)
      Adds a new int value at the end of the list.
      Parameters:
      value - the int value to add.
    • add

      public void add(int index, int value)
      Puts the given int value in the int array at the given index
      Parameters:
      index - Index into the array.
      value - value to store
      Throws:
      IndexOutOfBoundsException - if the index is negative OR index > size
    • removeValueAt

      public void removeValueAt(int index)
      Removes the value at the given index decreasing the array list size by 1.
      Parameters:
      index - the index to remove.
      Throws:
      IndexOutOfBoundsException - if the index is negative
    • removeValue

      public void removeValue(int value)
      Removes the first occurrence of the given value.
      Parameters:
      value - the value to be removed.
    • get

      public int get(int index)
      Returns the int at the given index
      Parameters:
      index - index into the array
      Returns:
      The int value at the given index. A 0 will be returned for any index not initialized to another value.
      Throws:
      IndexOutOfBoundsException - if the index is negative or greater than the list size.
    • set

      public void set(int index, int value)
      Sets the array value at index to value.
      Parameters:
      index - the index to set.
      value - the value to store.
    • clear

      public void clear()
      Clears the entire array of data.
    • size

      public int size()
      Returns the size of this virtual array.
      Returns:
      int the size of this virtual array.
    • isEmpty

      public boolean isEmpty()
    • toArray

      public int[] toArray()
      Converts to a primitive array.
      Returns:
      int[] int array for results.
    • restore

      public void restore(ObjectStorage objStorage)
      Description copied from interface: Saveable
      Restore from the given ObjectStorage.
      Specified by:
      restore in interface Saveable
      Parameters:
      objStorage - Object that can handle Java primitives, Strings, and arrays of primitives and Strings TODO: document how errors should be handled (i.e, exception, null return)
      See Also:
    • save

      public void save(ObjectStorage objStorage)
      Description copied from interface: Saveable
      Save to the given ObjectStorage.
      Specified by:
      save in interface Saveable
      Parameters:
      objStorage - Object that can handle Java primitives, Strings, and arrays of primitives and Strings
      See Also:
    • getObjectStorageFields

      public Class<?>[] getObjectStorageFields()
      Description copied from interface: Saveable
      Returns the field classes, in Java types, in the same order as used Saveable.save(ghidra.util.ObjectStorage) and Saveable.restore(ghidra.util.ObjectStorage).

      For example, if the save method calls objStorage.putInt() and then objStorage.putFloat(), then this method must return Class[]{ Integer.class, Float.class }.

      Specified by:
      getObjectStorageFields in interface Saveable
      Returns:
    • getSchemaVersion

      public int getSchemaVersion()
      Description copied from interface: Saveable
      Get the storage schema version. Any time there is a software release in which the implementing class has changed the data structure used for the save and restore methods, the schema version must be incremented. NOTE: While this could be a static method, the Saveable interface is unable to define such methods.
      Specified by:
      getSchemaVersion in interface Saveable
      Returns:
      storage schema version.
      See Also:
    • isUpgradeable

      public boolean isUpgradeable(int oldSchemaVersion)
      Description copied from interface: Saveable
      Determine if the implementation supports an storage upgrade of the specified oldSchemaVersion to the current schema version.
      Specified by:
      isUpgradeable in interface Saveable
      Parameters:
      oldSchemaVersion -
      Returns:
      true if upgrading is supported for the older schema version.
      See Also:
    • upgrade

      public boolean upgrade(ObjectStorage oldObjStorage, int oldSchemaVersion, ObjectStorage currentObjStorage)
      Description copied from interface: Saveable
      Upgrade an older stored object to the current storage schema.
      Specified by:
      upgrade in interface Saveable
      Parameters:
      oldObjStorage - the old stored object
      oldSchemaVersion - storage schema version number for the old object
      currentObjStorage - new object for storage in the current schema
      Returns:
      true if data was upgraded to the currentObjStorage successfully.
      See Also:
    • isPrivate

      public boolean isPrivate()
      Description copied from interface: Saveable
      Returns true if this saveable should not have it's changes broadcast.
      Specified by:
      isPrivate in interface Saveable
      Returns:
      true if this saveable should not have it's changes broadcast.