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

de.regnis.q.sequence.core.QSequenceDeePathExtenderArray Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
/*
 * ====================================================================
 * Copyright (c) 2000-2008 SyntEvo GmbH, [email protected]
 * All rights reserved.
 *
 * This software is licensed as described in the file SEQUENCE-LICENSE,
 * which you should have received as part of this distribution. Use is
 * subject to license terms.
 * ====================================================================
 */

package de.regnis.q.sequence.core;

/**
 * @author Marc Strapetz
 */
class QSequenceDeePathExtenderArray {

	// Fields =================================================================

	private final int[] xs;
	private final int offset;

	private int delta;

	// Setup ==================================================================

	public QSequenceDeePathExtenderArray(int maximumMediaLeftRightLength) {
		this.offset = maximumMediaLeftRightLength;
		this.xs = new int[2 * maximumMediaLeftRightLength + 1];
	}

	// Accessing ==============================================================

	public void set(int diagonal, int maxLeft) {
		if (QSequenceAlgorithm.ASSERTIONS) {
			QSequenceAssert.assertTrue(-offset + delta <= diagonal && diagonal <= offset + delta);
		}
		this.xs[offset - delta + diagonal] = maxLeft;
	}

	public int get(int diagonal) {
		if (QSequenceAlgorithm.ASSERTIONS) {
			QSequenceAssert.assertTrue(-offset + delta <= diagonal && diagonal <= offset + delta);
		}
		final int left = xs[offset - delta + diagonal];
		if (QSequenceAlgorithm.ASSERTIONS) {
			QSequenceAssert.assertTrue(left != Integer.MAX_VALUE);
		}
		return left;
	}

	public void setDelta(int delta) {
		this.delta = delta;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy