1 #Region "Microsoft.VisualBasic::585af9b6e34291ded89ba898745a1541, Microsoft.VisualBasic.Core\ComponentModel\Ranges\Sequence.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     '     Class Sequence
35     
36     '         Properties: Max, Min, n, Range, Steps
37     
38     '         Constructor: (+2 OverloadsSub New
39     '         Function: (+2 OverloadsIsInside, IsOverlapping, ToArray, ToString
40     
41     
42     ' /********************************************************************************/
43
44 #End Region
45
46 Imports System.Runtime.CompilerServices
47 Imports System.Xml.Serialization
48 Imports Microsoft.VisualBasic.ComponentModel.Ranges.Model
49
50 Namespace ComponentModel.Ranges
51
52     <XmlType("numeric-sequence")>
53     Public Class Sequence : Implements IRanges(Of Double)
54
55         <XmlElement("range")>
56         Public Property Range As DoubleRange
57         <XmlAttribute>
58         Public Property n As Integer
59
60         Public ReadOnly Property StepAs Double
61             <MethodImpl(MethodImplOptions.AggressiveInlining)>
62             Get
63                 Return Range.Length / n
64             End Get
65         End Property
66
67         Public ReadOnly Property Min As Double Implements IRange(Of Double).Min
68             <MethodImpl(MethodImplOptions.AggressiveInlining)>
69             Get
70                 Return Range.Min
71             End Get
72         End Property
73         Public ReadOnly Property Max As Double Implements IRange(Of Double).Max
74             <MethodImpl(MethodImplOptions.AggressiveInlining)>
75             Get
76                 Return Range.Max
77             End Get
78         End Property
79
80         Sub New(a#, b#, n%)
81             Me.Range = New DoubleRange(a, b)
82             Me.n = n
83         End Sub
84
85         Sub New()
86
87         End Sub
88
89         <MethodImpl(MethodImplOptions.AggressiveInlining)>
90         Public Function IsInside(x As DoubleAs Boolean Implements IRanges(Of Double).IsInside
91             Return Range.IsInside(x)
92         End Function
93
94         <MethodImpl(MethodImplOptions.AggressiveInlining)>
95         Public Function IsInside(range As IRanges(Of Double)) As Boolean Implements IRanges(Of Double).IsInside
96             Return range.IsInside(range)
97         End Function
98
99         <MethodImpl(MethodImplOptions.AggressiveInlining)>
100         Public Function IsOverlapping(range As IRanges(Of Double)) As Boolean Implements IRanges(Of Double).IsOverlapping
101             Return range.IsOverlapping(range)
102         End Function
103
104         <MethodImpl(MethodImplOptions.AggressiveInlining)>
105         Public Function ToArray() As Double()
106             Return Range.Enumerate(n)
107         End Function
108
109         Public Overrides Function ToString() As String
110             Return Range.ToString
111         End Function
112     End Class
113 End Namespace