Package ghidra.util.datastruct
Class IntListIndexer
java.lang.Object
ghidra.util.datastruct.IntListIndexer
- All Implemented Interfaces:
Serializable
Class to manage multiple linked lists of int indexes. Users can add indexes
to a list, remove indexes from a list, remove all indexes from a list, and
retrieve all indexes within a given list.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
add
(int listID) Allocates a new index resource and adds it to the front of the linked list indexed by listID.int
append
(int listID) Allocates a new index resource and adds it to the end of the linked list indexed by listID.void
clear()
Removes all indexes from all lists.final int
first
(int listID) Returns the first index resource on the linked list indexed by listID.int
Returns the current index capacity.int
getListSize
(int listID) Returns the number of indexes in the specified list.int
Computes the next size that should be used to grow the index capacity.int
Returns the number of linked list being managed.int
getSize()
Returns the current number of used index resources.void
growCapacity
(int newCapacity) Increases the index resource pool.void
growNumLists
(int newListSize) Increases the number of managed linked lists.final int
next
(int index) Returns the next index resource that follows the given index in a linked list.void
remove
(int listID, int index) Remove the index resource from the linked list indexed by listID.void
removeAll
(int listID) Removes all indexes from the specified list.
-
Constructor Details
-
IntListIndexer
public IntListIndexer(int numLists, int capacity) The constructor- Parameters:
numLists
- - The initial number of lists to be managed.capacity
- - The current size of the pool of possible indexes. All indexes begin on the free list.
-
-
Method Details
-
add
public int add(int listID) Allocates a new index resource and adds it to the front of the linked list indexed by listID.- Parameters:
listID
- the id of the list to add to.- Throws:
IndexOutOfBoundsException
- thrown if the listID is not in the the range [0, numLists).
-
append
public int append(int listID) Allocates a new index resource and adds it to the end of the linked list indexed by listID.- Parameters:
listID
- the id of the list to add to.- Throws:
IndexOutOfBoundsException
- thrown if the listID is not in the the range [0, numLists).
-
remove
public void remove(int listID, int index) Remove the index resource from the linked list indexed by listID.- Parameters:
listID
- the id of the list from which to removed the value at index.index
- the index of the value to be removed from the specified list.- Throws:
IndexOutOfBoundsException
- thrown if the listID is not in the the range [0, numLists).
-
removeAll
public void removeAll(int listID) Removes all indexes from the specified list.- Parameters:
listID
- the list to be emptied.
-
getNewCapacity
public int getNewCapacity()Computes the next size that should be used to grow the index capacity. -
getSize
public int getSize()Returns the current number of used index resources. -
getCapacity
public int getCapacity()Returns the current index capacity. -
getNumLists
public int getNumLists()Returns the number of linked list being managed. -
next
public final int next(int index) Returns the next index resource that follows the given index in a linked list. The index should be an index that is in some linked list. Otherwise, the results are undefined( probably give you the next index on the free list )- Parameters:
index
- the index to search after for the next index.- Throws:
IndexOutOfBoundsException
- thrown if the index is not in the the range [0, capacity].
-
first
public final int first(int listID) Returns the first index resource on the linked list indexed by listID.- Throws:
IndexOutOfBoundsException
- thrown if the listID is not in the the range [0, numLists].
-
growCapacity
public void growCapacity(int newCapacity) Increases the index resource pool.- Parameters:
newCapacity
- the new number of resource indexes to manage. if this number is smaller than the current number of resource indexes, then nothing changes.
-
growNumLists
public void growNumLists(int newListSize) Increases the number of managed linked lists.- Parameters:
newListSize
- the new number of linked lists. If this number is smaller than the current number of linked lists, then nothing changes.
-
clear
public void clear()Removes all indexes from all lists. -
getListSize
public int getListSize(int listID) Returns the number of indexes in the specified list.- Parameters:
listID
- the id of the list from which to get the number of indexes.- Throws:
IndexOutOfBoundsException
- thrown if the listID is not in the the range [0, numLists).
-