/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
- /*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
- package com.google.test.metric.cpp.dom;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- public class NodeList implements Iterable<Node> {
- private final List<Node> nodes = new ArrayList<Node>();
- private final Node parent;
- public NodeList(Node parent) {
- this.parent = parent;
- }
- public void add(Node node) {
- nodes.add(node);
- node.setParent(parent);
- }
- @SuppressWarnings("unchecked")
- public <T> T get(int index) {
- return (T) nodes.get(index);
- }
- public Iterator<Node> iterator() {
- return nodes.iterator();
- }
- public int size() {
- return nodes.size();
- }
- public void remove(int index) {
- nodes.remove(index);
- }
- public int indexOf(Node node) {
- return nodes.indexOf(node);
- }
- }