Package ghidra.util.datastruct

# Class ShortListIndexer

java.lang.Object
ghidra.util.datastruct.ShortListIndexer

All Implemented Interfaces:
  `Serializable`

public class ShortListIndexer extends Object implements Serializable
Class to manage multiple linked lists of short 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:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ShortListIndexer(short numLists, short capacity)`
  The constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `short`
  `add(short listID)`
  Allocates a new index resource and adds it to the front of the linked list indexed by listID.
  `short`
  `append(short 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 short`
  `first(short listID)`
  Returns the first index resource on the linked list indexed by listID.
  `short`
  `getCapacity()`
  Returns the current index capacity.
  `int`
  `getListSize(short listID)`
  Returns the number of indexes in the specified list.
  `short`
  `getNewCapacity()`
  Computes the next size that should be used to grow the index capacity.
  `short`
  `getNumLists()`
  Returns the number of linked list being managed.
  `short`
  `getSize()`
  Returns the current number of used index resources.
  `void`
  `growCapacity(short newCapacity)`
  Increases the index resource pool.
  `void`
  `growNumLists(short newListSize)`
  Increases the number of managed linked lists.
  `final short`
  `next(short index)`
  Returns the next index resource that follows the given index in a linked list.
  `void`
  `remove(short listID, short index)`
  Remove the index resource from the linked list indexed by listID.
  `void`
  `removeAll(short listID)`
  Removes all indexes from the specified list.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ShortListIndexer

    public ShortListIndexer(short numLists, short 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 short add(short 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 short append(short 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(short listID, short 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(short listID)
    Removes all indexes from the specified list.
    Parameters:
      `listID` - the list to be emptied.

  - ### getNewCapacity

    public short getNewCapacity()
    Computes the next size that should be used to grow the index capacity.

  - ### getSize

    public short getSize()
    Returns the current number of used index resources.

  - ### getCapacity

    public short getCapacity()
    Returns the current index capacity.

  - ### getNumLists

    public short getNumLists()
    Returns the number of linked list being managed.

  - ### next

    public final short next(short 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` - to search after to find the next index.
    Throws:
      `IndexOutOfBoundsException` - thrown if the index is not in the the range [0, capacity].

  - ### first

    public final short first(short 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(short 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(short 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(short listID)
    Returns the number of indexes in the specified list.
    Throws:
      `IndexOutOfBoundsException` - thrown if the listID is not in the the range [0, numLists).