當前位置: 首頁>>代碼示例>>Java>>正文


Java HashMap.clone方法代碼示例

本文整理匯總了Java中java.util.HashMap.clone方法的典型用法代碼示例。如果您正苦於以下問題:Java HashMap.clone方法的具體用法?Java HashMap.clone怎麽用?Java HashMap.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.HashMap的用法示例。


在下文中一共展示了HashMap.clone方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deepClone

import java.util.HashMap; //導入方法依賴的package包/類
/** Creates deep copy of Map.
* All items will be cloned. Used internally in this object.
*/
private HashMap deepClone(HashMap map) {
    HashMap newone = (HashMap)map.clone();
    Iterator it = newone.keySet().iterator();
    while (it.hasNext()) {
        Object newkey = it.next();
        Object deepobj = null, newobj = newone.get(newkey);
        if (newobj instanceof HashMap)
            deepobj = deepClone((HashMap)newobj);
        else if (newobj instanceof String)
            deepobj = (Object)new String((String)newobj);
        else if (newobj instanceof Vector)
            deepobj = ((Vector)newobj).clone();
        newone.put(newkey, deepobj);
    }

    return newone;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:SpecificationFactory.java

示例2: run

import java.util.HashMap; //導入方法依賴的package包/類
@Override
public void run() {
    HashMap<String,PlayerData> data=Cacher.getInstance().getData();
    Collection<Player> players=getOnlinePlayers();
    HashMap<String,PlayerData> temp= (HashMap<String, PlayerData>) data.clone();
    new BukkitRunnable(){
        @Override
        public void run() {
            for(Map.Entry<String,PlayerData> entry:data.entrySet()){
                if(!players.contains(entry.getKey())){
                    temp.remove(entry.getKey());
                }
            }
            Cacher.getInstance().setData(temp);
        }
    }.runTaskAsynchronously(GlobalPrefix.getInstance());
}
 
開發者ID:Soldier233,項目名稱:GlobalPrefix,代碼行數:18,代碼來源:CacheReleaseTask.java

示例3: getDeletes

import java.util.HashMap; //導入方法依賴的package包/類
@Override
@SuppressWarnings({"deprecation", "unchecked"})
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
	final Type indexType = persister.getIndexType();
	final HashMap snapshot = (HashMap) getSnapshot();
	final HashMap deletes = (HashMap) snapshot.clone();
	deletes.keySet().removeAll( ( (HashMap) getSnapshot( persister ) ).keySet() );
	final ArrayList deleteList = new ArrayList( deletes.size() );
	for ( Object o : deletes.entrySet() ) {
		final Map.Entry me = (Map.Entry) o;
		final Object object = indexIsFormula
				? me.getValue()
				: ( (XmlRepresentableType) indexType ).fromXMLString( (String) me.getKey(), persister.getFactory() );
		if ( object != null ) {
			deleteList.add( object );
		}
	}
	return deleteList.iterator();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:20,代碼來源:PersistentIndexedElementHolder.java

示例4: main

import java.util.HashMap; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    HashMap<Integer, Object> hm = makeMap();
    hm = (HashMap<Integer, Object>)hm.clone();
    hm.clear();
    // There should no longer be a strong reference to testObject
    // the WeakReference should be nulled out by GC. If not,
    // we will hang here until timed out by the test harness.
    Object[] chain = null;
    while (wr.get() != null) {
        try {
            Object[] allocate = new Object[1000000];
            allocate[0] = chain;
            chain = allocate;
        } catch (OutOfMemoryError oome) {
            chain = null;
        }
        System.gc();
        Thread.sleep(100);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:HashMapCloneLeak.java

示例5: clone

import java.util.HashMap; //導入方法依賴的package包/類
/**
 * Returns a clone of the NamespaceMap
 */
@SuppressWarnings("unchecked")
@Override
public Object clone()
{
  NamespaceMap namespaceMap;

  try
  {
    namespaceMap = (NamespaceMap)super.clone();
  }
  catch (CloneNotSupportedException e)
  {
    // this should never happen
    throw new IllegalStateException();
  }

  //
  // clone the key/value pairs
  //
  if (_namespaces != null)
  {
    int length = _namespaces.length;
    Object[] namespaces = new Object[length];
    System.arraycopy(_namespaces, 0, namespaces, 0, length);
    // -= Simon Lessard =-
    // FIXME: Strong ArrayMap's internal functionality coupling here as well
    for (int i = 1; i < length; i += 2)
    {
      HashMap<Object, Object> hm = (HashMap<Object, Object>) namespaces[i];
      if (hm != null)
        namespaces[i] = hm.clone();
    }

    namespaceMap._namespaces = namespaces;
  }

  return namespaceMap;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:42,代碼來源:NamespaceMap.java

示例6: processId

import java.util.HashMap; //導入方法依賴的package包/類
private static void processId(
		PropertyHolder propertyHolder,
		PropertyData inferredData,
		SimpleValue idValue,
		HashMap<String, IdGenerator> classGenerators,
		boolean isIdentifierMapper,
		Mappings mappings) {
	if ( isIdentifierMapper ) {
		throw new AnnotationException(
				"@IdClass class should not have @Id nor @EmbeddedId properties: "
						+ BinderHelper.getPath( propertyHolder, inferredData )
		);
	}
	XClass returnedClass = inferredData.getClassOrElement();
	XProperty property = inferredData.getProperty();
	//clone classGenerator and override with local values
	HashMap<String, IdGenerator> localGenerators = ( HashMap<String, IdGenerator> ) classGenerators.clone();
	localGenerators.putAll( buildLocalGenerators( property, mappings ) );

	//manage composite related metadata
	//guess if its a component and find id data access (property, field etc)
	final boolean isComponent = returnedClass.isAnnotationPresent( Embeddable.class )
			|| property.isAnnotationPresent( EmbeddedId.class );

	GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
	String generatorType = generatedValue != null ?
			generatorType( generatedValue.strategy(), mappings ) :
			"assigned";
	String generatorName = generatedValue != null ?
			generatedValue.generator() :
			BinderHelper.ANNOTATION_STRING_DEFAULT;
	if ( isComponent ) {
		generatorType = "assigned";
	} //a component must not have any generator
	BinderHelper.makeIdGenerator( idValue, generatorType, generatorName, mappings, localGenerators );

	if ( LOG.isTraceEnabled() ) {
		LOG.tracev( "Bind {0} on {1}", ( isComponent ? "@EmbeddedId" : "@Id" ), inferredData.getPropertyName() );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:AnnotationBinder.java

示例7: b

import java.util.HashMap; //導入方法依賴的package包/類
private void b(Platform platform, int i, HashMap<String, Object> hashMap) {
    ShareParams shareParams = hashMap != null ? (ShareParams) hashMap.remove("ShareParams") : null;
    try {
        HashMap hashMap2 = (HashMap) hashMap.clone();
    } catch (Throwable th) {
        Ln.e(th);
        HashMap<String, Object> hashMap3 = hashMap;
    }
    if (shareParams != null) {
        c fVar = new f();
        fVar.o = shareParams.getCustomFlag();
        fVar.b = BMPlatform.NAME_TENCENTWEIBO.equals(platform.getName()) ? platform.getDb().get("name") : platform.getDb().getUserId();
        fVar.a = platform.getPlatformId();
        cn.sharesdk.framework.statistics.b.f.a filterShareContent = platform.filterShareContent(shareParams, hashMap2);
        if (filterShareContent != null) {
            fVar.c = filterShareContent.a;
            fVar.d = filterShareContent;
        }
        fVar.n = b(platform);
        b.a(platform.getContext()).a(fVar);
    }
    if (this.a != null) {
        try {
            this.a.onComplete(platform, i, hashMap);
        } catch (Throwable th2) {
            Ln.w(th2);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:30,代碼來源:a.java

示例8: setMetadata

import java.util.HashMap; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public synchronized void setMetadata(String key,
    HashMap<String, String> metadata) {
  blobs.get(key).metadata = (HashMap<String, String>) metadata.clone();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:6,代碼來源:InMemoryBlockBlobStore.java

示例9: save

import java.util.HashMap; //導入方法依賴的package包/類
void save() {
    HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
    HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
    stack.add(clone);
}
 
開發者ID:ZieIony,項目名稱:RandomData,代碼行數:6,代碼來源:DataContext.java


注:本文中的java.util.HashMap.clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。