本文整理汇总了Java中java.util.Vector.add方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.add方法的具体用法?Java Vector.add怎么用?Java Vector.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Vector
的用法示例。
在下文中一共展示了Vector.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllResources
import java.util.Vector; //导入方法依赖的package包/类
/**
* List of all resources
* @return Vector
*/
public Vector getAllResources() {
Vector v = new Vector();
Elements rs = _root.getChildElements("resource");
for (int i = 0; i < rs.size(); i++)
v.add(new Resource(rs.get(i).getAttribute("path").getValue(), rs.get(i).getAttribute("isInetShortcut") != null, rs.get(i).getAttribute("isProjectFile") != null));
return v;
}
示例2: getActiveProjects
import java.util.Vector; //导入方法依赖的package包/类
public static Vector getActiveProjects() {
Elements prjs = _root.getChildElements("project");
Vector v = new Vector();
for (int i = 0; i < prjs.size(); i++) {
Project prj = new ProjectImpl((Element) prjs.get(i));
if (prj.getStatus() == Project.ACTIVE)
v.add(prj);
}
return v;
}
示例3: getExtensions
import java.util.Vector; //导入方法依赖的package包/类
public String[] getExtensions() {
Vector v = new Vector();
String[] ss = {};
Elements exts = _root.getChildElements("ext");
for (int i = 0; i < exts.size(); i++)
v.add(exts.get(i).getValue());
return (String[]) v.toArray(ss);
}
示例4: updateButtons
import java.util.Vector; //导入方法依赖的package包/类
void updateButtons() {
ColorComponent cc=null;
Color col;
if( buttonPanel==null ) {
buttonPanel=new JPanel(new GridLayout(1,0));
buttons = new Vector();
}
for( int k=0 ; k<buttons.size() ; k++) {
cc = (ColorComponent)buttons.get(k);
cc.removeMouseListener(buttonL);
buttonPanel.remove(cc);
}
float[][] model = lut.getModel();
float[] red = model[1];
float[] green = model[2];
float[] blue = model[3];
for( int k=0 ; k<red.length ; k++) {
col = new Color(red[k], green[k], blue[k]);
if( k<buttons.size() ) {
cc = (ColorComponent)buttons.get(k);
cc.setColor(col);
} else {
cc = new ColorComponent(col);
buttons.add(cc);
}
buttonPanel.add( cc );
cc.addMouseListener(buttonL);
}
for( int k=red.length ; k<buttons.size() ; k++) {
cc = (ColorComponent)buttons.remove(k);
}
buttonPanel.revalidate();
cc = (ColorComponent)buttons.get(0);
select(cc);
}
示例5: getMonths
import java.util.Vector; //导入方法依赖的package包/类
public Vector getMonths() {
Vector v = new Vector();
Elements ms = yearElement.getChildElements("month");
for (int i = 0; i < ms.size(); i++)
v.add(new Month(ms.get(i)));
return v;
}
示例6: scan
import java.util.Vector; //导入方法依赖的package包/类
/** Scans data for [] brackets and prepares data for formatting
* using MapFormat utility
*/
private Vector scan(StringTokenizer tok) throws ParseException {
Vector objvec = new Vector();
while (tok.hasMoreTokens()) {
String token = (String) tok.nextElement();
Object obj = token;
if (token.equals("["))
obj = (Object)scan(tok);
else if (token.equals("]"))
break;
objvec.add(obj);
}
return objvec;
}
示例7: assignTileAssociationsWithinRadius
import java.util.Vector; //导入方法依赖的package包/类
private void assignTileAssociationsWithinRadius(TileAssociation s, int radius, Vector<TileAssociation> vec) {
if (!vec.contains(s)) {
vec.add(s);
}
if (radius != 0) {
for (TileAssociation t : s.getNeighbors()) {
assignTileAssociationsWithinRadius(t, radius-1, vec);
}
}
}
示例8: addBestGuess
import java.util.Vector; //导入方法依赖的package包/类
/**
* When we don't come up with any suggestions (probably because the threshold was too strict),
* then pick the best guesses from the those words that have the same phonetic code.
* @param word - the word we are trying spell correct
* @param Two dimensional array of int used to calculate
* edit distance. Allocating this memory outside of the function will greatly improve efficiency.
* @param wordList - the linked list that will get the best guess
*/
private void addBestGuess(String word, Vector<Word> wordList, int[][] matrix) {
if(matrix == null)
matrix = new int[0][0];
if (wordList.size() != 0)
throw new InvalidParameterException("the wordList vector must be empty");
int bestScore = Integer.MAX_VALUE;
String code = getCode(word);
List<String> simwordlist = getWords(code);
LinkedList<Word> candidates = new LinkedList<Word>();
for (String similar : simwordlist) {
int distance = EditDistance.getDistance(word, similar, matrix);
if (distance <= bestScore) {
bestScore = distance;
Word goodGuess = new Word(similar, distance);
candidates.add(goodGuess);
}
}
//now, only pull out the guesses that had the best score
for (Iterator<Word> iter = candidates.iterator(); iter.hasNext();) {
Word candidate = iter.next();
if (candidate.getCost() == bestScore)
wordList.add(candidate);
}
}
示例9: makeSetterChange
import java.util.Vector; //导入方法依赖的package包/类
public static AtomicChange makeSetterChange(char typ, String methodQualifiedName, String fieldQualifiedName){
Vector<String> params = new Vector<String>();
params.add(methodQualifiedName);
params.add(fieldQualifiedName);
return new AtomicChange(typ=='A'?ChangeTypes.ADD_SETTER:
ChangeTypes.DEL_SETTER, params);
}
示例10: bencodeDictionary
import java.util.Vector; //导入方法依赖的package包/类
/**
* Bencodes a HashMap into a bencoded dictionary.The HashMap must contain
* only bencoded strings representing bencoded integers, strings, lists, and
* dictionaries.
*
* @param input
* A HashMap containing bencoded objects representing the entries
* in a dictionary.
* @return
*/
public byte[] bencodeDictionary(HashMap input)
{
byte[] return_bytes = null;
int length = 0;
Vector dictionary_entries = new Vector();
Iterator input_iterator = input.entrySet().iterator();
while (input_iterator.hasNext())
{
Map.Entry me = (Map.Entry) input_iterator.next();
length += ((byte[]) me.getKey()).length;
length += ((byte[]) me.getValue()).length;
dictionary_entries.add((byte[]) me.getKey());
dictionary_entries.add((byte[]) me.getValue());
}
return_bytes = new byte[length + 2];
return_bytes[0] = (byte) 'd';
return_bytes[return_bytes.length - 1] = (byte) 'e';
int index = 1;
for (int i = 0; i < dictionary_entries.size(); i++)
{
for (int j = 0; j < ((byte[]) dictionary_entries.get(i)).length; j++)
{
return_bytes[index] = ((byte[]) dictionary_entries.get(i))[j];
index++;
}
}
return return_bytes;
}
示例11: select
import java.util.Vector; //导入方法依赖的package包/类
protected void select() {
try {
minD = 10f*Float.parseFloat( minDep.getText() );
maxD = 10f*Float.parseFloat( maxDep.getText() );
minM = 10f*Float.parseFloat( minMag.getText() );
maxM = 10f*Float.parseFloat( maxMag.getText() );
int minY = Integer.parseInt( minYear.getText() );
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.set( minY, 0, 1);
minTime = (int)( cal.getTime().getTime()/1000L);
int maxY = Integer.parseInt( maxYear.getText() );
cal.set( maxY, 0, 1);
maxTime = (int)( cal.getTime().getTime()/1000L);
current = new Vector(earthquakes.size());
currentIndexInEQ = new Vector(earthquakes.size());
for( int k=0 ; k<earthquakes.size() ; k++) {
EarthQuake eq = (EarthQuake)earthquakes.get(k);
if( eq.time<minTime || eq.time>maxTime )continue;
if( (float)eq.dep<minD || (float)eq.dep>maxD )continue;
if( (float)eq.mag<minM || (float)eq.mag>maxM )continue;
current.add( eq );
currentIndexInEQ.add(new Integer(k));
}
current.trimToSize();
currentIndexInEQ.trimToSize();
} catch(NumberFormatException ex) {
JOptionPane.showMessageDialog( map.getTopLevelAncestor(), "number format exception");
}
}
示例12: init
import java.util.Vector; //导入方法依赖的package包/类
protected void init(Vector includes, Vector defines) {
defines.add("_DEBUG");
defines.add("ASSERT");
super.init(includes, defines);
getV("CompilerFlags").addAll(getCI().getDebugCompilerFlags(getOptFlag(), get("PlatformName")));
getV("LinkerFlags").addAll(getCI().getDebugLinkerFlags());
}
示例13: getDays
import java.util.Vector; //导入方法依赖的package包/类
public Vector getDays() {
if (mElement == null)
return null;
Vector v = new Vector();
Elements ds = mElement.getChildElements("day");
for (int i = 0; i < ds.size(); i++)
v.add(new Day(ds.get(i)));
return v;
}
示例14: getListPart
import java.util.Vector; //导入方法依赖的package包/类
public Vector<Vector<String>> getListPart() {
Vector<Vector<String>> ret = new Vector<Vector<String>>();
for (Event e: this.eventsPart) {
Vector<String> ite = new Vector<String>();
ite.add(Long.toString(e.getId()));
ite.add(e.getName());
ite.add(e.getLieu());
ite.add(e.getDate_event().toString());
ite.add(Integer.toString(e.getParticipants().size()));
ite.add("?");
ret.add(ite);
}
return ret;
}
示例15: viterbi
import java.util.Vector; //导入方法依赖的package包/类
public void viterbi(String sentence, List<String> tokens) {
Vector<Map<Character, Double>> v = new Vector<Map<Character, Double>>();
Map<Character, Node> path = new HashMap<Character, Node>();
v.add(new HashMap<Character, Double>());
for (char state : states) {
Double emP = emit.get(state).get(sentence.charAt(0));
if (null == emP)
emP = MIN_FLOAT;
v.get(0).put(state, start.get(state) + emP);
path.put(state, new Node(state, null));
}
for (int i = 1; i < sentence.length(); ++i) {
Map<Character, Double> vv = new HashMap<Character, Double>();
v.add(vv);
Map<Character, Node> newPath = new HashMap<Character, Node>();
for (char y : states) {
Double emp = emit.get(y).get(sentence.charAt(i));
if (emp == null)
emp = MIN_FLOAT;
Pair<Character> candidate = null;
for (char y0 : prevStatus.get(y)) {
Double tranp = trans.get(y0).get(y);
if (null == tranp)
tranp = MIN_FLOAT;
tranp += (emp + v.get(i - 1).get(y0));
if (null == candidate)
candidate = new Pair<Character>(y0, tranp);
else if (candidate.freq <= tranp) {
candidate.freq = tranp;
candidate.key = y0;
}
}
vv.put(y, candidate.freq);
newPath.put(y, new Node(y, path.get(candidate.key)));
}
path = newPath;
}
double probE = v.get(sentence.length() - 1).get('E');
double probS = v.get(sentence.length() - 1).get('S');
Vector<Character> posList = new Vector<Character>(sentence.length());
Node win;
if (probE < probS)
win = path.get('S');
else
win = path.get('E');
while (win != null) {
posList.add(win.value);
win = win.parent;
}
Collections.reverse(posList);
int begin = 0, next = 0;
for (int i = 0; i < sentence.length(); ++i) {
char pos = posList.get(i);
if (pos == 'B')
begin = i;
else if (pos == 'E') {
tokens.add(sentence.substring(begin, i + 1));
next = i + 1;
}
else if (pos == 'S') {
tokens.add(sentence.substring(i, i + 1));
next = i + 1;
}
}
if (next < sentence.length())
tokens.add(sentence.substring(next));
}