Both sides previous revisionPrevious revisionNext revision | Previous revision |
programming_tips_and_tricks [2017/05/16 20:28] – ledyx | programming_tips_and_tricks [2021/02/07 03:15] (current) – external edit 127.0.0.1 |
---|
=== 합병 정렬(Merge Sort) === | === 합병 정렬(Merge Sort) === |
[[algorithm:Merge Sort | 합병 정렬(Merge Sort)]] | [[algorithm:Merge Sort | 합병 정렬(Merge Sort)]] |
| |
| |
= Design Pattern = | |
| |
== Serialization을 이용한 Deep Copy == | |
<sxh java> | |
/* Java */ | |
@SuppressWarnings("unchecked") | |
public static <T> T deepCopy(T obj) { | |
try { | |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
ObjectOutputStream oos = new ObjectOutputStream(baos); | |
oos.writeObject(obj); | |
| |
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); | |
ObjectInputStream ois = new ObjectInputStream(bais); | |
return (T) ois.readObject(); | |
} catch (IOException e) { | |
return null; | |
} catch (ClassNotFoundException e) { | |
return null; | |
} | |
} | |
</sxh> | |
https://github.com/xeyez/CSharp-PrototypePattern | |
| |
<sxh csharp> | |
/* C# */ | |
public static T DeepCopy<T>(T obj) | |
{ | |
using (var ms = new MemoryStream()) | |
{ | |
var formatter = new BinaryFormatter(); | |
formatter.Serialize(ms, obj); | |
ms.Position = 0; | |
| |
return (T)formatter.Deserialize(ms); | |
} | |
} | |
</sxh> | |
https://github.com/xeyez/Java-PrototypePattern | |
| |
| |
| |
| |
} | } |
} | } |
| </sxh> |
| |
| |
| = Intellij - Git Bash 연동 = |
| |
| Tools -> Terminal |
| |
| <sxh bash> |
| "C:\Program Files\Git\bin\sh.exe" -login -i |
</sxh> | </sxh> |