Changeset 166


Ignore:
Timestamp:
Mar 13, 2007, 11:55:49 AM (18 years ago)
Author:
イグトランス (egtra)
Message:

GetHashCodeを実装

Location:
Include/Classes/System
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • Include/Classes/System/DateTime.ab

    r163 r166  
    8282
    8383    'Copy Constructor
    84     Sub DateTime( ByRef datetime As DateTime )
     84    Sub DateTime(ByRef datetime As DateTime)
    8585        This.m_Date = datetime.m_Date
    8686    End Sub
     
    8989    End Sub
    9090
    91     Function Operator+ (ByRef value As TimeSpan) As DateTime
     91    Function Operator + (ByRef value As TimeSpan) As DateTime
    9292        Dim date As DateTime(Ticks + value.Ticks)
    9393        Return date
    9494    End Function
    9595
    96     Function Operator- (ByRef value As DateTime) As TimeSpan
     96    Function Operator - (ByRef value As DateTime) As TimeSpan
    9797        Return TimeSpan.FromTicks(Ticks - value.Ticks)
    9898    End Function
    9999
    100     Function Operator- (ByRef value As TimeSpan) As DateTime
     100    Function Operator - (ByRef value As TimeSpan) As DateTime
    101101        Dim date As DateTime(Ticks - value.Ticks)
    102102        Return date
     
    254254            Return False
    255255        End If
     256    End Function
     257
     258    Override Function GetHashCode() As Long
     259        Return HIDWORD(m_Date) Xor LODWORD(m_Date)
    256260    End Function
    257261
  • Include/Classes/System/Drawing/CharacterRange.ab

    r11 r166  
    4242    End Sub
    4343
    44     Function Operator == (c As CharacterRange)
     44    Function Operator ==(c As CharacterRange)
    4545        Return Equals(c)
    4646    End Function
    4747
    48     Function Operator <> (c As CharacterRange)
     48    Function Operator <>(c As CharacterRange)
    4949        Return Not Equals(c)
    5050    End Function
     
    5252    Function Equals(c As CharacterRange)
    5353        Return first = c.first And length = c.length
     54    End Function
     55
     56    Override Function GetHashCode() As Long
     57        Return first Xor length
    5458    End Function
    5559
  • Include/Classes/System/Drawing/Color.ab

    r104 r166  
    7575    Sub SetFromCOLORREF(rgb As COLORREF)
    7676        If (rgb And &hff000000) = &h01000000 Then
    77             Exit Sub ' インデックス指定は無効
     77            Exit Sub ' パレットインデックス指定は無効
    7878        Else
    7979            argb = Color_MakeARGB(255, GetRValue(rgb), GetGValue(rgb), GetBValue(rgb))
     
    107107        Dim c As Color(a, r, g, b)
    108108        Return c
     109    End Function
     110
     111    Override Function GetHashCode() As Long
     112        Return argb As Long
    109113    End Function
    110114
  • Include/Classes/System/Drawing/Point.ab

    r104 r166  
    126126    End Function
    127127
     128    Override Function GetHashCode() As Long
     129        Return x Xor _System_BSwap(y As DWord)
     130    End Function
     131
    128132    Static Function Ceiling(ptf As PointF) As Point
    129133        Dim pt As Size(Math.Ceiling(ptf.width), Math.Ceiling(ptf.height))
  • Include/Classes/System/Drawing/PointF.ab

    r104 r166  
    133133    End Function
    134134
     135    Override Function GetHashCode() As Long
     136        Return GetDWord(VarPtr(x)) Xor _System_BSwap(GetDWord(VarPtr(x)))
     137    End Function
     138
    135139Private
    136140    x As Single
  • Include/Classes/System/Drawing/Rectangle.ab

    r104 r166  
    148148    End Function
    149149
     150    Override Function GetHashCode() As Long
     151        Return x Xor _System_BSwap(y) Xor width Xor _System_BSwap(height)
     152    End Function
     153
    150154    Static Function FromLTRB(l As Long, t As Long, r As Long, b As Long) As Rectangle
    151155        Dim rect As Rectangle(l, t, r - l, r - b)
  • Include/Classes/System/Drawing/RectangleF.ab

    r104 r166  
    113113    End Function
    114114
    115     Function Operator = (ByRef rc As RectangleF)
     115    Function Operator =(ByRef rc As RectangleF)
    116116        With rc
    117117            x = .x
     
    122122    End Function
    123123
    124     Function Operator == (ByRef rc As RectangleF)
     124    Function Operator ==(ByRef rc As RectangleF)
    125125        Return Equals(rc)
    126126    End Function
    127127
    128     Function Operator <> (ByRef rc As RectangleF)
     128    Function Operator <>(ByRef rc As RectangleF)
    129129        Return Not Equals(rc)
    130130    End Function
     
    136136            Equals = _System_FALSE
    137137        End If
     138    End Function
     139
     140    Override Function GetHashCode() As Long
     141        Return GetDWord(VarPtr(x)) Xor _System_BSwap(GetDWord(VarPtr(y))) Xor GetDWord(VarPtr(width)) Xor _System_BSwap(GetDWord(VarPtr(height)))
    138142    End Function
    139143
  • Include/Classes/System/Drawing/Size.ab

    r104 r166  
    4040    End Sub
    4141
    42     Function Operator + (sz As Size) As Size
     42    Function Operator +(sz As Size) As Size
    4343        Dim ret As Size(width + sz.width, height + sz.height)
    4444        Return ret
    4545    End Function
    4646
    47     Function Operator - (sz As Size) As Size
     47    Function Operator -(sz As Size) As Size
    4848        Dim ret As Size(width - sz.width, height - sz.height)
    4949        Return ret
     
    5555    End Function
    5656
    57     Function Operator == (sz As Size) As Boolean
     57    Function Operator ==(sz As Size) As Boolean
    5858        Return Equals(sz)
    5959    End Function
    6060
    61     Function Operator <> (sz As Size) As Boolean
     61    Function Operator <>(sz As Size) As Boolean
    6262        Return Not Equals(sz)
    6363    End Function
    6464
    65     Sub Operator = (ByRef sz As Size)
     65    Sub Operator =(ByRef sz As Size)
    6666        width = sz.width
    6767        height = sz.height
     
    7474            Equals = _System_FALSE
    7575        End If
     76    End Function
     77
     78    Override Function GetHashCode() As Long
     79        Return width Xor _System_BSwap(height)
    7680    End Function
    7781
  • Include/Classes/System/Drawing/SizeF.ab

    r104 r166  
    4040    End Sub
    4141
    42     Function Operator + (sz As SizeF) As SizeF
     42    Function Operator +(sz As SizeF) As SizeF
    4343        Dim ret As SizeF(width + sz.width, height + sz.height)
    4444        Return ret
    4545    End Function
    4646
    47     Function Operator - (sz As SizeF) As SizeF
     47    Function Operator -(sz As SizeF) As SizeF
    4848        Dim ret As SizeF(width - sz.width, height - sz.height)
    4949        Return ret
    5050    End Function
    5151
    52     Function Operator == (sz As SizeF) As Boolean
     52    Function Operator ==(sz As SizeF) As Boolean
    5353        Return Equals(sz)
    5454    End Function
    5555
    56     Function Operator <> (sz As SizeF) As Boolean
     56    Function Operator <>(sz As SizeF) As Boolean
    5757        Return Not Equals(sz)
    5858    End Function
    5959
    60     Sub Operator = (ByRef sz As SizeF)
     60    Sub Operator =(ByRef sz As SizeF)
    6161        width = sz.width
    6262        height = sz.height
     
    7070        End If
    7171    End Function
     72
     73    Override Function GetHashCode() As Long
     74        Return VarPtr(GetDWord(width)) Xor _System_BSwap(VarPtr(GetDWord(height)))
    7275
    7376    Function IsEmpty() As Boolean
Note: See TracChangeset for help on using the changeset viewer.