Package ghidra.util.datastruct
Class IntArrayList
- java.lang.Object
-
- ghidra.util.datastruct.IntArrayList
-
- All Implemented Interfaces:
Saveable
,java.io.Serializable
public class IntArrayList extends java.lang.Object implements java.io.Serializable, Saveable
An ArrayList type object for ints.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
MIN_SIZE
-
Constructor Summary
Constructors Constructor Description IntArrayList()
Creates new intArrayListIntArrayList(int[] arr)
Creates a new intArrayList using the values in the given array
-
Method Summary
All Methods Instance Methods Concrete Methods 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 indexvoid
clear()
Clears the entire array of data.int
get(int index)
Returns the int at the given indexjava.lang.Class<?>[]
getObjectStorageFields()
Returns the field classes, in Java types, in the same order as usedSaveable.save(ghidra.util.ObjectStorage)
andSaveable.restore(ghidra.util.ObjectStorage)
.int
getSchemaVersion()
Get the storage schema version.boolean
isPrivate()
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
size()
Returns the size of this virtual array.int[]
toArray()
Converts to a primitive array.boolean
upgrade(ObjectStorage oldObjStorage, int oldSchemaVersion, ObjectStorage currentObjStorage)
Upgrade an older stored object to the current storage schema.
-
-
-
Field Detail
-
MIN_SIZE
public static final int MIN_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
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:
java.lang.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:
java.lang.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:
java.lang.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.
-
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 interfaceSaveable
- Parameters:
objStorage
- Object that can handle Java primitives, Strings, and arrays of primitives and Strings- See Also:
Saveable.restore(ObjectStorage)
-
save
public void save(ObjectStorage objStorage)
Description copied from interface:Saveable
Save to the given ObjectStorage.- Specified by:
save
in interfaceSaveable
- Parameters:
objStorage
- Object that can handle Java primitives, Strings, and arrays of primitives and Strings- See Also:
Saveable.save(ObjectStorage)
-
getObjectStorageFields
public java.lang.Class<?>[] getObjectStorageFields()
Description copied from interface:Saveable
Returns the field classes, in Java types, in the same order as usedSaveable.save(ghidra.util.ObjectStorage)
andSaveable.restore(ghidra.util.ObjectStorage)
.For example, if the save method calls
objStorage.putInt()
and thenobjStorage.putFloat()
, then this method must returnClass[]{ Integer.class, Float.class }
.- Specified by:
getObjectStorageFields
in interfaceSaveable
- 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 interfaceSaveable
- Returns:
- storage schema version.
- See Also:
Saveable.getSchemaVersion()
-
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 interfaceSaveable
- Returns:
- true if upgrading is supported for the older schema version.
- See Also:
Saveable.isUpgradeable(int)
-
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 interfaceSaveable
- Parameters:
oldObjStorage
- the old stored objectoldSchemaVersion
- storage schema version number for the old objectcurrentObjStorage
- new object for storage in the current schema- Returns:
- true if data was upgraded to the currentObjStorage successfully.
- See Also:
Saveable.upgrade(ghidra.util.ObjectStorage, int, ghidra.util.ObjectStorage)
-
-