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

fr.boreal.backward_chaining.source_target.dlx.DLXResult Maven / Gradle / Ivy

package fr.boreal.backward_chaining.source_target.dlx;

import java.util.Iterator;
import java.util.List;

/**
 * This class models a DLX algorithm search result. The result object contains
 * a list of rows of size k, where k is the
 * depth of the search when the result was found.  Each row is returned as
 * a sequence of column labels; thus it's important to initialize DLX with
 * a meaningful set of column labels to get sensible results.
 */
public class DLXResult {

	private final List > resultData;

	/**
	 * Construct a result with the given lists
	 * @param resultData the result as list
	 */
	public DLXResult(List> resultData) {
		this.resultData = resultData;
	}

	@Override
	public String toString() {
		final StringBuilder buffer = new StringBuilder();
		for (final List row : resultData) {
			for (final Object label : row) {
				buffer.append(label.toString());
				buffer.append(' ');
			}
			buffer.append('\n');
		}
		return buffer.toString();
	}

	/**
	 * @return the rows
	 */
	public Iterator> rows() {
		return resultData.iterator();
	}

}