/** * Constructs a new instance that is a copy of the old instance. * * @param old instance to copy */ public LabeledList(LabeledList old) { super(old.size()); labelToIndex = old.labelToIndex.mutableCopy(); int sz = old.size(); for (int i = 0; i < sz; i++) { Object one = old.get0(i); if (one != null) { set0(i, one); } } }
/** * Sets the element at the given index. * * @param n {@code >= 0, < size();} which element * @param bb {@code null-ok;} the value to store */ public void set(int n, ByteBlock bb) { super.set(n, bb); } }
/** * Sets the element at the given index. * * @param n {@code >= 0, < size();} which element * @param item {@code null-ok;} the value to store */ protected void set(int n, LabeledItem item) { LabeledItem old = (LabeledItem) getOrNull0(n); set0(n, item); if (old != null) { removeLabel(old.getLabel()); } if (item != null) { addLabelIndex(item.getLabel(), n); } } }
/** * Rebuilds the label-to-index mapping after a {@code shrinkToFit()}. * Note: This assumes that the labels that are in the list are the * same, although the indicies may have changed. */ private void rebuildLabelToIndex() { int szItems = size(); for (int i = 0; i < szItems; i++) { LabeledItem li = (LabeledItem) get0(i); if (li != null) { labelToIndex.set(li.getLabel(), i); } } }
/** @inheritDoc */ @Override public void shrinkToFit() { super.shrinkToFit(); rebuildLabelToIndex(); }
/** * Sets the element at the given index. * * @param n {@code >= 0, < size();} which element * @param item {@code null-ok;} the value to store */ protected void set(int n, LabeledItem item) { LabeledItem old = (LabeledItem) getOrNull0(n); set0(n, item); if (old != null) { removeLabel(old.getLabel()); } if (item != null) { addLabelIndex(item.getLabel(), n); } } }
/** * Rebuilds the label-to-index mapping after a {@code shrinkToFit()}. * Note: This assumes that the labels that are in the list are the * same, although the indicies may have changed. */ private void rebuildLabelToIndex() { int szItems = size(); for (int i = 0; i < szItems; i++) { LabeledItem li = (LabeledItem) get0(i); if (li != null) { labelToIndex.set(li.getLabel(), i); } } }
/** {@inheritDoc} */ @Override public void shrinkToFit() { super.shrinkToFit(); rebuildLabelToIndex(); }
/** * Sets the element at the given index. * * @param n {@code >= 0, < size();} which element * @param item {@code null-ok;} the value to store */ protected void set(int n, LabeledItem item) { LabeledItem old = (LabeledItem) getOrNull0(n); set0(n, item); if (old != null) { removeLabel(old.getLabel()); } if (item != null) { addLabelIndex(item.getLabel(), n); } } }
/** * Constructs a new instance that is a copy of the old instance. * * @param old instance to copy */ protected LabeledList(LabeledList old) { super(old.size()); labelToIndex = old.labelToIndex.mutableCopy(); int sz = old.size(); for (int i = 0; i < sz; i++) { Object one = old.get0(i); if (one != null) { set0(i, one); } } }
/** * Rebuilds the label-to-index mapping after a {@code shrinkToFit()}. * Note: This assumes that the labels that are in the list are the * same, although the indicies may have changed. */ private void rebuildLabelToIndex() { int szItems = size(); for (int i = 0; i < szItems; i++) { LabeledItem li = (LabeledItem) get0(i); if (li != null) { labelToIndex.set(li.getLabel(), i); } } }
/** * Sets the basic block at the given index. * * @param n {@code >= 0, < size();} which index * @param bb {@code null-ok;} the element to set at {@code n} */ public void set(int n, BasicBlock bb) { super.set(n, bb); // Reset regCount, since it will need to be recalculated. regCount = -1; }
/** @inheritDoc */ @Override public void shrinkToFit() { super.shrinkToFit(); rebuildLabelToIndex(); }
/** * Sets the element at the given index. * * @param n {@code >= 0, < size();} which element * @param item {@code null-ok;} the value to store */ protected void set(int n, LabeledItem item) { LabeledItem old = (LabeledItem) getOrNull0(n); set0(n, item); if (old != null) { removeLabel(old.getLabel()); } if (item != null) { addLabelIndex(item.getLabel(), n); } } }
/** * Constructs a new instance that is a copy of the old instance. * * @param old instance to copy */ public LabeledList(LabeledList old) { super(old.size()); labelToIndex = old.labelToIndex.mutableCopy(); int sz = old.size(); for (int i = 0; i < sz; i++) { Object one = old.get0(i); if (one != null) { set0(i, one); } } }
/** * Gets an array containing all of the labels used in this instance, * in order. The returned array is freshly-allocated and so may be * modified safely by the caller without impacting this instance. * * @return {@code non-null;} ordered array of labels * @throws NullPointerException thrown if there are any {@code null} * items in this instance */ public final int[] getLabelsInOrder() { int sz = size(); int[] result = new int[sz]; for (int i = 0; i < sz; i++) { LabeledItem li = (LabeledItem) get0(i); if (li == null) { throw new NullPointerException("null at index " + i); } result[i] = li.getLabel(); } Arrays.sort(result); return result; }
/** * Sets the basic block at the given index. * * @param n {@code >= 0, < size();} which index * @param bb {@code null-ok;} the element to set at {@code n} */ public void set(int n, BasicBlock bb) { super.set(n, bb); // Reset regCount, since it will need to be recalculated. regCount = -1; }
/** {@inheritDoc} */ @Override public void shrinkToFit() { super.shrinkToFit(); rebuildLabelToIndex(); }
/** * Sets the element at the given index. * * @param n {@code >= 0, < size();} which element * @param item {@code null-ok;} the value to store */ protected void set(int n, LabeledItem item) { LabeledItem old = (LabeledItem) getOrNull0(n); set0(n, item); if (old != null) { removeLabel(old.getLabel()); } if (item != null) { addLabelIndex(item.getLabel(), n); } } }
/** * Constructs a new instance that is a copy of the old instance. * * @param old instance to copy */ public LabeledList(LabeledList old) { super(old.size()); labelToIndex = old.labelToIndex.mutableCopy(); int sz = old.size(); for (int i = 0; i < sz; i++) { Object one = old.get0(i); if (one != null) { set0(i, one); } } }