You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2015/01/11 01:33:16 UTC
[3/6] lucenenet git commit: use UnmodifiedList as a reference to
children array
use UnmodifiedList as a reference to children array
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/da67eb06
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/da67eb06
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/da67eb06
Branch: refs/heads/master
Commit: da67eb0638e35a210c032f8ab6bc56702e227d36
Parents: 08fd199
Author: Laimonas Simutis <la...@gmail.com>
Authored: Sat Jan 10 07:48:57 2015 -0500
Committer: Laimonas Simutis <la...@gmail.com>
Committed: Sat Jan 10 07:48:57 2015 -0500
----------------------------------------------------------------------
.../Index/CompositeReaderContext.cs | 2 +-
src/Lucene.Net.Core/Lucene.Net.csproj | 1 +
src/Lucene.Net.Core/Support/UnmodifiableList.cs | 82 ++++++++++++++++++++
3 files changed, 84 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/da67eb06/src/Lucene.Net.Core/Index/CompositeReaderContext.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/CompositeReaderContext.cs b/src/Lucene.Net.Core/Index/CompositeReaderContext.cs
index b507aad..b200077 100644
--- a/src/Lucene.Net.Core/Index/CompositeReaderContext.cs
+++ b/src/Lucene.Net.Core/Index/CompositeReaderContext.cs
@@ -56,7 +56,7 @@ namespace Lucene.Net.Index
private CompositeReaderContext(CompositeReaderContext parent, CompositeReader reader, int ordInParent, int docbaseInParent, IList<IndexReaderContext> children, IList<AtomicReaderContext> leaves)
: base(parent, ordInParent, docbaseInParent)
{
- this.children = children.ToArray();
+ this.children = new UnmodifiableList<IndexReaderContext>(children);
this.leaves = leaves;
this.reader = reader;
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/da67eb06/src/Lucene.Net.Core/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Lucene.Net.csproj b/src/Lucene.Net.Core/Lucene.Net.csproj
index fec1b4f..5454521 100644
--- a/src/Lucene.Net.Core/Lucene.Net.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.csproj
@@ -675,6 +675,7 @@
<Compile Include="Support\TextSupport.cs" />
<Compile Include="Support\ThreadClass.cs" />
<Compile Include="Support\ThreadLock.cs" />
+ <Compile Include="Support\UnmodifiableList.cs" />
<Compile Include="Support\WeakDictionary.cs" />
<Compile Include="Util\Accountable.cs" />
<Compile Include="Util\ArrayInPlaceMergeSorter.cs" />
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/da67eb06/src/Lucene.Net.Core/Support/UnmodifiableList.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/UnmodifiableList.cs b/src/Lucene.Net.Core/Support/UnmodifiableList.cs
new file mode 100644
index 0000000..44138f1
--- /dev/null
+++ b/src/Lucene.Net.Core/Support/UnmodifiableList.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Lucene.Net.Support
+{
+ internal class UnmodifiableList<TValue> : IList<TValue>
+ {
+ private IList<TValue> _list;
+
+ public UnmodifiableList(IList<TValue> list)
+ {
+ _list = list;
+ }
+
+ public IEnumerator<TValue> GetEnumerator()
+ {
+ return _list.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ public void Add(TValue item)
+ {
+ throw new InvalidOperationException("Unable to modify this list.");
+ }
+
+ public void Clear()
+ {
+ throw new InvalidOperationException("Unable to modify this list.");
+ }
+
+ public bool Contains(TValue item)
+ {
+ return _list.Contains(item);
+ }
+
+ public void CopyTo(TValue[] array, int arrayIndex)
+ {
+ _list.CopyTo(array, arrayIndex);
+ }
+
+ public bool Remove(TValue item)
+ {
+ throw new InvalidOperationException("Unable to modify this list.");
+ }
+
+ public int Count
+ {
+ get { return _list.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return true; }
+ }
+
+ public int IndexOf(TValue item)
+ {
+ return _list.IndexOf(item);
+ }
+
+ public void Insert(int index, TValue item)
+ {
+ throw new InvalidOperationException("Unable to modify this list.");
+ }
+
+ public void RemoveAt(int index)
+ {
+ throw new InvalidOperationException("Unable to modify this list.");
+ }
+
+ public TValue this[int index]
+ {
+ get { return _list[index]; }
+ set { throw new InvalidOperationException("Unable to modify this list."); }
+ }
+ }
+}
\ No newline at end of file