All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mathiewz.slick.util.xml.XMLElementList Maven / Gradle / Ivy

Go to download

The main purpose of this libraryis to modernize and maintain the slick2D library.

The newest version!
package com.github.mathiewz.slick.util.xml;

import java.util.ArrayList;
import java.util.Collection;

/**
 * A simple typed list.
 *
 * @author kevin
 */
public class XMLElementList {
    /** The list of elements */
    private final ArrayList list = new ArrayList<>();

    /**
     * Create a new list
     */
    public XMLElementList() {

    }

    /**
     * Add an element to the list
     *
     * @param element
     *            The element to be added
     */
    public void add(XMLElement element) {
        list.add(element);
    }

    /**
     * Get the number of elements in the list
     *
     * @return The number of elements in the list
     */
    public int size() {
        return list.size();
    }

    /**
     * Get the element at a specified index
     *
     * @param i
     *            The index of the element
     * @return The element at the specified index
     */
    public XMLElement get(int i) {
        return list.get(i);
    }

    /**
     * Check if this list contains the given element
     *
     * @param element
     *            The element to check for
     * @return True if the element is in the list
     */
    public boolean contains(XMLElement element) {
        return list.contains(element);
    }

    /**
     * Add all the elements in this list to another collection
     *
     * @param collection
     *            The collection the elements should be added to
     */
    public void addAllTo(Collection collection) {
        collection.addAll(list);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy