当前位置: 首页>>代码示例>>Java>>正文


Java HashSet.clone方法代码示例

本文整理汇总了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;
}
 
开发者ID:JINKEHE,项目名称:Rescue-Victims,代码行数:24,代码来源:Playground.java

示例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());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestRetryCacheWithHA.java

示例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());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestRetryCacheWithHA.java

示例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;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:13,代码来源:DataTreeV1.java

示例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;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:13,代码来源:DataTree.java

示例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;
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:13,代码来源:DataTree.java

示例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;
}
 
开发者ID:guozhaotong,项目名称:FacetExtract,代码行数:34,代码来源:BResult_delete4.java

示例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;
}
 
开发者ID:guozhaotong,项目名称:FacetExtract,代码行数:9,代码来源:BResult_delete4.java

示例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;
}
 
开发者ID:guozhaotong,项目名称:FacetExtract,代码行数:34,代码来源:BResult_add4.java

示例10: Node

import java.util.HashSet; //导入方法依赖的package包/类
public Node(HashSet<Position> thePool, int theAction) {
    positionPool = (HashSet<Position>) thePool.clone();
    action = theAction;
}
 
开发者ID:JINKEHE,项目名称:Rescue-Victims,代码行数:5,代码来源:Playground.java

示例11: cloneCollection

import java.util.HashSet; //导入方法依赖的package包/类
/**
 * 
 */
@SuppressWarnings("unchecked")
public HashSet<V> cloneCollection(HashSet<V> collection) {
    return (HashSet<V>)collection.clone();
}
 
开发者ID:annoflex,项目名称:annoflex,代码行数:8,代码来源:MultiMapController.java

示例12: PropertySet

import java.util.HashSet; //导入方法依赖的package包/类
public PropertySet(HashSet<SSSProperty> objectsProperties2) {

		this.properties = (HashSet<SSSProperty>) objectsProperties2.clone(); //makes clone now
	}
 
开发者ID:ThomasWrobel,项目名称:JAMCore,代码行数:5,代码来源:PropertySet.java


注:本文中的java.util.HashSet.clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。