2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.dx.cf.code;
19 import com.android.dx.util.FixedSizeList;
20 import com.android.dx.util.Hex;
21 import com.android.dx.util.LabeledList;
24 * List of {@link ByteBlock} instances.
26 public final class ByteBlockList extends LabeledList {
29 * Constructs an instance.
31 * @param size {@code >= 0;} the number of elements to be in the list
33 public ByteBlockList(int size) {
38 * Gets the indicated element. It is an error to call this with the
39 * index for an element which was never set; if you do that, this
40 * will throw {@code NullPointerException}.
42 * @param n {@code >= 0, < size();} which element
43 * @return {@code non-null;} the indicated element
45 public ByteBlock get(int n) {
46 return (ByteBlock) get0(n);
50 * Gets the block with the given label.
52 * @param label the label to look for
53 * @return {@code non-null;} the block with the given label
55 public ByteBlock labelToBlock(int label) {
56 int idx = indexOfLabel(label);
59 throw new IllegalArgumentException("no such label: "
67 * Sets the element at the given index.
69 * @param n {@code >= 0, < size();} which element
70 * @param bb {@code null-ok;} the value to store
72 public void set(int n, ByteBlock bb) {