01: /*
02: * ====================================================================
03: * Copyright (c) 2004 Marc Strapetz, marc.strapetz@smartsvn.com.
04: * All rights reserved.
05: *
06: * This software is licensed as described in the file COPYING, which
07: * you should have received as part of this distribution. Use is
08: * subject to license terms.
09: * ====================================================================
10: */
11:
12: package de.regnis.q.sequence.core;
13:
14: /**
15: * @author Marc Strapetz
16: */
17: class QSequenceDeePathExtenderArray {
18:
19: // Fields =================================================================
20:
21: private final int[] xs;
22: private final int offset;
23:
24: private int delta;
25:
26: // Setup ==================================================================
27:
28: public QSequenceDeePathExtenderArray(int maximumMediaLeftRightLength) {
29: this .offset = maximumMediaLeftRightLength;
30: this .xs = new int[2 * maximumMediaLeftRightLength + 1];
31: }
32:
33: // Accessing ==============================================================
34:
35: public void set(int diagonal, int maxLeft) {
36: if (QSequenceAlgorithm.ASSERTIONS) {
37: QSequenceAssert.assertTrue(-offset + delta <= diagonal
38: && diagonal <= offset + delta);
39: }
40: this .xs[offset - delta + diagonal] = maxLeft;
41: }
42:
43: public int get(int diagonal) {
44: if (QSequenceAlgorithm.ASSERTIONS) {
45: QSequenceAssert.assertTrue(-offset + delta <= diagonal
46: && diagonal <= offset + delta);
47: }
48: final int left = xs[offset - delta + diagonal];
49: if (QSequenceAlgorithm.ASSERTIONS) {
50: QSequenceAssert.assertTrue(left != Integer.MAX_VALUE);
51: }
52: return left;
53: }
54:
55: public void setDelta(int delta) {
56: this.delta = delta;
57: }
58: }
|