001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021 022 023package org.biojava.bio.dp.onehead; 024 025import java.util.Iterator; 026 027import org.biojava.bio.dp.State; 028import org.biojava.bio.symbol.SymbolList; 029 030/** 031 * Constant-memory implementation of single-head DP cursor. 032 * 033 * @author Matthew Pocock 034 */ 035public class SmallCursor extends AbstractCursor { 036 private final SymbolList symList; 037 private double [] currentC; 038 private double [] lastC; 039 040 public SymbolList symList() { 041 return symList; 042 } 043 044 public int length() { 045 return symList.length(); 046 } 047 048 public double [] currentCol() { 049 return currentC; 050 } 051 052 public double [] lastCol() { 053 return lastC; 054 } 055 056 public void advance() { 057 super.advance(); 058 059 double [] v = lastC; 060 lastC = currentC; 061 currentC = v; 062 } 063 064 public SmallCursor(State [] states, SymbolList symList, Iterator symIterator) { 065 super(symIterator); 066 this.symList = symList; 067 068 this.currentC = new double[states.length]; 069 this.lastC = new double[states.length]; 070 } 071}