List of usage examples for java.util Vector removeElement
public synchronized boolean removeElement(Object obj)
From source file:Main.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(0, i);//w w w . java 2 s.c o m } System.out.println(v.capacity()); System.out.println(v); v.remove(new Integer(9)); v.removeElement(new Integer(2)); System.out.println(v); System.out.println(v.capacity()); }
From source file:Main.java
public static void main(String[] args) { Vector vec = new Vector(4); vec.add(4);/*from ww w.ja v a 2 s. c o m*/ vec.add(3); vec.add(2); vec.add(1); System.out.println(vec); System.out.println("Size of the vector: " + vec.size()); System.out.println("Removing all elements"); // lets remove all the elements vec.removeElement(3); System.out.println("Now size of the vector: " + vec.size()); }
From source file:SelectionHandler.java
private void removeFromSource(String item) { ListModel model = source.getModel(); Vector listData = new Vector(); for (int i = 0; i < model.getSize(); i++) { listData.addElement(model.getElementAt(i)); }//w w w . ja va 2s . c o m listData.removeElement(item); source.setListData(listData); }
From source file:edu.cmu.tetrad.search.Ling.java
private static List<List<Integer>> nRookColumnAssignments(DoubleMatrix2D mat, List<Integer> availableRows) { List<List<Integer>> concats = new ArrayList<List<Integer>>(); int n = availableRows.size(); for (int i = 0; i < n; i++) { int currentRowIndex = availableRows.get(i); if (mat.get(currentRowIndex, 0) != 0) { if (mat.columns() > 1) { Vector<Integer> newAvailableRows = (new Vector<Integer>(availableRows)); newAvailableRows.removeElement(currentRowIndex); DoubleMatrix2D subMat = mat.viewPart(0, 1, mat.rows(), mat.columns() - 1); List<List<Integer>> allLater = nRookColumnAssignments(subMat, newAvailableRows); for (List<Integer> laterPerm : allLater) { laterPerm.add(0, currentRowIndex); concats.add(laterPerm); }//ww w . j a v a 2 s . c om } else { List<Integer> l = new ArrayList<Integer>(); l.add(currentRowIndex); concats.add(l); } } } return concats; }
From source file:gate.DocumentFormat.java
public synchronized void removeStatusListener(StatusListener l) { if (statusListeners != null && statusListeners.contains(l)) { @SuppressWarnings("unchecked") Vector<StatusListener> v = (Vector<StatusListener>) statusListeners.clone(); v.removeElement(l); statusListeners = v;/*from w w w . j a va 2 s. co m*/ } }
From source file:cm.aptoide.pt.ManageRepo.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { LayoutInflater li = LayoutInflater.from(this); switch (item.getItemId()) { case ADD_REPO: View view = li.inflate(R.layout.addrepo, null); final TextView sec_msg = (TextView) view.findViewById(R.id.sec_msg); final TextView sec_msg2 = (TextView) view.findViewById(R.id.sec_msg2); final EditText sec_user = (EditText) view.findViewById(R.id.sec_user); final EditText sec_pwd = (EditText) view.findViewById(R.id.sec_pwd); final CheckBox sec = (CheckBox) view.findViewById(R.id.secure_chk); sec.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sec_user.setEnabled(true); sec_pwd.setEnabled(true); } else { sec_user.setEnabled(false); sec_pwd.setEnabled(false); }//from w w w . j ava2 s.c o m } }); Builder p = new AlertDialog.Builder(this).setView(view); alrt = p.create(); alrt.setIcon(android.R.drawable.ic_menu_add); alrt.setTitle("Add new repository"); alrt.setButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Message msg = new Message(); EditText uri = (EditText) alrt.findViewById(R.id.edit_uri); String uri_str = uri.getText().toString(); sec_msg.setVisibility(View.GONE); sec_msg2.setVisibility(View.GONE); if (sec.isChecked()) { String user = sec_user.getText().toString(); String pwd = sec_pwd.getText().toString(); int result = checkServer(uri_str, user, pwd); if (result == 200) { msg.obj = 0; db.addServer(uri_str); db.addLogin(user, pwd, uri_str); change = true; redraw(); } else if (result == 401) { sec_msg2.setText("Login is wrong"); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; } else { sec_msg.setText("Can't connect to server"); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; } } else { int result = checkServer(uri_str, null, null); if (result == 200) { msg.obj = 0; db.addServer(uri_str); change = true; redraw(); } else if (result == 401) { sec_msg2.setText("Login required"); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; } else { sec_msg.setText("Can't connect to server"); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; } } new_repo.sendMessage(msg); } }); alrt.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alrt.dismiss(); } }); alrt.show(); break; case REM_REPO: final Vector<String> rem_lst = new Vector<String>(); CharSequence[] b = new CharSequence[server_lst.size()]; for (int i = 0; i < server_lst.size(); i++) { b[i] = server_lst.get(i).uri; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Chose repository to remove"); builder.setIcon(android.R.drawable.ic_menu_close_clear_cancel); builder.setMultiChoiceItems(b, null, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { if (isChecked) { rem_lst.addElement(server_lst.get(whichButton).uri); } else { rem_lst.removeElement(server_lst.get(whichButton).uri); } } }); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { db.removeServer(rem_lst); change = true; redraw(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); AlertDialog alert = builder.create(); alert.show(); break; case EDIT_REPO: CharSequence[] b2 = new CharSequence[server_lst.size()]; for (int i = 0; i < server_lst.size(); i++) { b2[i] = server_lst.get(i).uri; } AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle("Chose repository to edit"); builder2.setIcon(android.R.drawable.ic_menu_edit); builder2.setSingleChoiceItems(b2, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { updt_repo = server_lst.get(which).uri; } }); builder2.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { editRepo(updt_repo); return; } }); builder2.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); alert2 = builder2.create(); alert2.show(); break; } return super.onMenuItemSelected(featureId, item); }
From source file:gate.annotation.AnnotationSetImpl.java
@Override public synchronized void removeGateListener(GateListener l) { if (gateListeners != null && gateListeners.contains(l)) { @SuppressWarnings("unchecked") Vector<GateListener> v = (Vector<GateListener>) gateListeners.clone(); v.removeElement(l); gateListeners = v;/*from ww w . j a va2 s. c om*/ } }
From source file:gate.annotation.AnnotationSetImpl.java
@Override public synchronized void removeAnnotationSetListener(AnnotationSetListener l) { if (annotationSetListeners != null && annotationSetListeners.contains(l)) { @SuppressWarnings("unchecked") Vector<AnnotationSetListener> v = (Vector<AnnotationSetListener>) annotationSetListeners.clone(); v.removeElement(l); annotationSetListeners = v;/*from w ww . ja v a 2s. c o m*/ } }
From source file:cm.aptoide.pt.ManageRepos.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { EnumOptionsMenu option = EnumOptionsMenu.reverseOrdinal(item.getItemId()); CharSequence[] reposArray = new CharSequence[repos.getList().size() - reposInserting.size()]; int j = 0;/*from w w w . jav a 2s .c o m*/ for (int i = 0; i < repos.getList().size(); i++) { if (!reposInserting.containsKey(repos.getList().get(i).get(Constants.KEY_REPO_HASHID))) { reposArray[j] = (String) repos.getList().get(i).get(Constants.KEY_REPO_URI); j++; } } switch (option) { case ADD_REPO: validateRepo(null, false); break; case REMOVE_REPO: if (reposArray.length == 0) { return true; } final Vector<Integer> remList = new Vector<Integer>(); AlertDialog.Builder builder = new AlertDialog.Builder(theme); builder.setTitle(getString(R.string.remove_repo_choose)); builder.setIcon(R.drawable.ic_menu_close_clear_cancel); builder.setMultiChoiceItems(reposArray, null, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { if (isChecked) { remList.addElement( (Integer) (repos.getList().get(whichButton).get(Constants.KEY_REPO_HASHID))); } else { remList.removeElement( (Integer) (repos.getList().get(whichButton).get(Constants.KEY_REPO_HASHID))); } } }); builder.setPositiveButton(getString(R.string.remove), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { for (Integer repoHashid : remList) { removeDisplayRepo(repoHashid); } alert.dismiss(); refreshReposList(); } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { alert.dismiss(); return; } }); alert = builder.create(); alert.show(); break; case EDIT_REPO: if (reposArray.length == 0) { return true; } AlertDialog.Builder builder2 = new AlertDialog.Builder(theme); builder2.setTitle(getString(R.string.edit_repo_choose)); builder2.setIcon(R.drawable.ic_menu_edit); builder2.setSingleChoiceItems(reposArray, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { updt_repo = (String) (repos.getList().get(whichButton).get(Constants.KEY_REPO_URI)); } }); builder2.setPositiveButton(getString(R.string.edit), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { alert2.dismiss(); validateRepo(updt_repo, true); return; } }); builder2.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { alert2.dismiss(); return; } }); alert2 = builder2.create(); alert2.show(); break; } return super.onMenuItemSelected(featureId, item); }
From source file:Maze.java
/** * internal to createMaze. Checks the four squares surrounding * the chosen square. Of those that are already connected to * the maze, one is randomly selected to be joined to the * current square (to attach the current square to the * growing maze). Those squares that were not previously in * a position to be joined to the maze are added to the list * of "possible" squares (that could be chosen to be attached * to the maze in the next round)./*from w w w.java 2s . co m*/ */ private void link(int[] chosenSquare, Vector possibleSquares) { int linkCount = 0; int i = chosenSquare[0]; int j = chosenSquare[1]; int[] links = new int[8]; if (i >= 3) { if (mySquares[i - 2][j] == 1) { links[2 * linkCount] = i - 1; links[2 * linkCount + 1] = j; linkCount++; } else if (mySquares[i - 2][j] == 3) { mySquares[i - 2][j] = 2; int[] newSquare = new int[2]; newSquare[0] = i - 2; newSquare[1] = j; possibleSquares.addElement(newSquare); } } if (j + 3 <= mySquares[i].length) { if (mySquares[i][j + 2] == 3) { mySquares[i][j + 2] = 2; int[] newSquare = new int[2]; newSquare[0] = i; newSquare[1] = j + 2; possibleSquares.addElement(newSquare); } else if (mySquares[i][j + 2] == 1) { links[2 * linkCount] = i; links[2 * linkCount + 1] = j + 1; linkCount++; } } if (j >= 3) { if (mySquares[i][j - 2] == 3) { mySquares[i][j - 2] = 2; int[] newSquare = new int[2]; newSquare[0] = i; newSquare[1] = j - 2; possibleSquares.addElement(newSquare); } else if (mySquares[i][j - 2] == 1) { links[2 * linkCount] = i; links[2 * linkCount + 1] = j - 1; linkCount++; } } if (i + 3 <= mySquares.length) { if (mySquares[i + 2][j] == 3) { mySquares[i + 2][j] = 2; int[] newSquare = new int[2]; newSquare[0] = i + 2; newSquare[1] = j; possibleSquares.addElement(newSquare); } else if (mySquares[i + 2][j] == 1) { links[2 * linkCount] = i + 1; links[2 * linkCount + 1] = j; linkCount++; } } if (linkCount > 0) { int linkChoice = getRandomInt(linkCount); int linkX = links[2 * linkChoice]; int linkY = links[2 * linkChoice + 1]; mySquares[linkX][linkY] = 1; int[] removeSquare = new int[2]; removeSquare[0] = linkX; removeSquare[1] = linkY; possibleSquares.removeElement(removeSquare); } }