本文整理汇总了Java中java.util.HashSet.clear方法的典型用法代码示例。如果您正苦于以下问题:Java HashSet.clear方法的具体用法?Java HashSet.clear怎么用?Java HashSet.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.HashSet
的用法示例。
在下文中一共展示了HashSet.clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkTarget
import java.util.HashSet; //导入方法依赖的package包/类
private void checkTarget(TextView textView) {
synchronized (lock) {
//noinspection unchecked
HashSet<Cancelable> cs = (HashSet<Cancelable>) textView.getTag(TASK_TAG);
if (cs != null) {
if (cs == tasks) {
return;
}
for (Cancelable c : cs) {
c.cancel();
}
cs.clear();
}
textView.setTag(TASK_TAG, tasks);
}
}
示例2: countClusters
import java.util.HashSet; //导入方法依赖的package包/类
public ClusterResult countClusters() {
final HashMap<Long, DictNode> lookup = new HashMap<Long, DictNode>(this.nodes);
int clusterCount = 0;
int maxClusterSize = 0;
int deadLinks = 0;
final HashSet<Long> currentCluster = new HashSet<Long>();
while (lookup.size() > 0) {
DictNode r = (DictNode) lookup.values().toArray()[0];
dfsMarking(r, currentCluster);
if (currentCluster.size() > maxClusterSize) {
maxClusterSize = currentCluster.size();
}
for (long c : currentCluster) {
lookup.remove(c);
}
currentCluster.clear();
clusterCount += 1;
}
return new ClusterResult(clusterCount, maxClusterSize, deadLinks);
}
示例3: removeUserDefinedNodes
import java.util.HashSet; //导入方法依赖的package包/类
private void removeUserDefinedNodes(Element parent) {
HashSet<Node> toRemove = new HashSet<Node>();
NodeList list = parent.getChildNodes();
for (int i=0; i<list.getLength(); i++) {
Node node = list.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
((Element)node).removeAttribute("done");
((Element)node).removeAttribute("hashcode");
if (node.getNodeName().equals("schema-type")) {
toRemove.add(node);
}
else {
removeUserDefinedNodes((Element)node);
}
}
}
Iterator<Node> it = toRemove.iterator();
while (it.hasNext()) {
parent.removeChild(it.next());
}
toRemove.clear();
}
示例4: testGetNextUniqueId
import java.util.HashSet; //导入方法依赖的package包/类
public void testGetNextUniqueId() {
long numIds = 100000;
long numBusyWork = 0;
HashSet<Long> generatedIds = new HashSet<Long>();
long start = System.nanoTime();
for (int ii = 0; ii < numIds; ii++) {
Long id = tim.getNextUniqueTransactionId();
assertEquals( false, generatedIds.contains(id));
generatedIds.add(id);
//make some busy work
for (int zz = 0; zz < numBusyWork; zz++) {
long foo1 = zz;
Long foo2 = foo1;
long foo3 = foo2;
Long foo4 = foo3;
foo4++;
}
}
generatedIds.clear();
long end = System.nanoTime();
double nanosPerId = (end - start) / numIds;
System.out.println("Finished in " + (end - start) + " nanoseconds with " + nanosPerId + " nanoseconds per generated id");
}
示例5: checkColumnDuplication
import java.util.HashSet; //导入方法依赖的package包/类
protected void checkColumnDuplication() {
HashSet cols = new HashSet();
if (getIdentifierMapper() == null ) {
//an identifier mapper => getKey will be included in the getNonDuplicatedPropertyIterator()
//and checked later, so it needs to be excluded
checkColumnDuplication( cols, getKey().getColumnIterator() );
}
checkColumnDuplication( cols, getDiscriminatorColumnIterator() );
checkPropertyColumnDuplication( cols, getNonDuplicatedPropertyIterator() );
Iterator iter = getJoinIterator();
while ( iter.hasNext() ) {
cols.clear();
Join join = (Join) iter.next();
checkColumnDuplication( cols, join.getKey().getColumnIterator() );
checkPropertyColumnDuplication( cols, join.getPropertyIterator() );
}
}
示例6: testAddIndex
import java.util.HashSet; //导入方法依赖的package包/类
public void testAddIndex() throws Exception {
String tablename = "mytable";
String pkname = "id";
String colname = "col";
String ixname = "col_ix";
createBasicTable(tablename, pkname);
addBasicColumn(tablename, colname, Types.VARCHAR, 255);
AddIndexDDL ddl = new AddIndexDDL(getSpecification(), getSchema(),
fixIdentifier(tablename));
HashSet cols = new HashSet();
cols.add(fixIdentifier(colname));
boolean wasException = ddl.execute(ixname, false, cols);
assertFalse(wasException);
assertTrue(columnInIndex(tablename, colname, ixname));
colname = "col2";
ixname = "col2_ix";
addBasicColumn(tablename, colname, Types.VARCHAR, 255);
cols.clear();
cols.add(fixIdentifier(colname));
wasException = ddl.execute(ixname, true, cols);
assertFalse(wasException);
assertTrue(columnInIndex(tablename, colname, ixname));
assertTrue(indexIsUnique(tablename, ixname));
}
示例7: checkGraphLoop
import java.util.HashSet; //导入方法依赖的package包/类
public final void checkGraphLoop(A entity, boolean parents, boolean children) throws ServiceException {
HashSet<Long> checked = new HashSet<Long>();
if (parents) {
checkParents(entity, entity, checked);
}
checked.clear();
if (children) {
checkChildren(entity, entity, checked);
}
}
示例8: testHashCode
import java.util.HashSet; //导入方法依赖的package包/类
@Test
public void testHashCode() {
int max = 100;
HashSet<Integer> codes = new HashSet<>();
for (int x = 1; x <= 100; x++) {
codes.add(AspectRatio.of(x, 1).hashCode());
}
assertThat(codes.size(), is(max));
codes.clear();
for (int y = 1; y <= 100; y++) {
codes.add(AspectRatio.of(1, y).hashCode());
}
assertThat(codes.size(), is(max));
}
示例9: clearNodeSetForAttempt
import java.util.HashSet; //导入方法依赖的package包/类
public void clearNodeSetForAttempt(ApplicationAttemptId attemptId) {
super.writeLock.lock();
try {
HashSet<NodeId> nodeSet = this.appAttemptToNodeKeyMap.get(attemptId);
if (nodeSet != null) {
LOG.info("Clear node set for " + attemptId);
nodeSet.clear();
}
} finally {
super.writeLock.unlock();
}
}
示例10: getFactories
import java.util.HashSet; //导入方法依赖的package包/类
private static Set<Object> getFactories(String serviceName) {
HashSet<Object> result = new HashSet<Object>();
if ((serviceName == null) || (serviceName.length() == 0) ||
(serviceName.endsWith("."))) {
return result;
}
Provider[] providers = Security.getProviders();
HashSet<String> classes = new HashSet<String>();
Object fac;
for (int i = 0; i < providers.length; i++) {
classes.clear();
// Check the keys for each provider.
for (Enumeration<Object> e = providers[i].keys(); e.hasMoreElements(); ) {
String currentKey = (String)e.nextElement();
if (currentKey.startsWith(serviceName)) {
// We should skip the currentKey if it contains a
// whitespace. The reason is: such an entry in the
// provider property contains attributes for the
// implementation of an algorithm. We are only interested
// in entries which lead to the implementation
// classes.
if (currentKey.indexOf(" ") < 0) {
String className = providers[i].getProperty(currentKey);
if (!classes.contains(className)) {
classes.add(className);
try {
fac = loadFactory(providers[i], className);
if (fac != null) {
result.add(fac);
}
}catch (Exception ignore) {
}
}
}
}
}
}
return Collections.unmodifiableSet(result);
}
示例11: internal_removeEdgeNeighborsOfVertex
import java.util.HashSet; //导入方法依赖的package包/类
/**
* internal method for removal the neighbor edges of a vertex
*
* @param vertex the vertex whose neighbors are to be removed
*/
private void internal_removeEdgeNeighborsOfVertex(IVertex vertex) {
if (vertex == null || !hasVertex(vertex))
return;
HashSet<Edge> setIn = _inEdges.get(vertex);
HashSet<Edge> setOut = _outEdges.get(vertex);
Edge edge;
for (Iterator<Edge> iterator = setIn.iterator(); iterator.hasNext(); ) {
edge = iterator.next();
iterator.remove();
internal_removeEdge(edge);
}
for (Iterator<Edge> iterator = setOut.iterator(); iterator.hasNext(); ) {
edge = iterator.next();
iterator.remove();
internal_removeEdge(edge);
}
_colAdjLists.remove(vertex).clear();
setIn.clear();
setOut.clear();
_inEdges.remove(vertex);
_outEdges.remove(vertex);
}
示例12: constructData
import java.util.HashSet; //导入方法依赖的package包/类
public static void constructData(EntityFallingTree of, World w, BlockPos initialPos)
{
synchronized(lock)
{
Map<BlockPos, IBlockState> data = Maps.newConcurrentMap();
HashSet<BlockPos> scannedData = Sets.newHashSet();
data.put(initialPos, w.getBlockState(initialPos));
scannedData.add(initialPos);
tryScanForWood(initialPos.up(), w, scannedData, w.getBlockState(initialPos), data);
scannedData.clear();
of.data = data;
of.isDataConstructed = true;
}
}
示例13: getUniqueExitBlocks
import java.util.HashSet; //导入方法依赖的package包/类
/**
* Returns the unique exit blocks list of this loop.
* <p>
* The unique exit block means that if there are multiple edge from
* a block in loop to this exit block, we just count one.
* </p>
* @return
*/
@Override
public ArrayList<MachineBasicBlock> getUniqueExitBlocks()
{
HashSet<MachineBasicBlock> switchExitBlocks = new HashSet<>();
ArrayList<MachineBasicBlock> exitBBs = new ArrayList<>();
for (MachineBasicBlock curBB : blocks)
{
switchExitBlocks.clear();
for (MachineBasicBlock succBB : curBB.getSuccessors())
{
MachineBasicBlock firstPred = succBB.predAt(0);
if (curBB != firstPred)
continue;
if (curBB.getNumSuccessors() <= 2)
{
exitBBs.add(succBB);
continue;
}
if (!switchExitBlocks.contains(succBB))
{
switchExitBlocks.add(succBB);
exitBBs.add(succBB);
}
}
}
return exitBBs;
}
示例14: UNION
import java.util.HashSet; //导入方法依赖的package包/类
public void UNION(T member1, T member2)
{
HashSet<T> setMember1 = validateGetMemberSet(member1);
HashSet<T> setMember2 = validateGetMemberSet(member2);
for (T t : setMember2) {
_mapMembers.put(t, setMember1);
}
setMember1.addAll(setMember2);
setMember2.clear();
}
示例15: run
import java.util.HashSet; //导入方法依赖的package包/类
public void run() {
HashSet<ChunkCoord> loadedChunksForProcess = new HashSet<ChunkCoord>();
HashSet<ChunkCoord> unloadedChunksForProcess = new HashSet<ChunkCoord>();
Map<World, HashSet<ChunkCoord>> chunksForReload = new WeakHashMap<World, HashSet<ChunkCoord>>();
ArrayList<World> localWorldsToCheck = new ArrayList<World>();
ArrayList<ChunkCoord> reloadedChunks = new ArrayList<ChunkCoord>();
while (!this.isInterrupted() && !kill.get()) {
try {
// Wait until necessary
long timeWait = lastExecute + OrebfuscatorConfig.ChunkReloaderRate - System.currentTimeMillis();
lastExecute = System.currentTimeMillis();
if (timeWait > 0) {
Thread.sleep(timeWait);
}
synchronized (loadedChunks) {
localWorldsToCheck.addAll(loadedChunks.keySet());
}
for(World world : localWorldsToCheck) {
HashSet<ChunkCoord> chunksForReloadForWorld = chunksForReload.get(world);
if(chunksForReloadForWorld == null) {
chunksForReload.put(world, chunksForReloadForWorld = new HashSet<ChunkCoord>());
}
synchronized (unloadedChunks) {
HashSet<ChunkCoord> unloadedChunksForWorld = unloadedChunks.get(world);
if(unloadedChunksForWorld != null && !unloadedChunksForWorld.isEmpty()) {
unloadedChunksForProcess.addAll(unloadedChunksForWorld);
unloadedChunksForWorld.clear();
}
}
for(ChunkCoord unloadedChunk : unloadedChunksForProcess) {
chunksForReloadForWorld.remove(unloadedChunk);
}
unloadedChunksForProcess.clear();
synchronized (loadedChunks) {
HashSet<ChunkCoord> loadedChunksForWorld = loadedChunks.get(world);
if(loadedChunksForWorld != null && !loadedChunksForWorld.isEmpty()) {
loadedChunksForProcess.addAll(loadedChunksForWorld);
loadedChunksForWorld.clear();
}
}
for(ChunkCoord loadedChunk : loadedChunksForProcess) {
ChunkCoord chunk1 = new ChunkCoord(loadedChunk.x - 1, loadedChunk.z);
ChunkCoord chunk2 = new ChunkCoord(loadedChunk.x + 1, loadedChunk.z);
ChunkCoord chunk3 = new ChunkCoord(loadedChunk.x, loadedChunk.z - 1);
ChunkCoord chunk4 = new ChunkCoord(loadedChunk.x, loadedChunk.z + 1);
chunksForReloadForWorld.add(chunk1);
chunksForReloadForWorld.add(chunk2);
chunksForReloadForWorld.add(chunk3);
chunksForReloadForWorld.add(chunk4);
}
loadedChunksForProcess.clear();
if(!chunksForReloadForWorld.isEmpty()) {
reloadChunks(world, chunksForReloadForWorld, reloadedChunks);
chunksForReloadForWorld.removeAll(reloadedChunks);
reloadedChunks.clear();
}
}
localWorldsToCheck.clear();
} catch (Exception e) {
Orebfuscator.log(e);
}
}
}