PageRenderTime 19ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/cpp/src/main/java/com/google/test/metric/cpp/dom/NodeList.java

http://testability-explorer.googlecode.com/
Java | 56 lines | 31 code | 10 blank | 15 comment | 0 complexity | b4d1360840ca97387bc72403a258bffb MD5 | raw file
 1/*
 2 * Copyright 2008 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package com.google.test.metric.cpp.dom;
17
18import java.util.ArrayList;
19import java.util.Iterator;
20import java.util.List;
21
22public class NodeList implements Iterable<Node> {
23
24  private final List<Node> nodes = new ArrayList<Node>();
25  private final Node parent;
26
27  public NodeList(Node parent) {
28    this.parent = parent;
29  }
30
31  public void add(Node node) {
32    nodes.add(node);
33    node.setParent(parent);
34  }
35
36  @SuppressWarnings("unchecked")
37  public <T> T get(int index) {
38    return (T) nodes.get(index);
39  }
40
41  public Iterator<Node> iterator() {
42    return nodes.iterator();
43  }
44
45  public int size() {
46    return nodes.size();
47  }
48
49  public void remove(int index) {
50    nodes.remove(index);
51  }
52
53  public int indexOf(Node node) {
54    return nodes.indexOf(node);
55  }
56}