本文整理汇总了Java中java.util.HashSet.clone方法的典型用法代码示例。如果您正苦于以下问题:Java HashSet.clone方法的具体用法?Java HashSet.clone怎么用?Java HashSet.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.HashSet
的用法示例。
在下文中一共展示了HashSet.clone方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canThisActionDistinguish
import java.util.HashSet; //导入方法依赖的package包/类
/**
* whether this action can remove at least one possible position
* the basic idea is the same as the howThisActionCanDistinguish method
* @param thePool, the possible position pool
* @param action, the imaged next step (0F,1B,2L,3R)
* @return double value, the number of different scenario after this action/the total number of
* scenarios after this action
*/
private boolean canThisActionDistinguish(HashSet<Position> thePool, int action) {
HashSet<Position> pool = (HashSet<Position>) thePool.clone();
// if action is not valid, return -1
ArrayList<String> results = new ArrayList<String>();
for (Position pos : pool) {
// clone the position (if we use the original one, we need to move
// it back, which I don't want to do)
Position copy = pos.clone();
// simulate the movement
copy.relativeMove(action);
results.add(getRelativeOccupiedInfo(copy));
}
double diffNum = new HashSet<String>(results).size();
return diffNum > 1;
}
示例2: listCachePools
import java.util.HashSet; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void listCachePools(
HashSet<String> poolNames, int active) throws Exception {
HashSet<String> tmpNames = (HashSet<String>)poolNames.clone();
RemoteIterator<CachePoolEntry> pools = dfs.listCachePools();
int poolCount = poolNames.size();
for (int i=0; i<poolCount; i++) {
CachePoolEntry pool = pools.next();
String pollName = pool.getInfo().getPoolName();
assertTrue("The pool name should be expected", tmpNames.remove(pollName));
if (i % 2 == 0) {
int standby = active;
active = (standby == 0) ? 1 : 0;
cluster.transitionToStandby(standby);
cluster.transitionToActive(active);
cluster.waitActive(active);
}
}
assertTrue("All pools must be found", tmpNames.isEmpty());
}
示例3: listCacheDirectives
import java.util.HashSet; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void listCacheDirectives(
HashSet<String> poolNames, int active) throws Exception {
HashSet<String> tmpNames = (HashSet<String>)poolNames.clone();
RemoteIterator<CacheDirectiveEntry> directives = dfs.listCacheDirectives(null);
int poolCount = poolNames.size();
for (int i=0; i<poolCount; i++) {
CacheDirectiveEntry directive = directives.next();
String pollName = directive.getInfo().getPool();
assertTrue("The pool name should be expected", tmpNames.remove(pollName));
if (i % 2 == 0) {
int standby = active;
active = (standby == 0) ? 1 : 0;
cluster.transitionToStandby(standby);
cluster.transitionToActive(active);
cluster.waitActive(active);
}
}
assertTrue("All pools must be found", tmpNames.isEmpty());
}
示例4: getEphemerals
import java.util.HashSet; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public HashSet<String> getEphemerals(long sessionId) {
HashSet<String> retv = ephemerals.get(sessionId);
if (retv == null) {
return new HashSet<String>();
}
HashSet<String> cloned = null;
synchronized(retv) {
cloned = (HashSet<String>) retv.clone();
}
return cloned;
}
示例5: getEphemerals
import java.util.HashSet; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public HashSet<String> getEphemerals(long sessionId) {
HashSet<String> retv = ephemerals.get(sessionId);
if (retv == null) {
return new HashSet<String>();
}
HashSet<String> cloned = null;
synchronized (retv) {
cloned = (HashSet<String>) retv.clone();
}
return cloned;
}
示例6: getEphemerals
import java.util.HashSet; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Set<String> getEphemerals(long sessionId) {
HashSet<String> retv = ephemerals.get(sessionId);
if (retv == null) {
return new HashSet<String>();
}
Set<String> cloned = null;
synchronized (retv) {
cloned = (HashSet<String>) retv.clone();
}
return cloned;
}
示例7: ComplementFacet
import java.util.HashSet; //导入方法依赖的package包/类
/**
* 用于为分面做相应的补全
*
* @param set
* @param name
* @return
*/
public static HashSet<String> ComplementFacet(HashSet<String> set, String name) {
HashSet<String> facetSet = (HashSet<String>) set.clone();
facetSet.remove("definition");
facetSet.remove("property");
facetSet.remove("application");
facetSet.remove("example");
if (name.toLowerCase().contains("graph") || name.contains("tree") || name.contains("heap")) {
facetSet.add("representation");
facetSet.add("construction");
facetSet.add("operation");
facetSet.add("method");
}
if (name.toLowerCase().contains("list") || name.toLowerCase().contains("array") || name.toLowerCase().contains("queue")) {
facetSet.add("dimension");
facetSet.add("operation");
facetSet.add("method");
}
if (name.contains("algorithm")) {
facetSet.add("complexity");
facetSet.add("mechanism");
}
if (name.contains("search")) {
facetSet.add("algorithm");
}
return facetSet;
}
示例8: GetOneRes
import java.util.HashSet; //导入方法依赖的package包/类
public static HashSet<String> GetOneRes(HashSet<String> hashSet, String name) {
HashSet<String> set = (HashSet<String>) hashSet.clone();
List<String> facetRes = GetNameOrder(oriPath + "experiment\\result\\" + name + ".txt");
for (String s : facetRes) {
set.add(s.trim());
}
return set;
}
示例9: ComplementFacet
import java.util.HashSet; //导入方法依赖的package包/类
/**
* 用于为分面做相应的补全
*
* @param set
* @param name
* @return
*/
public static HashSet<String> ComplementFacet(HashSet<String> set, String name) {
HashSet<String> facetSet = (HashSet<String>) set.clone();
facetSet.add("definition");
facetSet.add("property");
facetSet.add("application");
facetSet.add("example");
if (name.toLowerCase().contains("graph") || name.contains("tree") || name.contains("heap")) {
facetSet.add("representation");
facetSet.add("construction");
facetSet.add("operation");
facetSet.add("method");
}
if (name.toLowerCase().contains("list") || name.toLowerCase().contains("array") || name.toLowerCase().contains("queue")) {
facetSet.add("dimension");
facetSet.add("operation");
facetSet.add("method");
}
if (name.contains("algorithm")) {
facetSet.add("complexity");
facetSet.add("mechanism");
}
if (name.contains("search")) {
facetSet.add("algorithm");
}
return facetSet;
}
示例10: Node
import java.util.HashSet; //导入方法依赖的package包/类
public Node(HashSet<Position> thePool, int theAction) {
positionPool = (HashSet<Position>) thePool.clone();
action = theAction;
}
示例11: cloneCollection
import java.util.HashSet; //导入方法依赖的package包/类
/**
*
*/
@SuppressWarnings("unchecked")
public HashSet<V> cloneCollection(HashSet<V> collection) {
return (HashSet<V>)collection.clone();
}
示例12: PropertySet
import java.util.HashSet; //导入方法依赖的package包/类
public PropertySet(HashSet<SSSProperty> objectsProperties2) {
this.properties = (HashSet<SSSProperty>) objectsProperties2.clone(); //makes clone now
}