⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assignmentiterator.java

📁 这是一个matlab的java实现。里面有许多内容。请大家慢慢捉摸。
💻 JAVA
字号:
/* Copyright (C) 2003 Univ. of Massachusetts Amherst, Computer Science Dept.   This file is part of "MALLET" (MAchine Learning for LanguagE Toolkit).   http://www.cs.umass.edu/~mccallum/mallet   This software is provided under the terms of the Common Public License,   version 1.0, as published by http://www.opensource.org.  For further   information, see the file `LICENSE' included with this distribution. */package edu.umass.cs.mallet.grmm;import java.util.Iterator;import java.util.List;import edu.umass.cs.mallet.base.types.Matrixn;/** * Iterates over the assignments to a set of variables. *  This is never instantiated by user code; instead, use *  one of the many assignmentIterator() methods. * *   DOCTODO: Add note about difference between using this class and iterating *    over assignments. *   DOCTODO: Explain why advance() is useful instead of next. * * Created: Sun Nov  9 21:04:03 2003 * * @author <a href="mailto:casutton@cs.umass.edu">Charles Sutton</a> * @version $Id: AssignmentIterator.java,v 1.2 2004/08/11 20:07:15 casutton Exp $ */public class AssignmentIterator implements Iterator {	private List vertsList;			private int current = 0;	private int max = 1;	private int[] sizes;	AssignmentIterator (List verts)	{		vertsList = verts;    initSizes ();  }  private void initSizes ()  {    sizes = new int [vertsList.size()];    for (int i = 0; i < vertsList.size(); i++) {      Variable var = (Variable) vertsList.get (i);      sizes [i] = var.getNumOutcomes ();      max *= var.getNumOutcomes ();    }  }  public void advance()	{ 		current++;	}	public Object next() 	{		Assignment assn = assignment ();		advance ();		return assn;	}	int indexOfCurrentAssn () { return current; }	public Assignment assignment ()   {    if (sizes == null) initSizes ();  // Lazily build sizes array		int[] outcomes = new int [sizes.length];		Matrixn.singleToIndices (current, outcomes, sizes);		Variable[] vars = (Variable[]) vertsList.toArray (new Variable [0]);		return new Assignment (vars, outcomes);	}	public boolean hasNext() {		return current < max;	}	public void remove() {		throw new UnsupportedOperationException 			("Attempt to remave assignment from Clique.");	}		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -