📄 positionvector.java
字号:
package ergo.util;
// $Id: PositionVector.java,v 1.2 1999/08/13 01:20:43 sigue Exp $
/*
* Copyright (C) 1999 Carl L. Gay and Antranig M. Basman.
* See the file copyright.txt, distributed with this software,
* for further information.
*/
import java.util.Vector;
/**
* It is common enough to have vectors of Position objects that this is
* worthwhile. This doesn't attempt to be a general subclass of Vector;
* it only implements the methods I need for Ergo.
*/
public class PositionVector {
Vector p;
public PositionVector() { p = new Vector(); }
public PositionVector(int a) { p = new Vector(a); }
public PositionVector(int a, int b) { p = new Vector(a, b); }
public Position elementAt(int index) {
return (Position) p.elementAt(index);
}
public int size() { return p.size(); }
public void setSize(int n) { p.setSize(n); }
public void addElement(Position pos) {
p.addElement(pos);
}
public void removeElementAt(int index) {
p.removeElementAt(index);
}
public boolean isMember(Position p) {
for (int i = 0; i < size(); i++)
if (elementAt(i).equals(p))
return true;
return false;
}
public boolean isMember(int row, int col) {
for (int i = 0; i < size(); i++) {
Position p = elementAt(i);
if (p.row == row && p.column == col)
return true;
}
return false;
}
public String toString() {
StringBuffer s = new StringBuffer();
for (int i = 0; i < p.size(); i++) {
s.append(elementAt(i));
s.append(" "); }
return s.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -