TAILIEUCHUNG - Accelerated VB 2005 phần 10

Nhưng, những gì sẽ xảy ra nếu đề tài phát hành khóa đầu đọc và sau đó cố gắng để reacquire khóa đọc trước khi nhà văn đã có một cơ hội để có được các khóa? Nếu đề tài được phép reacquire khóa, sau đó bất kỳ chủ đề chờ đợi trong hàng đợi nhà văn có khả năng có thể thiếu bất cứ lúc nào với khóa. | 364 CHAPTER 15 CANONICAL FORMS two integers the hash values is executed along with the function calls to acquire them. If the call to Equals is expensive then this optimization will return some gains on a lot of the comparisons. If the call to Equals is not expensive then this technique could add overhead and make the code less efficient. It s best to apply the old adage which states that premature optimization is poor optimization and apply such an optimization after a profiler has pointed you in this direction and if you re sure it will help. exists because the developers of the standard library felt it would be convenient to be able to use any object as a key to a hash table. The fact is not all objects are good candidates for hash keys. Usually it s best to use immutable types as hash keys. A good example of an immutable type is . Once created you cannot ever change it. Therefore GetHashCode on a string instance is guaranteed to always return the same value for the same string instance. It becomes more difficult to generate hash codes for objects that are mutable. In those cases it s best to base your GetHashCode implementation on calculations performed on immutable fields inside the mutable object. For the sake of example suppose you want to implement GetHashCode for a ComplexNumber type. One solution is to compute the hash based on the magnitude of the complex number as in the following example Imports System Public NotInheritable Class ComplexNumber Private ReadOnly real As Double Private ReadOnly imaginary As Double Other methods removed for clarity Public Sub New ByVal real As Double ByVal imaginary As Double real imaginary End Sub Public Overrides Function Equals ByVal other As Object As Boolean Dim result As Boolean False Dim that As ComplexNumber TryCast other ComplexNumber If Not that Is Nothing Then result AndAlso End If Return result End Function Public

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.