From commits-return-6526-apmail-lucenenet-commits-archive=lucenenet.apache.org@lucenenet.apache.org Tue Dec 17 17:00:58 2019 Return-Path: X-Original-To: apmail-lucenenet-commits-archive@www.apache.org Delivered-To: apmail-lucenenet-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id 41860190D2 for ; Tue, 17 Dec 2019 17:00:58 +0000 (UTC) Received: (qmail 96001 invoked by uid 500); 17 Dec 2019 17:00:57 -0000 Delivered-To: apmail-lucenenet-commits-archive@lucenenet.apache.org Received: (qmail 95933 invoked by uid 500); 17 Dec 2019 17:00:57 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 95774 invoked by uid 99); 17 Dec 2019 17:00:56 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Dec 2019 17:00:56 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id B4BF48D811; Tue, 17 Dec 2019 17:00:56 +0000 (UTC) Date: Tue, 17 Dec 2019 17:00:58 +0000 To: "commits@lucenenet.apache.org" Subject: [lucenenet] 02/04: Lucene.Net.Support.HashMap: Changed implementation to distinguish between null value and missing element for consistent behavior between value and reference types. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: nightowl888@apache.org In-Reply-To: <157660205661.16847.15629073092912553791@gitbox.apache.org> References: <157660205661.16847.15629073092912553791@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: lucenenet X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: f13ba5777f34aa639555487783285648e0525be5 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20191217170056.B4BF48D811@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git commit f13ba5777f34aa639555487783285648e0525be5 Author: Shad Storhaug AuthorDate: Tue Dec 17 14:06:55 2019 +0700 Lucene.Net.Support.HashMap: Changed implementation to distinguish between null value and missing element for consistent behavior between value and reference types. --- src/Lucene.Net/Support/HashMap.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Lucene.Net/Support/HashMap.cs b/src/Lucene.Net/Support/HashMap.cs index 75fe996..9136880 100644 --- a/src/Lucene.Net/Support/HashMap.cs +++ b/src/Lucene.Net/Support/HashMap.cs @@ -35,22 +35,14 @@ namespace Lucene.Net.Support /// the Hashmap supports both null keys and values, where the C# Dictionary /// only supports null values not keys. Also, V Get(TKey) /// method in Java returns null if the key doesn't exist, instead of throwing - /// an exception. This implementation doesn't throw an exception when a key - /// doesn't exist, it will return null. This class is slower than using a + /// an exception. In .NET, using + /// will provide similar behavior as V Get(TKey) This class is slower than using a /// , because of extra checks that have to be /// done on each access, to check for null. /// - /// - /// NOTE: This class works best with nullable types. default(T) is returned - /// when a key doesn't exist in the collection (this being similar to how Java returns - /// null). Therefore, if the expected behavior of the java code is to execute code - /// based on if the key exists, when the key is an integer type, it will return 0 instead of null. - /// - /// /// Consider also implementing IDictionary, IEnumerable, and ICollection /// like does, so HashMap can be /// used in substituted in place for the same interfaces it implements. - /// /// /// The type of keys in the dictionary /// The type of values in the dictionary @@ -63,7 +55,7 @@ namespace Lucene.Net.Support ///

Ordered Dictionaries

/// /// - use when you need to preserve entry insertion order. Keys are nullable. - /// - use when you need natural sort order. Keys must be unique. + /// - use when you need natural sort order. Null keys are not supported. /// - use when you need natural sort order. Keys are nullable. /// - use when you need to sort by most recent access or most recent update. Works well for LRU caching. /// @@ -390,7 +382,7 @@ namespace Lucene.Net.Support } return _nullValue; } - return _dict.ContainsKey(key) ? _dict[key] : default(TValue); + return _dict[key]; } set { Add(key, value); } }