You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2021/07/24 19:12:31 UTC

[lucenenet] branch master updated: Lucene.Net.Support.ListExtensions::SubList(): Factored out in favor of J2N's GetView() method

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


The following commit(s) were added to refs/heads/master by this push:
     new d58ed59  Lucene.Net.Support.ListExtensions::SubList(): Factored out in favor of J2N's GetView() method
d58ed59 is described below

commit d58ed592d43ed3f0e6a2187c618efc1c4730ea73
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Sat Jul 24 02:43:37 2021 +0700

    Lucene.Net.Support.ListExtensions::SubList(): Factored out in favor of J2N's GetView() method
---
 .../JapaneseTokenizer.cs                           |   8 +-
 .../Morfologik/MorfologikFilter.cs                 |   5 +-
 src/Lucene.Net.Analysis.SmartCn/Hhmm/BiSegGraph.cs |   7 +-
 src/Lucene.Net.Analysis.SmartCn/WordSegmenter.cs   |   3 +-
 .../Core/Processors/QueryNodeProcessorPipeline.cs  |  11 +-
 .../Surround/Query/ComposedQuery.cs                |   3 +-
 .../Surround/Query/NotQuery.cs                     |  12 +-
 .../Surround/Query/SrndBooleanQuery.cs             |   5 +-
 .../Suggest/Analyzing/FreeTextSuggester.cs         |   2 +-
 .../Suggest/Fst/FSTCompletion.cs                   |  11 +-
 .../Index/MockRandomMergePolicy.cs                 |  12 +-
 src/Lucene.Net.TestFramework/Index/RandomCodec.cs  |  10 +-
 .../Util/LuceneTestCase.cs                         |   4 +-
 .../Taxonomy/TestTaxonomyFacetCounts2.cs           |  10 +-
 .../GroupFacetCollectorTest.cs                     |   6 +-
 src/Lucene.Net.Tests.Queries/TermsFilterTest.cs    |   4 +-
 .../Suggest/Analyzing/AnalyzingSuggesterTest.cs    |   5 +-
 .../Suggest/Analyzing/FuzzySuggesterTest.cs        |   4 +-
 .../Suggest/Analyzing/TestFreeTextSuggester.cs     |   4 +-
 .../Suggest/Fst/WFSTCompletionTest.cs              |   2 +-
 .../Suggest/LookupBenchmarkTest.cs                 |   5 +-
 src/Lucene.Net.Tests/Index/Test2BTerms.cs          |   5 +-
 .../Index/TestPerSegmentDeletes.cs                 |   5 +-
 src/Lucene.Net.Tests/Search/TestMinShouldMatch2.cs |  10 +-
 src/Lucene.Net.Tests/Search/TestShardSearching.cs  |   2 +-
 src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs          |   4 +-
 src/Lucene.Net/Codecs/BlockTreeTermsWriter.cs      |  10 +-
 src/Lucene.Net/Index/BufferedUpdatesStream.cs      |   6 +-
 src/Lucene.Net/Index/LogMergePolicy.cs             |  21 +--
 src/Lucene.Net/Index/SegmentInfos.cs               |   6 +-
 src/Lucene.Net/Index/TieredMergePolicy.cs          |  10 +-
 src/Lucene.Net/Search/FuzzyTermsEnum.cs            |   2 +-
 src/Lucene.Net/Support/ListExtensions.cs           | 174 ---------------------
 src/Lucene.Net/Util/FieldCacheSanityChecker.cs     |   4 +-
 src/Lucene.Net/Util/Fst/BytesStore.cs              |   4 +-
 35 files changed, 118 insertions(+), 278 deletions(-)

diff --git a/src/Lucene.Net.Analysis.Kuromoji/JapaneseTokenizer.cs b/src/Lucene.Net.Analysis.Kuromoji/JapaneseTokenizer.cs
index a635e98..efcb9b6 100644
--- a/src/Lucene.Net.Analysis.Kuromoji/JapaneseTokenizer.cs
+++ b/src/Lucene.Net.Analysis.Kuromoji/JapaneseTokenizer.cs
@@ -12,6 +12,7 @@ using System.Globalization;
 using System.IO;
 using System.Threading;
 using Console = Lucene.Net.Util.SystemConsole;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Analysis.Ja
 {
@@ -123,7 +124,7 @@ namespace Lucene.Net.Analysis.Ja
         private int pos;
 
         // Already parsed, but not yet passed to caller, tokens:
-        private readonly IList<Token> pending = new List<Token>();
+        private readonly JCG.List<Token> pending = new JCG.List<Token>();
 
         private readonly ICharTermAttribute termAtt;
         private readonly IOffsetAttribute offsetAtt;
@@ -1098,8 +1099,9 @@ namespace Lucene.Net.Analysis.Ja
                     // Reverse the tokens we just added, because when we
                     // serve them up from incrementToken we serve in
                     // reverse:
-                    Collections.Reverse(pending.SubList(pending.Count - (wordIDAndLength.Length - 1),
-                                                        pending.Count));
+                    pending.Reverse(pending.Count - (wordIDAndLength.Length - 1),
+                        wordIDAndLength.Length - 1); // LUCENENET: Converted from reverse on SubList to reverse on List<T> and converted end index to length
+
 
                     backCount += wordIDAndLength.Length - 1;
                 }
diff --git a/src/Lucene.Net.Analysis.Morfologik/Morfologik/MorfologikFilter.cs b/src/Lucene.Net.Analysis.Morfologik/Morfologik/MorfologikFilter.cs
index 96071c1..b2f0bd1 100644
--- a/src/Lucene.Net.Analysis.Morfologik/Morfologik/MorfologikFilter.cs
+++ b/src/Lucene.Net.Analysis.Morfologik/Morfologik/MorfologikFilter.cs
@@ -11,6 +11,7 @@ using System.Collections.Generic;
 using System.Globalization;
 using System.Text;
 using System.Text.RegularExpressions;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Analysis.Morfologik
 {
@@ -52,7 +53,7 @@ namespace Lucene.Net.Analysis.Morfologik
         private readonly IStemmer stemmer;
 
         private IList<WordData> lemmaList;
-        private readonly List<StringBuilder> tagsList = new List<StringBuilder>();
+        private readonly JCG.List<StringBuilder> tagsList = new JCG.List<StringBuilder>();
 
         private int lemmaListIndex;
 
@@ -109,7 +110,7 @@ namespace Lucene.Net.Analysis.Morfologik
                     buffer.Length = 0;
                     buffer.Append(tags[i]);
                 }
-                tagsAtt.Tags = tagsList.SubList(0, tags.Length);
+                tagsAtt.Tags = tagsList.GetView(0, tags.Length - 0); // LUCENENET: Converted end index to length
             }
             else
             {
diff --git a/src/Lucene.Net.Analysis.SmartCn/Hhmm/BiSegGraph.cs b/src/Lucene.Net.Analysis.SmartCn/Hhmm/BiSegGraph.cs
index fd01294..94dd645 100644
--- a/src/Lucene.Net.Analysis.SmartCn/Hhmm/BiSegGraph.cs
+++ b/src/Lucene.Net.Analysis.SmartCn/Hhmm/BiSegGraph.cs
@@ -3,6 +3,7 @@ using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
 using System.Text;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Analysis.Cn.Smart.Hhmm
 {
@@ -181,7 +182,7 @@ namespace Lucene.Net.Analysis.Cn.Smart.Hhmm
         {
             int current;
             int nodeCount = ToCount;
-            IList<PathNode> path = new List<PathNode>();
+            IList<PathNode> path = new JCG.List<PathNode>();
             PathNode zeroPath = new PathNode();
             zeroPath.Weight = 0;
             zeroPath.PreNode = 0;
@@ -213,8 +214,8 @@ namespace Lucene.Net.Analysis.Cn.Smart.Hhmm
             int preNode, lastNode;
             lastNode = path.Count - 1;
             current = lastNode;
-            IList<int> rpath = new List<int>();
-            IList<SegToken> resultPath = new List<SegToken>();
+            IList<int> rpath = new JCG.List<int>();
+            IList<SegToken> resultPath = new JCG.List<SegToken>();
 
             rpath.Add(current);
             while (current != 0)
diff --git a/src/Lucene.Net.Analysis.SmartCn/WordSegmenter.cs b/src/Lucene.Net.Analysis.SmartCn/WordSegmenter.cs
index 66bd89c..5ddddf7 100644
--- a/src/Lucene.Net.Analysis.SmartCn/WordSegmenter.cs
+++ b/src/Lucene.Net.Analysis.SmartCn/WordSegmenter.cs
@@ -1,4 +1,5 @@
 // lucene version compatibility level: 4.8.1
+using J2N.Collections.Generic.Extensions;
 using Lucene.Net.Analysis.Cn.Smart.Hhmm;
 using Lucene.Net.Support;
 using System.Collections.Generic;
@@ -47,7 +48,7 @@ namespace Lucene.Net.Analysis.Cn.Smart
             IList<SegToken> result = Collections.EmptyList<SegToken>();
 
             if (segTokenList.Count > 2) // if its not an empty sentence
-                result = segTokenList.SubList(1, segTokenList.Count - 1);
+                result = segTokenList.GetView(1, segTokenList.Count - 2); // LUCENENET: Converted end index to length
 
             foreach (SegToken st in result)
             {
diff --git a/src/Lucene.Net.QueryParser/Flexible/Core/Processors/QueryNodeProcessorPipeline.cs b/src/Lucene.Net.QueryParser/Flexible/Core/Processors/QueryNodeProcessorPipeline.cs
index 0f2e855..ca5c111 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Core/Processors/QueryNodeProcessorPipeline.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Core/Processors/QueryNodeProcessorPipeline.cs
@@ -2,6 +2,7 @@
 using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
 using System.Collections;
 using System.Collections.Generic;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.QueryParsers.Flexible.Core.Processors
 {
@@ -37,7 +38,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Core.Processors
     /// </summary>
     public class QueryNodeProcessorPipeline : IQueryNodeProcessor, IList<IQueryNodeProcessor>
     {
-        private readonly List<IQueryNodeProcessor> processors = new List<IQueryNodeProcessor>();
+        private readonly JCG.List<IQueryNodeProcessor> processors = new JCG.List<IQueryNodeProcessor>();
 
         private QueryConfigHandler queryConfig;
 
@@ -219,6 +220,14 @@ namespace Lucene.Net.QueryParsers.Flexible.Core.Processors
             return this.processors.GetRange(index, count);
         }
 
+        /// <summary>
+        /// <see cref="JCG.List{T}.GetView(int, int)"/>
+        /// </summary>
+        public virtual IList<IQueryNodeProcessor> GetView(int index, int count)
+        {
+            return this.processors.GetView(index, count);
+        }
+
         public virtual void Insert(int index, IQueryNodeProcessor item)
         {
             this.processors.Insert(index, item);
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/ComposedQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/ComposedQuery.cs
index 1c154c4..d263996 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/ComposedQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/ComposedQuery.cs
@@ -2,6 +2,7 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.QueryParsers.Surround.Query
 {
@@ -59,7 +60,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
 
         public virtual IList<Search.Query> MakeLuceneSubQueriesField(string fn, BasicQueryFactory qf)
         {
-            List<Search.Query> luceneSubQueries = new List<Search.Query>();
+            IList<Search.Query> luceneSubQueries = new JCG.List<Search.Query>();
             using (IEnumerator<SrndQuery> sqi = GetSubQueriesEnumerator())
             {
                 while (sqi.MoveNext())
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/NotQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/NotQuery.cs
index 13a8ba9..20386b9 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/NotQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/NotQuery.cs
@@ -1,4 +1,5 @@
-using Lucene.Net.Search;
+using J2N.Collections.Generic.Extensions;
+using Lucene.Net.Search;
 using System.Collections.Generic;
 
 namespace Lucene.Net.QueryParsers.Surround.Query
@@ -38,15 +39,10 @@ namespace Lucene.Net.QueryParsers.Surround.Query
                 { luceneSubQueries.Count > 0 ? luceneSubQueries[0] : null, Occur.MUST }
             };
 
-            // LUCENENET: SubList() is slow, so we do an array copy operation instead
-            var luceneSubQueriesArray = new Search.Query[luceneSubQueries.Count - 1];
-            for (int i = 1, j = 0; i < luceneSubQueries.Count; i++, j++)
-                luceneSubQueriesArray[j] = luceneSubQueries[i];
-
             SrndBooleanQuery.AddQueriesToBoolean(bq,
                     // FIXME: do not allow weights on prohibited subqueries.
-                    luceneSubQueriesArray,
-                // later subqueries: not required, prohibited
+                    luceneSubQueries.GetView(1, luceneSubQueries.Count - 1), // LUCENENET: Converted end index to length
+                    // later subqueries: not required, prohibited
                     Occur.MUST_NOT);
             return bq;
         }
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/SrndBooleanQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/SrndBooleanQuery.cs
index 11ca8e7..a79c24e 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/SrndBooleanQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/SrndBooleanQuery.cs
@@ -1,6 +1,5 @@
-using Lucene.Net.Diagnostics;
+using J2N.Collections.Generic.Extensions;
 using Lucene.Net.Search;
-using System;
 using System.Collections.Generic;
 
 namespace Lucene.Net.QueryParsers.Surround.Query
@@ -44,7 +43,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
                 throw AssertionError.Create("Too few subqueries: " + queries.Count);
             }
             BooleanQuery bq = new BooleanQuery();
-            AddQueriesToBoolean(bq, queries, occur);
+            AddQueriesToBoolean(bq, queries.GetView(0, queries.Count), occur);
             return bq;
         }
     }
diff --git a/src/Lucene.Net.Suggest/Suggest/Analyzing/FreeTextSuggester.cs b/src/Lucene.Net.Suggest/Suggest/Analyzing/FreeTextSuggester.cs
index e5f5b35..347defa 100644
--- a/src/Lucene.Net.Suggest/Suggest/Analyzing/FreeTextSuggester.cs
+++ b/src/Lucene.Net.Suggest/Suggest/Analyzing/FreeTextSuggester.cs
@@ -799,7 +799,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
 
                 if (results.Count > num)
                 {
-                    results.RemoveRange(num, results.Count - num); //results.SubList(num, results.Count).Clear();
+                    results.RemoveRange(num, results.Count - num); // LUCENENET: Converted end index to length
                 }
 
                 return results;
diff --git a/src/Lucene.Net.Suggest/Suggest/Fst/FSTCompletion.cs b/src/Lucene.Net.Suggest/Suggest/Fst/FSTCompletion.cs
index bfd8daf..1bbd8eb 100644
--- a/src/Lucene.Net.Suggest/Suggest/Fst/FSTCompletion.cs
+++ b/src/Lucene.Net.Suggest/Suggest/Fst/FSTCompletion.cs
@@ -4,9 +4,8 @@ using Lucene.Net.Util;
 using Lucene.Net.Util.Fst;
 using System;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.Globalization;
-using System.IO;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Search.Suggest.Fst
 {
@@ -263,7 +262,7 @@ namespace Lucene.Net.Search.Suggest.Fst
         /// constant</c>. This is a workaround: in general, use constant weights for
         /// alphabetically sorted result.
         /// </summary>
-        private List<Completion> LookupSortedAlphabetically(BytesRef key, int num)
+        private JCG.List<Completion> LookupSortedAlphabetically(BytesRef key, int num)
         {
             // Greedily get num results from each weight branch.
             var res = LookupSortedByWeight(key, num, true);
@@ -272,7 +271,7 @@ namespace Lucene.Net.Search.Suggest.Fst
             res.Sort();
             if (res.Count > num)
             {
-                res = res.GetRange(0, num - 0);
+                res = res.GetView(0, num - 0); // LUCENENET: Converted end index to length
             }
             return res;
         }
@@ -285,12 +284,12 @@ namespace Lucene.Net.Search.Suggest.Fst
         ///          <paramref name="num"/> suggestions have been collected. If
         ///          <c>false</c>, it will collect suggestions from all weight
         ///          arcs (needed for <see cref="LookupSortedAlphabetically"/>. </param>
-        private List<Completion> LookupSortedByWeight(BytesRef key, int num, bool collectAll)
+        private JCG.List<Completion> LookupSortedByWeight(BytesRef key, int num, bool collectAll)
         {
             // Don't overallocate the results buffers. This also serves the purpose of
             // allowing the user of this class to request all matches using Integer.MAX_VALUE as
             // the number of results.
-            List<Completion> res = new List<Completion>(Math.Min(10, num));
+            JCG.List<Completion> res = new JCG.List<Completion>(Math.Min(10, num));
 
             BytesRef output = BytesRef.DeepCopyOf(key);
             for (int i = 0; i < rootArcs.Length; i++)
diff --git a/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs b/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
index d7ca5ad..3a811ff 100644
--- a/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
+++ b/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
@@ -1,9 +1,9 @@
-using J2N.Collections.Generic.Extensions;
+using J2N.Collections.Generic.Extensions;
 using Lucene.Net.Diagnostics;
-using Lucene.Net.Support;
 using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Index
 {
@@ -45,7 +45,7 @@ namespace Lucene.Net.Index
 
             int numSegments/* = segmentInfos.Count*/; // LUCENENET: IDE0059: Remove unnecessary value assignment
 
-            IList<SegmentCommitInfo> segments = new List<SegmentCommitInfo>();
+            JCG.List<SegmentCommitInfo> segments = new JCG.List<SegmentCommitInfo>();
             ICollection<SegmentCommitInfo> merging = base.m_writer.Get().MergingSegments;
 
             foreach (SegmentCommitInfo sipc in segmentInfos.Segments)
@@ -65,7 +65,7 @@ namespace Lucene.Net.Index
                 // TODO: sometimes make more than 1 merge?
                 mergeSpec = new MergeSpecification();
                 int segsToMerge = TestUtil.NextInt32(random, 1, numSegments);
-                mergeSpec.Add(new OneMerge(segments.SubList(0, segsToMerge)));
+                mergeSpec.Add(new OneMerge(segments.GetView(0, segsToMerge))); // LUCENENET: Checked length for correctness
             }
 
             return mergeSpec;
@@ -73,7 +73,7 @@ namespace Lucene.Net.Index
 
         public override MergeSpecification FindForcedMerges(SegmentInfos segmentInfos, int maxSegmentCount, IDictionary<SegmentCommitInfo, bool?> segmentsToMerge)
         {
-            IList<SegmentCommitInfo> eligibleSegments = new List<SegmentCommitInfo>();
+            JCG.List<SegmentCommitInfo> eligibleSegments = new JCG.List<SegmentCommitInfo>();
             foreach (SegmentCommitInfo info in segmentInfos.Segments)
             {
                 if (segmentsToMerge.ContainsKey(info))
@@ -95,7 +95,7 @@ namespace Lucene.Net.Index
                 {
                     int max = Math.Min(10, eligibleSegments.Count - upto);
                     int inc = max <= 2 ? max : TestUtil.NextInt32(random, 2, max);
-                    mergeSpec.Add(new OneMerge(eligibleSegments.SubList(upto, upto + inc)));
+                    mergeSpec.Add(new OneMerge(eligibleSegments.GetView(upto, inc))); // LUCENENET: Converted end index to length
                     upto += inc;
                 }
             }
diff --git a/src/Lucene.Net.TestFramework/Index/RandomCodec.cs b/src/Lucene.Net.TestFramework/Index/RandomCodec.cs
index 8573da5..0f41316 100644
--- a/src/Lucene.Net.TestFramework/Index/RandomCodec.cs
+++ b/src/Lucene.Net.TestFramework/Index/RandomCodec.cs
@@ -1,4 +1,4 @@
-using Lucene.Net.Codecs;
+using Lucene.Net.Codecs;
 using Lucene.Net.Codecs.Asserting;
 using Lucene.Net.Codecs.Bloom;
 using Lucene.Net.Codecs.DiskDV;
@@ -56,11 +56,11 @@ namespace Lucene.Net.Index
     {
         /// <summary>
         /// Shuffled list of postings formats to use for new mappings </summary>
-        private readonly IList<PostingsFormat> formats = new List<PostingsFormat>(); // LUCENENET: marked readonly
+        private readonly JCG.List<PostingsFormat> formats = new JCG.List<PostingsFormat>(); // LUCENENET: marked readonly
 
         /// <summary>
         /// Shuffled list of docvalues formats to use for new mappings </summary>
-        private readonly IList<DocValuesFormat> dvFormats = new List<DocValuesFormat>(); // LUCENENET: marked readonly
+        private readonly JCG.List<DocValuesFormat> dvFormats = new JCG.List<DocValuesFormat>(); // LUCENENET: marked readonly
 
         /// <summary>
         /// unique set of format names this codec knows about </summary>
@@ -174,11 +174,11 @@ namespace Lucene.Net.Index
             // Avoid too many open files:
             if (formats.Count > 4)
             {
-                formats = formats.SubList(0, 4);
+                formats = formats.GetView(0, 4); // LUCENENET: Checked length for correctness
             }
             if (dvFormats.Count > 4)
             {
-                dvFormats = dvFormats.SubList(0, 4);
+                dvFormats = dvFormats.GetView(0, 4); // LUCENENET: Checked length for correctness
             }
         }
 
diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index 1a32801..2dcc036 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -2190,14 +2190,14 @@ namespace Lucene.Net.Util
 
                         case 3:
                             AtomicReader ar = SlowCompositeReaderWrapper.Wrap(r);
-                            IList<string> allFields = new List<string>();
+                            JCG.List<string> allFields = new JCG.List<string>();
                             foreach (FieldInfo fi in ar.FieldInfos)
                             {
                                 allFields.Add(fi.Name);
                             }
                             allFields.Shuffle(Random);
                             int end = allFields.Count == 0 ? 0 : random.Next(allFields.Count);
-                            ISet<string> fields = new JCG.HashSet<string>(allFields.SubList(0, end));
+                            ISet<string> fields = new JCG.HashSet<string>(allFields.GetView(0, end)); // LUCENENET: Checked length for correctness
                             // will create no FC insanity as ParallelAtomicReader has own cache key:
                             r = new ParallelAtomicReader(new FieldFilterAtomicReader(ar, fields, false), new FieldFilterAtomicReader(ar, fields, true));
                             break;
diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetCounts2.cs b/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetCounts2.cs
index 284547b..fcf6f40 100644
--- a/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetCounts2.cs
+++ b/src/Lucene.Net.Tests.Facet/Taxonomy/TestTaxonomyFacetCounts2.cs
@@ -1,13 +1,13 @@
 // Lucene version compatibility level 4.8.1
 using J2N.Collections.Generic.Extensions;
 using Lucene.Net.Index;
-using Lucene.Net.Support;
 using NUnit.Framework;
 using RandomizedTesting.Generators;
 using System;
 using System.Collections.Generic;
 using System.Globalization;
 using Assert = Lucene.Net.TestFramework.Assert;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Facet.Taxonomy
 {
@@ -100,16 +100,16 @@ namespace Lucene.Net.Facet.Taxonomy
             // category is not added twice.
             int numFacetsA = random.Next(3) + 1; // 1-3
             int numFacetsB = random.Next(2) + 1; // 1-2
-            List<FacetField> categories_a = new List<FacetField>();
+            JCG.List<FacetField> categories_a = new JCG.List<FacetField>();
             categories_a.AddRange(CATEGORIES_A);
-            List<FacetField> categories_b = new List<FacetField>();
+            JCG.List<FacetField> categories_b = new JCG.List<FacetField>();
             categories_b.AddRange(CATEGORIES_B);
             categories_a.Shuffle(Random);
             categories_b.Shuffle(Random);
 
             List<FacetField> categories = new List<FacetField>();
-            categories.AddRange(categories_a.SubList(0, numFacetsA));
-            categories.AddRange(categories_b.SubList(0, numFacetsB));
+            categories.AddRange(categories_a.GetView(0, numFacetsA)); // LUCENENET: Checked length for correctness
+            categories.AddRange(categories_b.GetView(0, numFacetsB)); // LUCENENET: Checked length for correctness
 
             // add the NO_PARENT categories
             categories.Add(CATEGORIES_C[Util.LuceneTestCase.Random.Next(NUM_CHILDREN_CP_C)]);
diff --git a/src/Lucene.Net.Tests.Grouping/GroupFacetCollectorTest.cs b/src/Lucene.Net.Tests.Grouping/GroupFacetCollectorTest.cs
index 7a7a2ad..4c4f0d6 100644
--- a/src/Lucene.Net.Tests.Grouping/GroupFacetCollectorTest.cs
+++ b/src/Lucene.Net.Tests.Grouping/GroupFacetCollectorTest.cs
@@ -756,7 +756,7 @@ namespace Lucene.Net.Search.Grouping
                 facetValues = context.facetValues;
             }
 
-            List<TermGroupFacetCollector.FacetEntry> entries = new List<TermGroupFacetCollector.FacetEntry>(facetGroups.size());
+            JCG.List<TermGroupFacetCollector.FacetEntry> entries = new JCG.List<TermGroupFacetCollector.FacetEntry>(facetGroups.size());
             // also includes facets with count 0
             foreach (string facetValue in facetValues)
             {
@@ -802,11 +802,11 @@ namespace Lucene.Net.Search.Grouping
             }
             else if (endOffset >= entries.size())
             {
-                entriesResult = entries.GetRange(offset, entries.size() - offset);
+                entriesResult = entries.GetView(offset, entries.size() - offset); // LUCENENET: Converted end index to length
             }
             else
             {
-                entriesResult = entries.GetRange(offset, endOffset - offset);
+                entriesResult = entries.GetView(offset, endOffset - offset); // LUCENENET: Converted end index to length
             }
             return new GroupedFacetResult(totalCount, totalMissCount, entriesResult);
         }
diff --git a/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs b/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs
index 319e21b..f48a3a7 100644
--- a/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs
+++ b/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs
@@ -240,7 +240,7 @@ namespace Lucene.Net.Tests.Queries
                 Random, dir);
             int num = AtLeast(100);
             bool singleField = Random.NextBoolean();
-            IList<Term> terms = new List<Term>();
+            JCG.List<Term> terms = new JCG.List<Term>();
             for (int i = 0; i < num; i++)
             {
                 string field = "field" + (singleField ? "1" : Random.Next(100).ToString(CultureInfo.InvariantCulture));
@@ -268,7 +268,7 @@ namespace Lucene.Net.Tests.Queries
                 TopDocs queryResult = searcher.Search(new ConstantScoreQuery(bq), reader.MaxDoc);
 
                 MatchAllDocsQuery matchAll = new MatchAllDocsQuery();
-                TermsFilter filter = TermsFilter(singleField, terms.SubList(0, numTerms));
+                TermsFilter filter = TermsFilter(singleField, terms.GetView(0, numTerms)); // LUCENENET: Checked length for correctness
                 TopDocs filterResult = searcher.Search(matchAll, filter, reader.MaxDoc);
                 assertEquals(filterResult.TotalHits, queryResult.TotalHits);
                 ScoreDoc[] scoreDocs = filterResult.ScoreDocs;
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
index 34d1e73..ab0c75b 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
@@ -927,7 +927,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                 IList<Lookup.LookupResult> r = suggester.DoLookup(TestUtil.StringToCharSequence(prefix, Random).ToString(), false, topN);
 
                 // 2. go thru whole set to find suggestions:
-                List<TermFreq2> matches = new List<TermFreq2>();
+                JCG.List<TermFreq2> matches = new JCG.List<TermFreq2>();
 
                 // "Analyze" the key:
                 string[] tokens = prefix.Split(' ').TrimEnd();
@@ -1006,8 +1006,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
 
                 if (matches.size() > topN)
                 {
-                    //matches = new List<TermFreq2>(matches.SubList(0, topN));
-                    matches = matches.GetRange(0, topN);
+                    matches = matches.GetView(0, topN); // LUCENENET: Checked length for correctness
                 }
 
                 if (Verbose)
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/FuzzySuggesterTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/FuzzySuggesterTest.cs
index 72bbad0..66a6660 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/FuzzySuggesterTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/FuzzySuggesterTest.cs
@@ -843,7 +843,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                 IList<Lookup.LookupResult> r = suggester.DoLookup(TestUtil.StringToCharSequence(prefix, Random).ToString(), false, topN);
 
                 // 2. go thru whole set to find suggestions:
-                List<Lookup.LookupResult> matches = new List<Lookup.LookupResult>();
+                JCG.List<Lookup.LookupResult> matches = new JCG.List<Lookup.LookupResult>();
 
                 // "Analyze" the key:
                 string[] tokens = prefix.Split(' ').TrimEnd();
@@ -954,7 +954,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
 
                 if (matches.size() > topN)
                 {
-                    matches = new List<Lookup.LookupResult>(matches.SubList(0, topN));
+                    matches = matches.GetView(0, topN); // LUCENENET: Checked length for correctness
                 }
 
                 if (Verbose)
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/TestFreeTextSuggester.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/TestFreeTextSuggester.cs
index 1978e50..587c45c 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/TestFreeTextSuggester.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/TestFreeTextSuggester.cs
@@ -621,7 +621,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                     if (tmp.size() > num)
                     {
                         //tmp.subList(num, tmp.size()).clear();
-                        tmp.RemoveRange(num, tmp.size() - num);
+                        tmp.RemoveRange(num, tmp.size() - num); // LUCENENET: Converted end index to length
                     }
                     foreach (Lookup.LookupResult result in tmp)
                     {
@@ -654,7 +654,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
 
                 if (expected.size() > num)
                 {
-                    expected.RemoveRange(num, expected.size() - num);
+                    expected.RemoveRange(num, expected.size() - num); // LUCENENET: Converted end index to length
                 }
 
                 // Actual:
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Fst/WFSTCompletionTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Fst/WFSTCompletionTest.cs
index 485d4e7..4ea2d69 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/Fst/WFSTCompletionTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/Fst/WFSTCompletionTest.cs
@@ -195,7 +195,7 @@ namespace Lucene.Net.Search.Suggest.Fst
                 if (matches.size() > topN)
                 {
                     //matches.SubList(topN, matches.size()).clear();
-                    matches.RemoveRange(topN, matches.size() - topN);
+                    matches.RemoveRange(topN, matches.size() - topN); // LUCENENET: Converted end index to length
                 }
 
                 assertEquals(matches.size(), r.size());
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/LookupBenchmarkTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/LookupBenchmarkTest.cs
index c620752..2441913 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/LookupBenchmarkTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/LookupBenchmarkTest.cs
@@ -18,6 +18,7 @@ using System.Linq;
 using System.Reflection;
 using System.Text;
 using Console = Lucene.Net.Util.SystemConsole;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Search.Suggest
 {
@@ -293,7 +294,7 @@ namespace Lucene.Net.Search.Suggest
 
             try
             {
-                List<double> times = new List<double>();
+                JCG.List<double> times = new JCG.List<double>();
                 for (int i = 0; i < warmup + rounds; i++)
                 {
                     long start = J2N.Time.NanoTime();
@@ -321,7 +322,7 @@ namespace Lucene.Net.Search.Suggest
 
             public BenchmarkResult(IList<double> times, int warmup, int rounds)
             {
-                this.average = Average.From(times.SubList(warmup, times.Count));
+                this.average = Average.From(times.GetView(warmup, times.Count - warmup)); // LUCENENET: Converted end index to length
             }
         }
     }
diff --git a/src/Lucene.Net.Tests/Index/Test2BTerms.cs b/src/Lucene.Net.Tests/Index/Test2BTerms.cs
index d7ed797..f15c6cb 100644
--- a/src/Lucene.Net.Tests/Index/Test2BTerms.cs
+++ b/src/Lucene.Net.Tests/Index/Test2BTerms.cs
@@ -13,6 +13,7 @@ using System.Collections.Generic;
 using System.Runtime.CompilerServices;
 using Assert = Lucene.Net.TestFramework.Assert;
 using Console = Lucene.Net.Util.SystemConsole;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Index
 {
@@ -60,7 +61,7 @@ namespace Lucene.Net.Index
         {
             internal readonly int tokensPerDoc;
             internal int tokenCount;
-            public readonly IList<BytesRef> savedTerms = new List<BytesRef>();
+            public readonly IList<BytesRef> savedTerms = new JCG.List<BytesRef>();
             internal int nextSave;
             internal long termCounter;
             internal readonly Random random;
@@ -236,7 +237,7 @@ namespace Lucene.Net.Index
                 savedTerms = FindTerms(r);
             }
             int numSavedTerms = savedTerms.Count;
-            IList<BytesRef> bigOrdTerms = new List<BytesRef>(savedTerms.SubList(numSavedTerms - 10, numSavedTerms));
+            IList<BytesRef> bigOrdTerms = new List<BytesRef>(savedTerms.GetView(numSavedTerms - 10, 10)); // LUCENENET: Converted end index to length
             Console.WriteLine("TEST: test big ord terms...");
             TestSavedTerms(r, bigOrdTerms);
             Console.WriteLine("TEST: test all saved terms...");
diff --git a/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs b/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
index 1f9eaca..534ab1c 100644
--- a/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
+++ b/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
@@ -1,4 +1,5 @@
-using Lucene.Net.Index.Extensions;
+using J2N.Collections.Generic.Extensions;
+using Lucene.Net.Index.Extensions;
 using Lucene.Net.Support;
 using NUnit.Framework;
 using System;
@@ -293,7 +294,7 @@ namespace Lucene.Net.Index
                 MergeSpecification ms = new MergeSpecification();
                 if (doMerge)
                 {
-                    OneMerge om = new OneMerge(segmentInfos.AsList().SubList(start, start + length));
+                    OneMerge om = new OneMerge(segmentInfos.AsList().GetView(start, length)); // LUCENENET: Converted end index to length
                     ms.Add(om);
                     doMerge = false;
                     return ms;
diff --git a/src/Lucene.Net.Tests/Search/TestMinShouldMatch2.cs b/src/Lucene.Net.Tests/Search/TestMinShouldMatch2.cs
index 24315d6..534fa55 100644
--- a/src/Lucene.Net.Tests/Search/TestMinShouldMatch2.cs
+++ b/src/Lucene.Net.Tests/Search/TestMinShouldMatch2.cs
@@ -1,4 +1,4 @@
-using J2N.Collections.Generic.Extensions;
+using J2N.Collections.Generic.Extensions;
 using Lucene.Net.Diagnostics;
 using Lucene.Net.Documents;
 using Lucene.Net.Index;
@@ -292,7 +292,7 @@ namespace Lucene.Net.Search
         [Test]
         public virtual void TestNextVaryingNumberOfTerms()
         {
-            IList<string> termsList = new List<string>(commonTerms.Length + mediumTerms.Length + rareTerms.Length);
+            IList<string> termsList = new JCG.List<string>(commonTerms.Length + mediumTerms.Length + rareTerms.Length);
             termsList.AddRange(commonTerms);
             termsList.AddRange(mediumTerms);
             termsList.AddRange(rareTerms);
@@ -300,7 +300,7 @@ namespace Lucene.Net.Search
 
             for (int numTerms = 2; numTerms <= termsList.Count; numTerms++)
             {
-                string[] terms = termsList.SubList(0, numTerms).ToArray(/*new string[0]*/);
+                string[] terms = termsList.GetView(0, numTerms).ToArray(/*new string[0]*/); // LUCENENET: Checked length of GetView() for correctness
                 for (int minNrShouldMatch = 1; minNrShouldMatch <= terms.Length; minNrShouldMatch++)
                 {
                     Scorer expected = Scorer(terms, minNrShouldMatch, true);
@@ -315,7 +315,7 @@ namespace Lucene.Net.Search
         [Test]
         public virtual void TestAdvanceVaryingNumberOfTerms()
         {
-            IList<string> termsList = new List<string>(commonTerms.Length + mediumTerms.Length + rareTerms.Length);
+            IList<string> termsList = new JCG.List<string>(commonTerms.Length + mediumTerms.Length + rareTerms.Length);
             termsList.AddRange(commonTerms);
             termsList.AddRange(mediumTerms);
             termsList.AddRange(rareTerms);
@@ -325,7 +325,7 @@ namespace Lucene.Net.Search
             {
                 for (int numTerms = 2; numTerms <= termsList.Count; numTerms++)
                 {
-                    string[] terms = termsList.SubList(0, numTerms).ToArray(/*new string[0]*/);
+                    string[] terms = termsList.GetView(0, numTerms).ToArray(/*new string[0]*/); // LUCENENET: Checked length of GetView() for correctness
                     for (int minNrShouldMatch = 1; minNrShouldMatch <= terms.Length; minNrShouldMatch++)
                     {
                         Scorer expected = Scorer(terms, minNrShouldMatch, true);
diff --git a/src/Lucene.Net.Tests/Search/TestShardSearching.cs b/src/Lucene.Net.Tests/Search/TestShardSearching.cs
index 157fbd5..ec5c316 100644
--- a/src/Lucene.Net.Tests/Search/TestShardSearching.cs
+++ b/src/Lucene.Net.Tests/Search/TestShardSearching.cs
@@ -327,7 +327,7 @@ namespace Lucene.Net.Search
                     if (priorSearches.Count > 200)
                     {
                         priorSearches.Shuffle(Random);
-                        priorSearches.SubList(100, priorSearches.Count).Clear();
+                        priorSearches.RemoveRange(100, priorSearches.Count - 100); // LUCENENET: Converted end index to length
                     }
                 }
             }
diff --git a/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs b/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs
index 3038658..6b793ba 100644
--- a/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs
+++ b/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs
@@ -1680,7 +1680,7 @@ namespace Lucene.Net.Util.Fst
                 matches.Sort(new TieBreakByInputComparer<long?>(minLongComparer));
                 if (matches.Count > topN)
                 {
-                    matches.SubList(topN, matches.Count).Clear();
+                    matches.RemoveRange(topN, matches.Count - topN); // LUCENENET: Converted end index to length
                 }
 
                 Assert.AreEqual(matches.Count, r.TopN.Count);
@@ -1820,7 +1820,7 @@ namespace Lucene.Net.Util.Fst
                 matches.Sort(new TieBreakByInputComparer<Pair>(minPairWeightComparer));
                 if (matches.Count > topN)
                 {
-                    matches.SubList(topN, matches.Count).Clear();
+                    matches.RemoveRange(topN, matches.Count - topN);  // LUCENENET: Converted end index to length;
                 }
 
                 Assert.AreEqual(matches.Count, r.TopN.Count);
diff --git a/src/Lucene.Net/Codecs/BlockTreeTermsWriter.cs b/src/Lucene.Net/Codecs/BlockTreeTermsWriter.cs
index 88bf01c..89728a7 100644
--- a/src/Lucene.Net/Codecs/BlockTreeTermsWriter.cs
+++ b/src/Lucene.Net/Codecs/BlockTreeTermsWriter.cs
@@ -1,4 +1,5 @@
-using J2N.Text;
+using J2N.Collections.Generic.Extensions;
+using J2N.Text;
 using Lucene.Net.Diagnostics;
 using Lucene.Net.Support;
 using Lucene.Net.Util.Fst;
@@ -7,6 +8,7 @@ using System.Collections.Generic;
 using System.IO;
 using System.Runtime.CompilerServices;
 using System.Text;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Codecs
 {
@@ -608,7 +610,7 @@ namespace Lucene.Net.Codecs
             private readonly Builder<object> blockBuilder;
 
             // PendingTerm or PendingBlock:
-            private readonly IList<PendingEntry> pending = new List<PendingEntry>();
+            private readonly IList<PendingEntry> pending = new JCG.List<PendingEntry>();
 
             // Index into pending of most recently written block
             private int lastBlockIndex = -1;
@@ -730,7 +732,7 @@ namespace Lucene.Net.Codecs
                     // already done this (partitioned these sub-terms
                     // according to their leading prefix byte)
 
-                    IList<PendingEntry> slice = ListExtensions.SubList<PendingEntry>(pending, pending.Count - count, pending.Count);
+                    IList<PendingEntry> slice = pending.GetView(pending.Count - count, count); // LUCENENET: Converted end index to length
                     int lastSuffixLeadLabel = -1;
                     int termCount = 0;
                     int subCount = 0;
@@ -962,7 +964,7 @@ namespace Lucene.Net.Codecs
 
                 if (Debugging.AssertsEnabled) Debugging.Assert(start >= 0, "pending.Count={0} startBackwards={1} length={2}", pending.Count, startBackwards, length);
 
-                IList<PendingEntry> slice = pending.SubList(start, start + length);
+                IList<PendingEntry> slice = pending.GetView(start, length); // LUCENENET: Converted end index to length
 
                 long startFP = outerInstance.@out.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
 
diff --git a/src/Lucene.Net/Index/BufferedUpdatesStream.cs b/src/Lucene.Net/Index/BufferedUpdatesStream.cs
index 4043e4f..526586b 100644
--- a/src/Lucene.Net/Index/BufferedUpdatesStream.cs
+++ b/src/Lucene.Net/Index/BufferedUpdatesStream.cs
@@ -1,11 +1,11 @@
 using J2N.Text;
 using J2N.Threading.Atomic;
 using Lucene.Net.Diagnostics;
-using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
+using JCG = J2N.Collections.Generic;
 
 namespace Lucene.Net.Index
 {
@@ -53,7 +53,7 @@ namespace Lucene.Net.Index
     internal class BufferedUpdatesStream
     {
         // TODO: maybe linked list?
-        private readonly IList<FrozenBufferedUpdates> updates = new List<FrozenBufferedUpdates>();
+        private readonly JCG.List<FrozenBufferedUpdates> updates = new JCG.List<FrozenBufferedUpdates>();
 
         // Starts at 1 so that SegmentInfos that have never had
         // deletes applied (whose bufferedDelGen defaults to 0)
@@ -442,7 +442,7 @@ namespace Lucene.Net.Index
                         bytesUsed.AddAndGet(-packet.bytesUsed);
                         if (Debugging.AssertsEnabled) Debugging.Assert(bytesUsed >= 0);
                     }
-                    updates.SubList(0, count).Clear();
+                    updates.RemoveRange(0, count); // LUCENENET: Checked count parameter for correctness
                 }
             }
         }
diff --git a/src/Lucene.Net/Index/LogMergePolicy.cs b/src/Lucene.Net/Index/LogMergePolicy.cs
index ca010af..0d483d9 100644
--- a/src/Lucene.Net/Index/LogMergePolicy.cs
+++ b/src/Lucene.Net/Index/LogMergePolicy.cs
@@ -1,4 +1,5 @@
-using Lucene.Net.Diagnostics;
+using J2N.Collections.Generic.Extensions;
+using Lucene.Net.Diagnostics;
 using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
@@ -271,14 +272,14 @@ namespace Lucene.Net.Index
                     {
                         // there is more than 1 segment to the right of
                         // this one, or a mergeable single segment.
-                        spec.Add(new OneMerge(segments.SubList(start + 1, last)));
+                        spec.Add(new OneMerge(segments.GetView(start + 1, last - (start + 1)))); // LUCENENET: Converted end index to length
                     }
                     last = start;
                 }
                 else if (last - start == m_mergeFactor)
                 {
                     // mergeFactor eligible segments were found, add them as a merge.
-                    spec.Add(new OneMerge(segments.SubList(start, last)));
+                    spec.Add(new OneMerge(segments.GetView(start, last - start))); // LUCENENET: Converted end index to length
                     last = start;
                 }
                 --start;
@@ -288,7 +289,7 @@ namespace Lucene.Net.Index
             // already fully merged
             if (last > 0 && (++start + 1 < last || !IsMerged(infos, infos.Info(start))))
             {
-                spec.Add(new OneMerge(segments.SubList(start, last)));
+                spec.Add(new OneMerge(segments.GetView(start, last - start))); // LUCENENET: Converted end index to length
             }
 
             return spec.Merges.Count == 0 ? null : spec;
@@ -308,7 +309,7 @@ namespace Lucene.Net.Index
             // mergeFactor) to potentially be run concurrently:
             while (last - maxNumSegments + 1 >= m_mergeFactor)
             {
-                spec.Add(new OneMerge(segments.SubList(last - m_mergeFactor, last)));
+                spec.Add(new OneMerge(segments.GetView(last - m_mergeFactor, m_mergeFactor))); // LUCENENET: Converted end index to length
                 last -= m_mergeFactor;
             }
 
@@ -322,7 +323,7 @@ namespace Lucene.Net.Index
                     // choice is simple:
                     if (last > 1 || !IsMerged(infos, infos.Info(0)))
                     {
-                        spec.Add(new OneMerge(segments.SubList(0, last)));
+                        spec.Add(new OneMerge(segments.GetView(0, last))); // LUCENENET: Converted end index to length
                     }
                 }
                 else if (last > maxNumSegments)
@@ -356,7 +357,7 @@ namespace Lucene.Net.Index
                         }
                     }
 
-                    spec.Add(new OneMerge(segments.SubList(bestStart, bestStart + finalMergeSize)));
+                    spec.Add(new OneMerge(segments.GetView(bestStart, finalMergeSize))); // LUCENENET: Converted end index to length
                 }
             }
             return spec.Merges.Count == 0 ? null : spec;
@@ -491,7 +492,7 @@ namespace Lucene.Net.Index
                         {
                             Message("  add merge " + firstSegmentWithDeletions + " to " + (i - 1) + " inclusive");
                         }
-                        spec.Add(new OneMerge(segments.SubList(firstSegmentWithDeletions, i)));
+                        spec.Add(new OneMerge(segments.GetView(firstSegmentWithDeletions, i - firstSegmentWithDeletions))); // LUCENENET: Converted end index to length
                         firstSegmentWithDeletions = i;
                     }
                 }
@@ -504,7 +505,7 @@ namespace Lucene.Net.Index
                     {
                         Message("  add merge " + firstSegmentWithDeletions + " to " + (i - 1) + " inclusive");
                     }
-                    spec.Add(new OneMerge(segments.SubList(firstSegmentWithDeletions, i)));
+                    spec.Add(new OneMerge(segments.GetView(firstSegmentWithDeletions, i - firstSegmentWithDeletions))); // LUCENENET: Converted end index to length
                     firstSegmentWithDeletions = -1;
                 }
             }
@@ -515,7 +516,7 @@ namespace Lucene.Net.Index
                 {
                     Message("  add merge " + firstSegmentWithDeletions + " to " + (numSegments - 1) + " inclusive");
                 }
-                spec.Add(new OneMerge(segments.SubList(firstSegmentWithDeletions, numSegments)));
+                spec.Add(new OneMerge(segments.GetView(firstSegmentWithDeletions, numSegments - firstSegmentWithDeletions))); // LUCENENET: Converted end index to length
             }
 
             return spec;
diff --git a/src/Lucene.Net/Index/SegmentInfos.cs b/src/Lucene.Net/Index/SegmentInfos.cs
index 3426bfd..3cfba11 100644
--- a/src/Lucene.Net/Index/SegmentInfos.cs
+++ b/src/Lucene.Net/Index/SegmentInfos.cs
@@ -155,7 +155,7 @@ namespace Lucene.Net.Index
         /// Opaque <see cref="T:IDictionary{string, string}"/> that user can specify during <see cref="IndexWriter.Commit()"/> </summary>
         private IDictionary<string, string> userData = Collections.EmptyMap<string, string>();
 
-        private IList<SegmentCommitInfo> segments = new JCG.List<SegmentCommitInfo>();
+        private JCG.List<SegmentCommitInfo> segments = new JCG.List<SegmentCommitInfo>();
 
         /// <summary>
         /// If non-null, information about loading segments_N files 
@@ -707,7 +707,7 @@ namespace Lucene.Net.Index
         {
             var sis = (SegmentInfos)base.MemberwiseClone();
             // deep clone, first recreate all collections:
-            sis.segments = new List<SegmentCommitInfo>(Count);
+            sis.segments = new JCG.List<SegmentCommitInfo>(Count);
             foreach (SegmentCommitInfo info in segments)
             {
                 if (Debugging.AssertsEnabled) Debugging.Assert(info.Info.Codec != null);
@@ -1356,7 +1356,7 @@ namespace Lucene.Net.Index
             }
 
             // the rest of the segments in list are duplicates, so don't remove from map, only list!
-            segments.SubList(newSegIdx, segments.Count).Clear();
+            segments.RemoveRange(newSegIdx, segments.Count - newSegIdx); // LUCENENET: Converted end index to length
 
             // Either we found place to insert segment, or, we did
             // not, but only because all segments we merged becamee
diff --git a/src/Lucene.Net/Index/TieredMergePolicy.cs b/src/Lucene.Net/Index/TieredMergePolicy.cs
index 2d2ba07..87532fa 100644
--- a/src/Lucene.Net/Index/TieredMergePolicy.cs
+++ b/src/Lucene.Net/Index/TieredMergePolicy.cs
@@ -575,7 +575,7 @@ namespace Lucene.Net.Index
                     " segmentsToMerge=" + string.Format(J2N.Text.StringFormatter.InvariantCulture, "{0}", segmentsToMerge));
             }
 
-            List<SegmentCommitInfo> eligible = new List<SegmentCommitInfo>();
+            JCG.List<SegmentCommitInfo> eligible = new JCG.List<SegmentCommitInfo>();
             bool forceMergeRunning = false;
             ICollection<SegmentCommitInfo> merging = m_writer.Get().MergingSegments;
             bool? segmentIsOriginal = false;
@@ -628,7 +628,7 @@ namespace Lucene.Net.Index
                 {
                     spec = new MergeSpecification();
                 }
-                OneMerge merge = new OneMerge(eligible.SubList(end - maxMergeAtOnceExplicit, end));
+                OneMerge merge = new OneMerge(eligible.GetView(end - maxMergeAtOnceExplicit, maxMergeAtOnceExplicit)); // LUCENENET: Converted end index to length
                 if (Verbose())
                 {
                     Message("add merge=" + m_writer.Get().SegString(merge.Segments));
@@ -641,7 +641,7 @@ namespace Lucene.Net.Index
             {
                 // Do final merge
                 int numToMerge = end - maxSegmentCount + 1;
-                OneMerge merge = new OneMerge(eligible.SubList(end - numToMerge, end));
+                OneMerge merge = new OneMerge(eligible.GetView(end - numToMerge, numToMerge)); // LUCENENET: Converted end index to length
                 if (Verbose())
                 {
                     Message("add final merge=" + merge.SegString(m_writer.Get().Directory));
@@ -659,7 +659,7 @@ namespace Lucene.Net.Index
             {
                 Message("findForcedDeletesMerges infos=" + m_writer.Get().SegString(infos.Segments) + " forceMergeDeletesPctAllowed=" + forceMergeDeletesPctAllowed);
             }
-            List<SegmentCommitInfo> eligible = new List<SegmentCommitInfo>();
+            JCG.List<SegmentCommitInfo> eligible = new JCG.List<SegmentCommitInfo>();
             ICollection<SegmentCommitInfo> merging = m_writer.Get().MergingSegments;
             foreach (SegmentCommitInfo info in infos.Segments)
             {
@@ -696,7 +696,7 @@ namespace Lucene.Net.Index
                     spec = new MergeSpecification();
                 }
 
-                OneMerge merge = new OneMerge(eligible.SubList(start, end));
+                OneMerge merge = new OneMerge(eligible.GetView(start, end - start)); // LUCENENET: Converted end index to length
                 if (Verbose())
                 {
                     Message("add merge=" + m_writer.Get().SegString(merge.Segments));
diff --git a/src/Lucene.Net/Search/FuzzyTermsEnum.cs b/src/Lucene.Net/Search/FuzzyTermsEnum.cs
index 97c9f01..f0f3ee1 100644
--- a/src/Lucene.Net/Search/FuzzyTermsEnum.cs
+++ b/src/Lucene.Net/Search/FuzzyTermsEnum.cs
@@ -174,7 +174,7 @@ namespace Lucene.Net.Search
             {
                 //if (BlockTreeTermsWriter.DEBUG) System.out.println("FuzzyTE.getAEnum: ed=" + editDistance + " lastTerm=" + (lastTerm==null ? "null" : lastTerm.utf8ToString()));
                 CompiledAutomaton compiled = runAutomata[editDistance];
-                return new AutomatonFuzzyTermsEnum(this, m_terms.Intersect(compiled, lastTerm == null ? null : compiled.Floor(lastTerm, new BytesRef())), runAutomata.SubList(0, editDistance + 1).ToArray(/*new CompiledAutomaton[editDistance + 1]*/));
+                return new AutomatonFuzzyTermsEnum(this, m_terms.Intersect(compiled, lastTerm == null ? null : compiled.Floor(lastTerm, new BytesRef())), runAutomata.GetView(0, editDistance + 1).ToArray(/*new CompiledAutomaton[editDistance + 1]*/)); // LUCENENET: Checked count parameter of GetView()
             }
             else
             {
diff --git a/src/Lucene.Net/Support/ListExtensions.cs b/src/Lucene.Net/Support/ListExtensions.cs
deleted file mode 100644
index b6797a1..0000000
--- a/src/Lucene.Net/Support/ListExtensions.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Lucene.Net.Support
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    internal static class ListExtensions
-    {
-        public static IList<T> SubList<T>(this IList<T> list, int fromIndex, int toIndex)
-        {
-            // .NET Port: This is to mimic Java's List.subList method, which has a different usage
-            // than .NETs' List.GetRange. subList's parameters are indices, GetRange's parameters are a
-            // starting index and a count. So we would need to do some light index math to translate this into
-            // GetRange. This will be a safer extension method to use when translating java code
-            // as there will be no question as to how to change it into GetRange. Also, subList returns
-            // a list instance that, when modified, modifies the original list. So we're duplicating
-            // that behavior as well.
-
-            return new SubList<T>(list, fromIndex, toIndex);
-        }
-    }
-
-    #region SubList<T>
-
-    internal sealed class SubList<T> : IList<T>
-    {
-        private readonly IList<T> list;
-        private readonly int fromIndex;
-        private int toIndex;
-
-        /// <summary>
-        /// Creates a ranged view of the given <paramref name="list"/>.
-        /// </summary>
-        /// <param name="list">The original list to view.</param>
-        /// <param name="fromIndex">The inclusive starting index.</param>
-        /// <param name="toIndex">The exclusive ending index.</param>
-        public SubList(IList<T> list, int fromIndex, int toIndex)
-        {
-            if (list is null)
-                throw new ArgumentNullException(nameof(list));
-            if (fromIndex < 0)
-                throw new ArgumentOutOfRangeException(nameof(fromIndex));
-            if (toIndex > list.Count)
-                throw new ArgumentOutOfRangeException(nameof(toIndex));
-            if (toIndex < fromIndex)
-                throw new ArgumentOutOfRangeException(nameof(toIndex));
-
-            this.list = list;
-            this.fromIndex = fromIndex;
-            this.toIndex = toIndex;
-        }
-
-        public int IndexOf(T item)
-        {
-            for (int i = fromIndex, fakeIndex = 0; i < toIndex; i++, fakeIndex++)
-            {
-                var current = list[i];
-
-                if (current == null && item == null)
-                    return fakeIndex;
-
-                if (current.Equals(item))
-                {
-                    return fakeIndex;
-                }
-            }
-
-            return -1;
-        }
-
-        public void Insert(int index, T item)
-        {
-            throw new NotSupportedException();
-        }
-
-        public void RemoveAt(int index)
-        {
-            // TODO: is this the right behavior?
-            list.RemoveAt(fromIndex + index);
-            toIndex--;
-        }
-
-        public T this[int index]
-        {
-            get => list[fromIndex + index];
-            set => list[fromIndex + index] = value;
-        }
-
-        public void Add(T item)
-        {
-            throw new NotSupportedException();
-        }
-
-        public void Clear()
-        {
-            // TODO: is this the correct behavior?
-
-            for (int i = toIndex - 1; i >= fromIndex; i--)
-            {
-                list.RemoveAt(i);
-            }
-
-            toIndex = fromIndex; // can't move further
-        }
-
-        public bool Contains(T item)
-        {
-            return IndexOf(item) >= 0;
-        }
-
-        public void CopyTo(T[] array, int arrayIndex)
-        {
-            int count = array.Length - arrayIndex;
-
-            for (int i = fromIndex, arrayi = arrayIndex; i <= Math.Min(toIndex - 1, fromIndex + count - 1); i++, arrayi++)
-            {
-                array[arrayi] = list[i];
-            }
-        }
-
-        public int Count => Math.Max(toIndex - fromIndex, 0);
-
-        public bool IsReadOnly => list.IsReadOnly;
-
-        public bool Remove(T item)
-        {
-            var index = this.IndexOf(item); // get fake index
-
-            if (index < 0)
-                return false;
-
-            list.RemoveAt(fromIndex + index);
-            toIndex--;
-
-            return true;
-        }
-
-        public IEnumerator<T> GetEnumerator()
-        {
-            return YieldItems().GetEnumerator();
-        }
-
-        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
-        {
-            return GetEnumerator();
-        }
-
-        private IEnumerable<T> YieldItems()
-        {
-            for (int i = fromIndex; i <= Math.Min(toIndex - 1, list.Count - 1); i++)
-            {
-                yield return list[i];
-            }
-        }
-    }
-
-    #endregion SubList<T>
-}
\ No newline at end of file
diff --git a/src/Lucene.Net/Util/FieldCacheSanityChecker.cs b/src/Lucene.Net/Util/FieldCacheSanityChecker.cs
index 50ca9ba..abecdf4 100644
--- a/src/Lucene.Net/Util/FieldCacheSanityChecker.cs
+++ b/src/Lucene.Net/Util/FieldCacheSanityChecker.cs
@@ -296,7 +296,7 @@ namespace Lucene.Net.Util
         /// </summary>
         private static IList<object> GetAllDescendantReaderKeys(object seed) // LUCENENET: CA1822: Mark members as static
         {
-            var all = new List<object>(17) {seed}; // will grow as we iter
+            var all = new JCG.List<object>(17) { seed }; // will grow as we iter
             for (var i = 0; i < all.Count; i++)
             {
                 var obj = all[i];
@@ -322,7 +322,7 @@ namespace Lucene.Net.Util
                 }
             }
             // need to skip the first, because it was the seed
-            return all.GetRange(1, all.Count - 1);
+            return all.GetView(1, all.Count - 1); // LUCENENET: Converted end index to length
         }
 
         /// <summary>
diff --git a/src/Lucene.Net/Util/Fst/BytesStore.cs b/src/Lucene.Net/Util/Fst/BytesStore.cs
index 8543233..ac5023c 100644
--- a/src/Lucene.Net/Util/Fst/BytesStore.cs
+++ b/src/Lucene.Net/Util/Fst/BytesStore.cs
@@ -1,4 +1,4 @@
-using Lucene.Net.Diagnostics;
+using Lucene.Net.Diagnostics;
 using System;
 using System.Runtime.CompilerServices;
 using JCG = J2N.Collections.Generic;
@@ -371,7 +371,7 @@ namespace Lucene.Net.Util.Fst
                 blockIndex--;
                 nextWrite = blockSize;
             }
-            blocks.RemoveRange(blockIndex + 1, blocks.Count - (blockIndex + 1));
+            blocks.RemoveRange(blockIndex + 1, blocks.Count - (blockIndex + 1)); // LUCENENET: Converted end index to length
             if (newLen == 0)
             {
                 current = null;