Package ghidra.util.datastruct
Class IntArrayList
java.lang.Object
ghidra.util.datastruct.IntArrayList
- All Implemented Interfaces:
Saveable
,Serializable
An ArrayList type object for ints.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates new intArrayListIntArrayList
(boolean useZeroSize) IntArrayList
(int[] arr) Creates a new intArrayList using the values in the given array -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 indexClass<?>[]
Returns the field classes, in Java types, in the same order as usedSaveable.save(ghidra.util.ObjectStorage)
andSaveable.restore(ghidra.util.ObjectStorage)
.int
Get the storage schema version.boolean
isEmpty()
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
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 Details
-
MIN_SIZE
public static final int MIN_SIZE- See Also:
-
-
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
Description copied from interface:Saveable
Restore from the given ObjectStorage. -
save
Description copied from interface:Saveable
Save to the given ObjectStorage. -
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:
-
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
- 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 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:
-
isPrivate
public boolean isPrivate()Description copied from interface:Saveable
Returns true if this saveable should not have it's changes broadcast.
-