public short append(short listID) {
        if ((listID < 0) || (listID >= numLists)) {
            throw new IndexOutOfBoundsException();
        }

        short index = allocate();
        if (index >= 0) {
            if (heads[listID] == END_OF_LIST) {
                heads[listID] = index;
            }
            else {
                short p = heads[listID];
                while(links[p] != END_OF_LIST) {
                    p = links[p];
                }
                links[p] = index;
            }
        }
        return index;
    }
Allocates a new index resource and adds it to the end of the linked list
indexed by listID.
@param listID the id of the list to add to.
@exception IndexOutOfBoundsException thrown if the listID is not in the
the range [0, numLists).
Ghidra/Framework/Generic/src/main/java/ghidra/util/datastruct/ShortListIndexer.java