Java Code Examples for java.util.Vector.removeAll()

The following are Jave code examples for showing how to use removeAll() of the java.util.Vector class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jmt   File: CommonModel.java   View Source Code Vote up 6 votes
/**
 * This method returns all station (except sources and sinks) keys.
 */
@Override
public Vector<Object> getStationKeysNoSourceSink() {
	Vector<Object> keyset = new Vector<Object>();
	keyset.addAll(stationsKeyset);
	keyset.removeAll(sourcesKeyset);
	keyset.removeAll(sinksKeyset);
	return keyset;
}
 
Example 2
Project: jmt   File: CommonModel.java   View Source Code Vote up 6 votes
/**
 * This method returns all station (except sources and sinks) and blocking region keys.
 */
@Override
public Vector<Object> getStationRegionKeysNoSourceSink() {
	Vector<Object> keyset = new Vector<Object>();
	keyset.addAll(stationsKeyset);
	keyset.removeAll(sourcesKeyset);
	keyset.removeAll(sinksKeyset);
	keyset.addAll(blockingRegionsKeyset);
	return keyset;
}
 
Example 3
Project: ibench   File: Utils.java   View Source Code Vote up 6 votes
public static Vector<String> getRandomWithoutReplacementSequence(Random generator, int desiredSize, Vector<String> allElems) {

 		Vector<String> randomElems = new Vector<String> ();
 		HashSet<String> elemHashSet = new HashSet<String> ();
 		
 		// Build a hashSet varSet out of allElems
 		for(String anElem: allElems) {
 			elemHashSet.add(anElem);
 		}
 		
 		// Do we have enough elements to obtain a random sequence of desiredSize?
 		// If not, just use all elements for the sake of completion
 		// Ditto if we were asked to choose 0 elements
 		if ( (desiredSize <= 0) || (desiredSize >= elemHashSet.size())) {
 			randomElems = new Vector<String> (elemHashSet);
 			Collections.sort(randomElems);
 			return randomElems;
 		}
 		
 		// Randomly select variables until we have enough. As we go along, remove chosen variables to guarantee convergence.
 		// By design, we select random numbers following a uniform distribution
 		for(int i = 0; i < desiredSize; i++) {
 			
 			int pos = Utils.getRandomUniformNumber(generator, allElems.size());
 			String elem = allElems.get(pos);
 			randomElems.add(elem);
 			
 			// Ensure "Random Without Replacement" Strategy; thus remove all occurrences of elem
 			elemHashSet.remove(elem);
 			allElems.removeAll(Collections.singleton(elem));
 		}
 		
 		// The following sorting only makes sense when this method is invoked with strings representing variables, instead of attribute names
 		Collections.sort(randomElems);
 		return randomElems;		
 	}