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

com.badlogic.gdx.ai.pfa.DefaultGraphPath Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright 2014 See AUTHORS file.
 * 
 * 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.badlogic.gdx.ai.pfa;

import org.mini2Dx.gdx.utils.Array;

import java.util.Iterator;

/** Default implementation of a {@link GraphPath} that uses an internal {@link Array} to store nodes or connections.
 * 
 * @param  Type of node
 * 
 * @author davebaol */
public class DefaultGraphPath implements GraphPath {
	public final Array nodes;

	/** Creates a {@code DefaultGraphPath} with no nodes. */
	public DefaultGraphPath () {
		this(new Array());
	}

	/** Creates a {@code DefaultGraphPath} with the given capacity and no nodes. */
	public DefaultGraphPath (int capacity) {
		this(new Array(capacity));
	}

	/** Creates a {@code DefaultGraphPath} with the given nodes. */
	public DefaultGraphPath (Array nodes) {
		this.nodes = nodes;
	}

	@Override
	public void clear () {
		nodes.clear();
	}

	@Override
	public int getCount () {
		return nodes.size;
	}

	@Override
	public void add (N node) {
		nodes.add(node);
	}

	@Override
	public N get (int index) {
		return nodes.get(index);
	}

	@Override
	public void reverse () {
		nodes.reverse();
	}

	@Override
	public Iterator iterator () {
		return nodes.iterator();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy