| 1 | #Region "Microsoft.VisualBasic::0adf314ee86e1490e8e614b81caf2154, Microsoft.VisualBasic.Core\Language\Value\Clones.vb" |
| 2 | |
| 3 | ' Author: |
| 4 | ' |
| 5 | ' asuka (amethyst.asuka@gcmodeller.org) |
| 6 | ' xie (genetics@smrucc.org) |
| 7 | ' xieguigang (xie.guigang@live.com) |
| 8 | ' |
| 9 | ' Copyright (c) 2018 GPL3 Licensed |
| 10 | ' |
| 11 | ' |
| 12 | ' GNU GENERAL PUBLIC LICENSE (GPL3) |
| 13 | ' |
| 14 | ' |
| 15 | ' This program is free software: you can redistribute it and/or modify |
| 16 | ' it under the terms of the GNU General Public License as published by |
| 17 | ' the Free Software Foundation, either version 3 of the License, or |
| 18 | ' (at your option) any later version. |
| 19 | ' |
| 20 | ' This program is distributed in the hope that it will be useful, |
| 21 | ' but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | ' GNU General Public License for more details. |
| 24 | ' |
| 25 | ' You should have received a copy of the GNU General Public License |
| 26 | ' along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 27 | |
| 28 | |
| 29 | |
| 30 | ' /********************************************************************************/ |
| 31 | |
| 32 | ' Summaries: |
| 33 | |
| 34 | ' Module Clones |
| 35 | ' |
| 36 | ' Function: (+5 Overloads) Clone, CloneCopy |
| 37 | ' |
| 38 | ' |
| 39 | ' /********************************************************************************/ |
| 40 | |
| 41 | #End Region |
| 42 | |
| 43 | Imports System.Runtime.CompilerServices |
| 44 | |
| 45 | Namespace Language.Values |
| 46 | |
| 47 | ''' <summary> |
| 48 | ''' Some extension for copy a collection object. |
| 49 | ''' </summary> |
| 50 | Public Module Clones |
| 51 | |
| 52 | ''' <summary> |
| 53 | ''' Creates a new dictionary |
| 54 | ''' </summary> |
| 55 | ''' <typeparam name="T"></typeparam> |
| 56 | ''' <typeparam name="V"></typeparam> |
| 57 | ''' <param name="table"></param> |
| 58 | ''' <returns></returns> |
| 59 | <Extension> Public Function Clone(Of T, V)(table As IDictionary(Of T, V)) As Dictionary(Of T, V) |
| 60 | Return New Dictionary(Of T, V)(table) |
| 61 | End Function |
| 62 | |
| 63 | <Extension> Public Function Clone(Of T)(list As List(Of T)) As List(Of T) |
| 64 | Return New List(Of T)(list) |
| 65 | End Function |
| 66 | |
| 67 | <Extension> Public Function CloneCopy(Of T)(array As T()) As T() |
| 68 | Return DirectCast(array.Clone, T()) |
| 69 | End Function |
| 70 | |
| 71 | <Extension> Public Function Clone(s As String) As String |
| 72 | Return New String(s.ToCharArray) |
| 73 | End Function |
| 74 | |
| 75 | <Extension> Public Function Clone(int As int) As int |
| 76 | Return New int(int.value) |
| 77 | End Function |
| 78 | |
| 79 | <Extension> Public Function Clone(float As float) As float |
| 80 | Return New float(float.value) |
| 81 | End Function |
| 82 | End Module |
| 83 | End Namespace |