本文整理匯總了Java中java.util.Vector.removeAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector.removeAll方法的具體用法?Java Vector.removeAll怎麽用?Java Vector.removeAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Vector
的用法示例。
在下文中一共展示了Vector.removeAll方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getStationKeysNoSourceSink
import java.util.Vector; //導入方法依賴的package包/類
/**
* 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;
}
示例2: getStationRegionKeysNoSourceSink
import java.util.Vector; //導入方法依賴的package包/類
/**
* 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;
}
示例3: getRandomWithoutReplacementSequence
import java.util.Vector; //導入方法依賴的package包/類
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;
}