-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.9.3: can now clone large LinkedHashMap
- Loading branch information
1 parent
b9c2036
commit 54b50ca
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/rits/cloning/FastClonerLinkedHashMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.rits.cloning; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author kostantinos.kougios | ||
* | ||
* 21 May 2009 | ||
*/ | ||
public class FastClonerLinkedHashMap implements IFastCloner { | ||
@SuppressWarnings({"unchecked", "rawtypes"}) | ||
public Object clone(final Object t, final IDeepCloner cloner, final Map<Object, Object> clones) { | ||
final LinkedHashMap<?, ?> al = (LinkedHashMap) t; | ||
final LinkedHashMap result = new LinkedHashMap(); | ||
for (final Map.Entry e : al.entrySet()) { | ||
final Object key = cloner.deepClone(e.getKey(), clones); | ||
final Object value = cloner.deepClone(e.getValue(), clones); | ||
|
||
result.put(key, value); | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters