lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [1/2] lucenenet git commit: More work on Analysis.Common
Date Sat, 30 May 2015 22:20:52 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master 40684b823 -> f47779a7e


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f47779a7/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs
index a760b2c..78aacd7 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Text;
 using Lucene.Net.Support;
+using Lucene.Net.Util;
 
 namespace Lucene.Net.Analysis.Util
 {
@@ -58,7 +59,7 @@ namespace Lucene.Net.Analysis.Util
 	  private readonly CharacterUtils charUtils;
 	  private bool ignoreCase;
 	  private int count;
-	  internal readonly Version matchVersion; // package private because used in CharArraySet
+	  internal readonly LuceneVersion matchVersion; // package private because used in CharArraySet
 	  internal char[][] keys; // package private because used in CharArraySet's non Set-conform
CharArraySetIterator
 	  internal V[] values; // package private because used in CharArraySet's non Set-conform
CharArraySetIterator
 
@@ -73,16 +74,16 @@ namespace Lucene.Net.Analysis.Util
 	  /// <param name="ignoreCase">
 	  ///          <code>false</code> if and only if the set should be case sensitive
 	  ///          otherwise <code>true</code>. </param>
-	  public CharArrayMap(Lucene.Net.Util.LuceneVersion matchVersion, int startSize, bool ignoreCase)
+	  public CharArrayMap(LuceneVersion matchVersion, int startSize, bool ignoreCase)
 	  {
 		this.ignoreCase = ignoreCase;
-		int size_Renamed = INIT_SIZE;
-		while (startSize + (startSize >> 2) > size_Renamed)
+		int size = INIT_SIZE;
+		while (startSize + (startSize >> 2) > size)
 		{
-		  size_Renamed <<= 1;
+		  size <<= 1;
 		}
-		keys = new char[size_Renamed][];
-		values = (V[]) new object[size_Renamed];
+		keys = new char[size][];
+		values = new V[size];
 		this.charUtils = CharacterUtils.GetInstance(matchVersion);
 		this.matchVersion = matchVersion;
 	  }
@@ -98,9 +99,13 @@ namespace Lucene.Net.Analysis.Util
 	  /// <param name="ignoreCase">
 	  ///          <code>false</code> if and only if the set should be case sensitive
 	  ///          otherwise <code>true</code>. </param>
-	  public CharArrayMap<T1>(Version matchVersion, IDictionary<T1> c, bool ignoreCase)
where T1 : V : this(matchVersion, c.Count, ignoreCase)
+	  public CharArrayMap(LuceneVersion matchVersion, IDictionary<object, V> c, bool ignoreCase)
+          : this(matchVersion, c.Count, ignoreCase)
 	  {
-		putAll(c);
+	      foreach (var v in c)
+	      {
+	          Add(v);
+	      }
 	  }
 
 	  /// <summary>
@@ -115,58 +120,74 @@ namespace Lucene.Net.Analysis.Util
 		this.matchVersion = toCopy.matchVersion;
 	  }
 
-	  /// <summary>
+	    public void Add(KeyValuePair<object, V> item)
+	    {
+	        Put(item.Key, item.Value);
+	    }
+
+	    /// <summary>
 	  /// Clears all entries in this map. This method is supported for reusing, but not <seealso
cref="Map#remove"/>. </summary>
-	  public override void Clear()
+	  public virtual void Clear()
 	  {
 		count = 0;
 		Arrays.Fill(keys, null);
-		Arrays.Fill(values, null);
+		Arrays.Fill(values, default(V));
 	  }
 
-	  /// <summary>
+	    public bool Contains(KeyValuePair<object, V> item)
+	    {
+	        throw new NotImplementedException();
+	    }
+
+	    /// <summary>
 	  /// true if the <code>len</code> chars of <code>text</code> starting
at <code>off</code>
 	  /// are in the <seealso cref="#keySet()"/> 
 	  /// </summary>
 	  public virtual bool ContainsKey(char[] text, int off, int len)
 	  {
-		return keys[getSlot(text, off, len)] != null;
+		return keys[GetSlot(text, off, len)] != null;
 	  }
 
 	  /// <summary>
 	  /// true if the <code>CharSequence</code> is in the <seealso cref="#keySet()"/>
</summary>
 	  public virtual bool ContainsKey(string cs)
 	  {
-		return keys[getSlot(cs)] != null;
+		return keys[GetSlot(cs)] != null;
 	  }
 
-	  public override bool ContainsKey(object o)
-	  {
-		if (o is char[])
-		{
-		  char[] text = (char[])o;
-		  return ContainsKey(text, 0, text.Length);
-		}
-		return ContainsKey(o.ToString());
-	  }
+	    public virtual bool ContainsKey(object o)
+	    {
+	        var c = o as char[];
+	        if (c != null)
+	        {
+	            var text = c;
+	            return ContainsKey(text, 0, text.Length);
+	        }
+	        return ContainsKey(o.ToString());
+	    }
 
-	  /// <summary>
+	    public void Add(object key, V value)
+	    {
+	        Put(key, value);
+	    }
+
+	    /// <summary>
 	  /// returns the value of the mapping of <code>len</code> chars of <code>text</code>
 	  /// starting at <code>off</code> 
 	  /// </summary>
 	  public virtual V Get(char[] text, int off, int len)
 	  {
-		return values[getSlot(text, off, len)];
+		return values[GetSlot(text, off, len)];
 	  }
 
 	  /// <summary>
 	  /// returns the value of the mapping of the chars inside this {@code CharSequence} </summary>
 	  public virtual V Get(string cs)
 	  {
-		return values[getSlot(cs)];
+		return values[GetSlot(cs)];
 	  }
 
-	  public V Get(object o)
+	  public virtual V Get(object o)
 	  {
 	      var text = o as char[];
 		if (text != null)
@@ -216,25 +237,26 @@ namespace Lucene.Net.Analysis.Util
 
 	  /// <summary>
 	  /// Add the given mapping. </summary>
-	  public virtual V put(CharSequence text, V value)
+	  public virtual V Put(ICharSequence text, V value)
 	  {
-		return put(text.ToString(), value); // could be more efficient
+		return Put(text.ToString(), value); // could be more efficient
 	  }
 
-	  public override V put(object o, V value)
+	  public virtual V Put(object o, V value)
 	  {
-		if (o is char[])
+	      var c = o as char[];
+	      if (c != null)
 		{
-		  return put((char[])o, value);
+		  return Put(c, value);
 		}
-		return put(o.ToString(), value);
+		return Put(o.ToString(), value);
 	  }
 
 	  /// <summary>
 	  /// Add the given mapping. </summary>
-	  public virtual V put(string text, V value)
+	  public virtual V Put(string text, V value)
 	  {
-		return put(text.ToCharArray(), value);
+		return Put(text.ToCharArray(), value);
 	  }
 
 	  /// <summary>
@@ -242,13 +264,13 @@ namespace Lucene.Net.Analysis.Util
 	  /// If ignoreCase is true for this Set, the text array will be directly modified.
 	  /// The user should never modify this text array after calling this method.
 	  /// </summary>
-	  public virtual V put(char[] text, V value)
+	  public virtual V Put(char[] text, V value)
 	  {
 		if (ignoreCase)
 		{
 		  charUtils.ToLower(text, 0, text.Length);
 		}
-		int slot = getSlot(text, 0, text.Length);
+		int slot = GetSlot(text, 0, text.Length);
 		if (keys[slot] != null)
 		{
 		  V oldValue = values[slot];
@@ -264,23 +286,17 @@ namespace Lucene.Net.Analysis.Util
 		  Rehash();
 		}
 
-		return null;
+		return default(V);
 	  }
 
 	  private void Rehash()
 	  {
 		Debug.Assert(keys.Length == values.Length);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int newSize = 2*keys.length;
 		int newSize = 2 * keys.Length;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final char[][] oldkeys = keys;
 		char[][] oldkeys = keys;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final V[] oldvalues = values;
 		V[] oldvalues = values;
 		keys = new char[newSize][];
-		values = (V[]) new object[newSize];
+		values = new V[newSize];
 
 		for (int i = 0; i < oldkeys.Length; i++)
 		{
@@ -288,9 +304,7 @@ namespace Lucene.Net.Analysis.Util
 		  if (text != null)
 		  {
 			// todo: could be faster... no need to compare strings on collision
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int slot = getSlot(text,0,text.length);
-			int slot = getSlot(text,0,text.Length);
+			int slot = GetSlot(text,0,text.Length);
 			keys[slot] = text;
 			values[slot] = oldvalues[i];
 		  }
@@ -303,21 +317,17 @@ namespace Lucene.Net.Analysis.Util
 		{
 		  return false;
 		}
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int limit = off+len;
 		int limit = off + len;
 		if (ignoreCase)
 		{
 		  for (int i = 0;i < len;)
 		  {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int codePointAt = charUtils.codePointAt(text1, off+i, limit);
-			int codePointAt = charUtils.codePointAt(text1, off + i, limit);
-			if (char.ToLower(codePointAt) != charUtils.codePointAt(text2, i, text2.Length))
+			var codePointAt = charUtils.CodePointAt(text1, off + i, limit);
+			if (char.ToLower((char)codePointAt) != charUtils.CodePointAt(text2, i, text2.Length))
 			{
 			  return false;
 			}
-			i += char.charCount(codePointAt);
+			i += Character.CharCount(codePointAt);
 		  }
 		}
 		else
@@ -333,9 +343,9 @@ namespace Lucene.Net.Analysis.Util
 		return true;
 	  }
 
-	  private bool Equals(CharSequence text1, char[] text2)
+	    private bool Equals(ICharSequence text1, char[] text2)
 	  {
-		int len = text1.length();
+		int len = text1.Length;
 		if (len != text2.Length)
 		{
 		  return false;
@@ -344,21 +354,19 @@ namespace Lucene.Net.Analysis.Util
 		{
 		  for (int i = 0;i < len;)
 		  {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int codePointAt = charUtils.codePointAt(text1, i);
-			int codePointAt = charUtils.codePointAt(text1, i);
-			if (char.ToLower(codePointAt) != charUtils.codePointAt(text2, i, text2.Length))
+			int codePointAt = charUtils.CodePointAt(text1, i);
+			if (char.ToLower((char)codePointAt) != charUtils.CodePointAt(text2, i, text2.Length))
 			{
 			  return false;
 			}
-			i += char.charCount(codePointAt);
+			i += Character.CharCount(codePointAt);
 		  }
 		}
 		else
 		{
 		  for (int i = 0;i < len;i++)
 		  {
-			if (text1.charAt(i) != text2[i])
+			if (text1.CharAt(i) != text2[i])
 			{
 			  return false;
 			}
@@ -371,21 +379,17 @@ namespace Lucene.Net.Analysis.Util
 	  {
 		if (text == null)
 		{
-		  throw new System.NullReferenceException();
+		  throw new ArgumentException("text can't be null", "text");
 		}
 		int code = 0;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int stop = offset + len;
 		int stop = offset + len;
 		if (ignoreCase)
 		{
 		  for (int i = offset; i < stop;)
 		  {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int codePointAt = charUtils.codePointAt(text, i, stop);
-			int codePointAt = charUtils.codePointAt(text, i, stop);
-			code = code * 31 + char.ToLower(codePointAt);
-			i += char.charCount(codePointAt);
+			int codePointAt = charUtils.CodePointAt(text, i, stop);
+			code = code * 31 + char.ToLower((char)codePointAt);
+			i += Character.CharCount(codePointAt);
 		  }
 		}
 		else
@@ -398,39 +402,55 @@ namespace Lucene.Net.Analysis.Util
 		return code;
 	  }
 
-	  private int getHashCode(ICharSequence text)
+	  private int getHashCode(string text)
 	  {
 		if (text == null)
 		{
-		  throw new System.NullReferenceException();
+            throw new ArgumentException("text can't be null", "text");
 		}
 		int code = 0;
-		int len = text.Length();
+		int len = text.Length;
 		if (ignoreCase)
 		{
 		  for (int i = 0; i < len;)
 		  {
-			int codePointAt = charUtils.codePointAt(text, i);
-			code = code * 31 + char.ToLower(codePointAt);
-			i += char.charCount(codePointAt);
+			int codePointAt = charUtils.CodePointAt(text, i);
+			code = code * 31 + char.ToLower((char)codePointAt);
+			i += Character.CharCount(codePointAt);
 		  }
 		}
 		else
 		{
 		  for (int i = 0; i < len; i++)
 		  {
-			code = code * 31 + text.charAt(i);
+			code = code * 31 + text[i];
 		  }
 		}
 		return code;
 	  }
 
-	  public override V remove(object key)
+	  public virtual bool Remove(object key)
 	  {
 		throw new System.NotSupportedException();
 	  }
 
-	    public override int Size
+	    public bool TryGetValue(object key, out V value)
+	    {
+	        throw new NotImplementedException();
+	    }
+
+	    public V this[object key]
+	    {
+	        get { return Get(key); }
+	        set { throw new NotSupportedException(); }
+	    }
+
+	    public bool Remove(KeyValuePair<object, V> item)
+	    {
+            throw new System.NotSupportedException();
+	    }
+
+	    public int Count
 	    {
 	        get
 	        {
@@ -440,10 +460,12 @@ namespace Lucene.Net.Analysis.Util
 	        }
 	    }
 
+	    public bool IsReadOnly { get; private set; }
+
 	    public override string ToString()
 	  {
 		var sb = new StringBuilder("{");
-		foreach (KeyValuePair<object, V> entry in entrySet())
+		foreach (KeyValuePair<object, V> entry in GetEntrySet())
 		{
 		  if (sb.Length > 1)
 		  {
@@ -457,16 +479,16 @@ namespace Lucene.Net.Analysis.Util
 	  private EntrySet entrySet_Renamed = null;
 	  private CharArraySet keySet_Renamed = null;
 
-	  internal virtual EntrySet createEntrySet()
+	  internal virtual EntrySet CreateEntrySet()
 	  {
 		return new EntrySet(this, true);
 	  }
 
-	  public override EntrySet entrySet()
+	  public EntrySet GetEntrySet()
 	  {
 		if (entrySet_Renamed == null)
 		{
-		  entrySet_Renamed = createEntrySet();
+		  entrySet_Renamed = CreateEntrySet();
 		}
 		return entrySet_Renamed;
 	  }
@@ -481,47 +503,44 @@ namespace Lucene.Net.Analysis.Util
 	  /// Returns an <seealso cref="CharArraySet"/> view on the map's keys.
 	  /// The set will use the same {@code matchVersion} as this map. 
 	  /// </summary>
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent
attributes:
-//ORIGINAL LINE: @Override @SuppressWarnings({"unchecked","rawtypes"}) public final CharArraySet
keySet()
-	  public override CharArraySet keySet()
+	  public CharArraySet KeySet()
 	  {
 		if (keySet_Renamed == null)
 		{
 		  // prevent adding of entries
-		  keySet_Renamed = new CharArraySetAnonymousInnerClassHelper(this, (CharArrayMap) this);
+		  keySet_Renamed = new CharArraySetAnonymousInnerClassHelper(this);
 		}
 		return keySet_Renamed;
 	  }
 
-	  private class CharArraySetAnonymousInnerClassHelper : CharArraySet
+	  private sealed class CharArraySetAnonymousInnerClassHelper : CharArraySet
 	  {
-		  private readonly CharArrayMap<V> outerInstance;
+	      internal CharArraySetAnonymousInnerClassHelper(CharArrayMap<object> map) : base(map)
+	      {
+              // TODO
+	      }
 
-		  public CharArraySetAnonymousInnerClassHelper(CharArrayMap<V> outerInstance, CharArrayMap
(CharArrayMap) this) : base((CharArrayMap) this)
-		  {
-			  this.outerInstance = outerInstance;
-		  }
-
-		  public override bool add(object o)
+	      public override bool Add(object o)
 		  {
 			throw new System.NotSupportedException();
 		  }
-		  public override bool add(CharSequence text)
+		  public bool Add(ICharSequence text)
 		  {
 			throw new System.NotSupportedException();
 		  }
-		  public override bool add(string text)
+		  public override bool Add(string text)
 		  {
 			throw new System.NotSupportedException();
 		  }
-		  public override bool add(char[] text)
+		  public override bool Add(char[] text)
 		  {
 			throw new System.NotSupportedException();
 		  }
 	  }
 
 	  /// <summary>
-	  /// public iterator class so efficient methods are exposed to users </summary>
+	  /// public iterator class so efficient methods are exposed to users
+	  /// </summary>
 	  public class EntryIterator : IEnumerator<KeyValuePair<object, V>>
 	  {
 		  private readonly CharArrayMap<V> outerInstance;
@@ -534,10 +553,10 @@ namespace Lucene.Net.Analysis.Util
 		{
 			this.outerInstance = outerInstance;
 		  this.allowModify = allowModify;
-		  goNext();
+		  GoNext();
 		}
 
-		internal virtual void goNext()
+		internal void GoNext()
 		{
 		  lastPos = pos;
 		  pos++;
@@ -547,36 +566,36 @@ namespace Lucene.Net.Analysis.Util
 		  }
 		}
 
-		public override bool hasNext()
+		public bool HasNext()
 		{
 		  return pos < outerInstance.keys.Length;
 		}
 
 		/// <summary>
 		/// gets the next key... do not modify the returned char[] </summary>
-		public virtual char[] nextKey()
+		public virtual char[] NextKey()
 		{
-		  goNext();
+		  GoNext();
 		  return outerInstance.keys[lastPos];
 		}
 
 		/// <summary>
 		/// gets the next key as a newly created String object </summary>
-		public virtual string nextKeyString()
+		public virtual string NextKeyString()
 		{
-		  return new string(nextKey());
+		  return new string(NextKey());
 		}
 
 		/// <summary>
 		/// returns the value associated with the last key returned </summary>
-		public virtual V currentValue()
+		public virtual V CurrentValue()
 		{
 		  return outerInstance.values[lastPos];
 		}
 
 		/// <summary>
 		/// sets the value associated with the last key returned </summary>
-		public virtual V setValue(V value)
+		public virtual V SetValue(V value)
 		{
 		  if (!allowModify)
 		  {
@@ -588,18 +607,46 @@ namespace Lucene.Net.Analysis.Util
 		}
 
 		/// <summary>
-		/// use nextCharArray() + currentValue() for better efficiency. </summary>
-		public override KeyValuePair<object, V> next()
+		/// use nextCharArray() + currentValue() for better efficiency.
+		/// </summary>
+		public KeyValuePair<object, V> Next()
 		{
-		  goNext();
+		  GoNext();
+            //return new KeyValuePair<object, V>();
 		  return new MapEntry(outerInstance, lastPos, allowModify);
 		}
 
-		public override void remove()
+		public void Remove()
 		{
 		  throw new System.NotSupportedException();
 		}
-	  }
+
+        #region Added for better .NET support
+        public void Dispose()
+	      {	          
+	      }
+
+	      public bool MoveNext()
+	      {
+	          if (!HasNext()) return false;
+	          GoNext();
+	          return true;
+	      }
+
+	      public void Reset()
+	      {
+	          pos = -1;
+              GoNext();
+	      }
+
+          public KeyValuePair<object, V> Current { get { return new KeyValuePair<object,
V>(outerInstance.keys[lastPos], outerInstance.values[lastPos]); } private set { } }
+
+	      object IEnumerator.Current
+	      {
+	          get { return CurrentValue(); }
+          }
+          #endregion
+      }
 
 	  private sealed class MapEntry : KeyValuePair<object, V>
 	  {
@@ -615,17 +662,17 @@ namespace Lucene.Net.Analysis.Util
 		  this.allowModify = allowModify;
 		}
 
-		public override object Key
+		public object Key
 		{
 			get
 			{
 			  // we must clone here, as putAll to another CharArrayMap
 			  // with other case sensitivity flag would corrupt the keys
-			  return outerInstance.keys[pos].clone();
+			  return outerInstance.keys[pos].Clone();
 			}
 		}
 
-		public override V Value
+		public V Value
 		{
 			get
 			{
@@ -633,14 +680,12 @@ namespace Lucene.Net.Analysis.Util
 			}
 		}
 
-		public override V setValue(V value)
+		public V setValue(V value)
 		{
 		  if (!allowModify)
 		  {
 			throw new System.NotSupportedException();
 		  }
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final V old = values[pos];
 		  V old = outerInstance.values[pos];
 		  outerInstance.values[pos] = value;
 		  return old;
@@ -648,13 +693,16 @@ namespace Lucene.Net.Analysis.Util
 
 		public override string ToString()
 		{
-		  return (new StringBuilder()).Append(outerInstance.keys[pos]).Append('=').Append((outerInstance.values[pos]
== outerInstance) ? "(this Map)" : outerInstance.values[pos]).ToString();
+		  return (new StringBuilder())
+              .Append(outerInstance.keys[pos])
+              .Append('=')
+              .Append((outerInstance.values[pos] == outerInstance) ? "(this Map)" : outerInstance.values[pos]).ToString();
 		}
 	  }
 
 	  /// <summary>
 	  /// public EntrySet class so efficient methods are exposed to users </summary>
-	  public sealed class EntrySet : AbstractSet<KeyValuePair<object, V>>
+	  public sealed class EntrySet : ISet<KeyValuePair<object, V>>
 	  {
 		  private readonly CharArrayMap<V> outerInstance;
 
@@ -666,51 +714,38 @@ namespace Lucene.Net.Analysis.Util
 		  this.allowModify = allowModify;
 		}
 
-		public override EntryIterator iterator()
-		{
-		  return new EntryIterator(outerInstance, allowModify);
-		}
+	      public IEnumerator GetEnumerator()
+	      {
+              return new EntryIterator(outerInstance, allowModify);
+	      }
 
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent
attributes:
-//ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public boolean contains(Object
o)
-		public override bool contains(object o)
+		public override bool Contains(object o)
 		{
 		  if (!(o is DictionaryEntry))
 		  {
 			return false;
 		  }
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final java.util.Map.Entry<Object,V> e = (java.util.Map.Entry<Object,V>)o;
-		  KeyValuePair<object, V> e = (KeyValuePair<object, V>)o;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final Object key = e.getKey();
+		  var e = (KeyValuePair<object, V>)o;
 		  object key = e.Key;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final Object val = e.getValue();
 		  object val = e.Value;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final Object v = get(key);
-		  object v = outerInstance.get(key);
+		  object v = outerInstance.Get(key);
 		  return v == null ? val == null : v.Equals(val);
 		}
 
-		public override bool remove(object o)
-		{
-		  throw new System.NotSupportedException();
-		}
+	      public bool Remove(KeyValuePair<object, V> item)
+	      {
+              throw new System.NotSupportedException();
+	      }
 
-		public override int size()
-		{
-		  return outerInstance.count;
-		}
+          public int Count { get { return outerInstance.count; } private set { throw new
NotSupportedException(); } }
 
-		public override void clear()
+		public void Clear()
 		{
 		  if (!allowModify)
 		  {
 			throw new System.NotSupportedException();
 		  }
-		  outerInstance.clear();
+		  outerInstance.Clear();
 		}
 	  }
 
@@ -723,21 +758,21 @@ namespace Lucene.Net.Analysis.Util
 	  /// <returns> an new unmodifiable <seealso cref="CharArrayMap"/>. </returns>
 	  /// <exception cref="NullPointerException">
 	  ///           if the given map is <code>null</code>. </exception>
-	  public static CharArrayMap<V> unmodifiableMap<V>(CharArrayMap<V> map)
+	  public static CharArrayMap<V> UnmodifiableMap<V>(CharArrayMap<V> map)
 	  {
 		if (map == null)
 		{
 		  throw new System.NullReferenceException("Given map is null");
 		}
-		if (map == emptyMap() || map.Empty)
+		if (map == EmptyMap() || map.Empty)
 		{
-		  return emptyMap();
+		  return EmptyMap();
 		}
 		if (map is UnmodifiableCharArrayMap)
 		{
 		  return map;
 		}
-		return new UnmodifiableCharArrayMap<>(map);
+		return new UnmodifiableCharArrayMap<V>(map);
 	  }
 
 	  /// <summary>
@@ -760,101 +795,92 @@ namespace Lucene.Net.Analysis.Util
 	  /// <returns> a copy of the given map as a <seealso cref="CharArrayMap"/>.
If the given map
 	  ///         is a <seealso cref="CharArrayMap"/> the ignoreCase property as well
as the
 	  ///         matchVersion will be of the given map will be preserved. </returns>
-//JAVA TO C# CONVERTER TODO TASK: The following line could not be converted:
-	  SuppressWarnings("unchecked") public static <V> CharArrayMap<V> copy(final
org.org.apache.lucene.util.Version matchVersion, final java.util.Map<?,? extends V>
map)
+	 public static CharArrayMap<V> copy(LuceneVersion matchVersion, IDictionary<object,
V> map)
 	  {
 		if (map == EMPTY_MAP)
 		{
-		  return emptyMap();
+		  return EmptyMap();
 		}
 		if (map is CharArrayMap)
 		{
-		  CharArrayMap<V> m = (CharArrayMap<V>) map;
+		  var m = (CharArrayMap<V>) map;
 		  // use fast path instead of iterating all values
 		  // this is even on very small sets ~10 times faster than iterating
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final char[][] keys = new char[m.keys.length][];
-		  char[][] keys = new char[m.keys.Length][];
+		  var keys = new char[m.keys.Length][];
 		  Array.Copy(m.keys, 0, keys, 0, keys.Length);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final V[] values = (V[]) new Object[m.values.length];
-		  V[] values = (V[]) new object[m.values.Length];
+		  var values = new V[m.values.Length];
 		  Array.Copy(m.values, 0, values, 0, values.Length);
-		  m = new CharArrayMap<>(m);
-		  m.keys = keys;
-		  m.values = values;
-		  return m;
+		  m = new CharArrayMap<V>(m) {keys = keys, values = values};
+		    return m;
 		}
-		return new CharArrayMap<>(matchVersion, map, false);
+		return new CharArrayMap<V>(matchVersion, map, false);
 	  }
 
 	  /// <summary>
 	  /// Returns an empty, unmodifiable map. </summary>
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent
attributes:
-//ORIGINAL LINE: @SuppressWarnings("unchecked") public static <V> CharArrayMap<V>
emptyMap()
-	  public static <V> CharArrayMap<V> emptyMap()
+	  public static CharArrayMap<char[]> EmptyMap()
 	  {
-		return (CharArrayMap<V>) EMPTY_MAP;
+		return EMPTY_MAP;
 	  }
 
 	  // package private CharArraySet instanceof check in CharArraySet
-	  static class UnmodifiableCharArrayMap<V> extends CharArrayMap<V>
+	  class UnmodifiableCharArrayMap<V> : CharArrayMap<V>
 	  {
 
-		UnmodifiableCharArrayMap(CharArrayMap<V> map)
+		public UnmodifiableCharArrayMap(CharArrayMap<V> map) : base(map)
 		{
-		  base(map);
+		  
 		}
 
-		public void clear()
+		public override void Clear()
 		{
 		  throw new System.NotSupportedException();
 		}
 
-		public V put(object o, V val)
+		public override V Put(object o, V val)
 		{
 		  throw new System.NotSupportedException();
 		}
 
-		public V put(char[] text, V val)
+		public override V Put(char[] text, V val)
 		{
 		  throw new System.NotSupportedException();
 		}
 
-		public V put(CharSequence text, V val)
+		public override V Put(ICharSequence text, V val)
 		{
 		  throw new System.NotSupportedException();
 		}
 
-		public V put(string text, V val)
+		public override V Put(string text, V val)
 		{
 		  throw new System.NotSupportedException();
 		}
 
-		public V remove(object key)
+		public override bool Remove(object key)
 		{
 		  throw new System.NotSupportedException();
 		}
 
-		EntrySet createEntrySet()
+		override EntrySet CreateEntrySet()
 		{
 		  return new EntrySet(this, false);
 		}
 	  }
 
 	  /// <summary>
-	  /// Empty <seealso cref="org.apache.lucene.analysis.util.CharArrayMap.UnmodifiableCharArrayMap"/>
optimized for speed.
+	  /// Empty <seealso cref="CharArrayMap{V}.UnmodifiableCharArrayMap"/> optimized for
speed.
 	  /// Contains checks will always return <code>false</code> or throw
 	  /// NPE if necessary.
 	  /// </summary>
-	  private static final class EmptyCharArrayMap<V> extends UnmodifiableCharArrayMap<V>
+	  private class EmptyCharArrayMap<V> : UnmodifiableCharArrayMap<V>
 	  {
-		EmptyCharArrayMap()
+		public EmptyCharArrayMap():base(new CharArrayMap<V>(LuceneVersion.LUCENE_CURRENT,
0, false))
 		{
-		  base(new CharArrayMap<V>(Version.LUCENE_CURRENT, 0, false));
+		  
 		}
 
-		public bool containsKey(char[] text, int off, int len)
+		public override bool ContainsKey(char[] text, int off, int len)
 		{
 		  if (text == null)
 		  {
@@ -863,7 +889,7 @@ namespace Lucene.Net.Analysis.Util
 		  return false;
 		}
 
-		public bool containsKey(CharSequence cs)
+		public bool ContainsKey(ICharSequence cs)
 		{
 		  if (cs == null)
 		  {
@@ -872,7 +898,7 @@ namespace Lucene.Net.Analysis.Util
 		  return false;
 		}
 
-		public bool containsKey(object o)
+		public override bool ContainsKey(object o)
 		{
 		  if (o == null)
 		  {
@@ -881,33 +907,32 @@ namespace Lucene.Net.Analysis.Util
 		  return false;
 		}
 
-		public V get(char[] text, int off, int len)
+		public override V Get(char[] text, int off, int len)
 		{
 		  if (text == null)
 		  {
 			throw new System.NullReferenceException();
 		  }
-		  return null;
+		  return default(V);
 		}
 
-		public V get(CharSequence cs)
+		public V Get(ICharSequence cs)
 		{
 		  if (cs == null)
 		  {
 			throw new System.NullReferenceException();
 		  }
-		  return null;
+		  return default(V);
 		}
 
-		public V get(object o)
+		public override V Get(object o)
 		{
 		  if (o == null)
 		  {
 			throw new System.NullReferenceException();
 		  }
-		  return null;
+		  return default(V);
 		}
 	  }
 	}
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f47779a7/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs
index 4faa921..23ce187 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArraySet.cs
@@ -1,4 +1,5 @@
-´╗┐using System.Collections.Generic;
+´╗┐using System.Collections;
+using System.Collections.Generic;
 using System.Text;
 using Lucene.Net.Util;
 
@@ -70,7 +71,8 @@ namespace Lucene.Net.Analysis.Util
 	  /// <param name="ignoreCase">
 	  ///          <code>false</code> if and only if the set should be case sensitive
 	  ///          otherwise <code>true</code>. </param>
-	  public CharArraySet(Lucene.Net.Util.LuceneVersion matchVersion, int startSize, bool ignoreCase)
: this(new CharArrayMap<>(matchVersion, startSize, ignoreCase))
+	  public CharArraySet(LuceneVersion matchVersion, int startSize, bool ignoreCase)
+          : this(new CharArrayMap<object>(matchVersion, startSize, ignoreCase))
 	  {
 	  }
 
@@ -85,7 +87,8 @@ namespace Lucene.Net.Analysis.Util
 	  /// <param name="ignoreCase">
 	  ///          <code>false</code> if and only if the set should be case sensitive
 	  ///          otherwise <code>true</code>. </param>
-	  public CharArraySet<T1>(LuceneVersion matchVersion, ICollection<T1> c, bool
ignoreCase) : this(matchVersion, c.Count, ignoreCase)
+	  public CharArraySet(LuceneVersion matchVersion, ICollection<T> c, bool ignoreCase)
+          : this(matchVersion, c.Count, ignoreCase)
 	  {
 		AddAll(c);
 	  }
@@ -96,8 +99,8 @@ namespace Lucene.Net.Analysis.Util
 	  {
 		this.map = map;
 	  }
-
-	  /// <summary>
+      
+        /// <summary>
 	  /// Clears all entries in this set. This method is supported for reusing, but not <seealso
cref="Set#remove"/>. </summary>
 	  public void Clear()
 	  {
@@ -125,16 +128,26 @@ namespace Lucene.Net.Analysis.Util
 		return map.ContainsKey(o);
 	  }
 
-	  public bool Add(object o)
+        public void CopyTo(object[] array, int arrayIndex)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public bool Remove(object item)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public virtual bool Add(object o)
 	  {
-		return map.put(o, PLACEHOLDER) == null;
+		return map.Put(o, PLACEHOLDER) == null;
 	  }
 
 	  /// <summary>
 	  /// Add this String into the set </summary>
 	  public virtual bool Add(string text)
 	  {
-		return map.put(text, PLACEHOLDER) == null;
+		return map.Put(text, PLACEHOLDER) == null;
 	  }
 
 	  /// <summary>
@@ -144,19 +157,21 @@ namespace Lucene.Net.Analysis.Util
 	  /// </summary>
 	  public virtual bool Add(char[] text)
 	  {
-		return map.put(text, PLACEHOLDER) == null;
+		return map.Put(text, PLACEHOLDER) == null;
 	  }
 
-        public override int Size
+        public int Count
         {
             get
             {
                 {
-                    return map.size();
+                    return map.Count;
                 }
             }
         }
 
+        public bool IsReadOnly { get; private set; }
+
         /// <summary>
 	  /// Returns an unmodifiable <seealso cref="CharArraySet"/>. This allows to provide
 	  /// unmodifiable views of internal sets for "read-only" use.
@@ -166,7 +181,7 @@ namespace Lucene.Net.Analysis.Util
 	  /// <returns> an new unmodifiable <seealso cref="CharArraySet"/>. </returns>
 	  /// <exception cref="NullPointerException">
 	  ///           if the given set is <code>null</code>. </exception>
-	  public static CharArraySet unmodifiableSet(CharArraySet set)
+	  public static CharArraySet UnmodifiableSet(CharArraySet set)
 	  {
 		if (set == null)
 		{
@@ -218,15 +233,21 @@ namespace Lucene.Net.Analysis.Util
 	  }
 
 	  /// <summary>
-	  /// Returns an <seealso cref="Iterator"/> for {@code char[]} instances in this set.
+	  /// Returns an <seealso cref="IEnumerator"/> for {@code char[]} instances in this
set.
 	  /// </summary>
-	  public override IEnumerator<object> iterator()
-	  {
-		// use the AbstractSet#keySet()'s iterator (to not produce endless recursion)
-		return map.originalKeySet().GetEnumerator();
-	  }
+        public IEnumerator GetEnumerator()
+        {
+            // use the AbstractSet#keySet()'s iterator (to not produce endless recursion)
+            return map.originalKeySet().GetEnumerator();
+        }
+
+        IEnumerator<object> IEnumerable<object>.GetEnumerator()
+        {
+            // use the AbstractSet#keySet()'s iterator (to not produce endless recursion)
+            return map.originalKeySet().GetEnumerator();
+        }
 
-	  public override string ToString()
+        public override string ToString()
 	  {
 		var sb = new StringBuilder("[");
 		foreach (object item in this)
@@ -246,6 +267,62 @@ namespace Lucene.Net.Analysis.Util
 		}
 		return sb.Append(']').ToString();
 	  }
-	}
 
+        #region Not used by the Java implementation anyway
+        void ICollection<object>.Add(object item)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public void UnionWith(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public void IntersectWith(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public void ExceptWith(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public void SymmetricExceptWith(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public bool IsSubsetOf(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public bool IsSupersetOf(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public bool IsProperSupersetOf(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public bool IsProperSubsetOf(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public bool Overlaps(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        public bool SetEquals(IEnumerable<object> other)
+        {
+            throw new System.NotImplementedException();
+        }
+        #endregion
+	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f47779a7/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
index 4d2e076..004b368 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharacterUtils.cs
@@ -78,6 +78,7 @@ namespace Lucene.Net.Analysis.Util
         ///           - if the value offset is negative or not less than the length of
         ///           the character sequence. </exception>
         public abstract int CodePointAt(string seq, int offset);
+        public abstract int CodePointAt(ICharSequence seq, int offset);
 
         /// <summary>
         /// Returns the code point at the given index of the char array where only elements
@@ -258,11 +259,11 @@ namespace Lucene.Net.Analysis.Util
 
         private sealed class Java5CharacterUtils : CharacterUtils
         {
-            internal Java5CharacterUtils()
+            public override int CodePointAt(string seq, int offset)
             {
+                return Character.CodePointAt(seq, offset);
             }
-
-            public override int CodePointAt(string seq, int offset)
+            public override int CodePointAt(ICharSequence seq, int offset)
             {
                 return Character.CodePointAt(seq, offset);
             }
@@ -326,14 +327,14 @@ namespace Lucene.Net.Analysis.Util
 
         private sealed class Java4CharacterUtils : CharacterUtils
         {
-            internal Java4CharacterUtils()
-            {
-            }
-
             public override int CodePointAt(string seq, int offset)
             {
                 return seq[offset];
             }
+            public override int CodePointAt(ICharSequence seq, int offset)
+            {
+                return seq.CharAt(offset);
+            }
 
             public override int CodePointAt(char[] chars, int offset, int limit)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f47779a7/src/Lucene.Net.Analysis.Common/Analysis/Util/StopwordAnalyzerBase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/StopwordAnalyzerBase.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/StopwordAnalyzerBase.cs
index 915f4a6..5462c94 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/StopwordAnalyzerBase.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/StopwordAnalyzerBase.cs
@@ -61,7 +61,7 @@ namespace Lucene.Net.Analysis.Util
 	  {
 		matchVersion = version;
 		// analyzers should use char array set for stopwords!
-		this.stopwords = stopwords == null ? CharArraySet.EMPTY_SET : CharArraySet.unmodifiableSet(CharArraySet.Copy(version,
stopwords));
+		this.stopwords = stopwords == null ? CharArraySet.EMPTY_SET : CharArraySet.UnmodifiableSet(CharArraySet.Copy(version,
stopwords));
 	  }
 
 	  /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f47779a7/src/Lucene.Net.Core/Support/Character.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Character.cs b/src/Lucene.Net.Core/Support/Character.cs
index fc90896..f1bd183 100644
--- a/src/Lucene.Net.Core/Support/Character.cs
+++ b/src/Lucene.Net.Core/Support/Character.cs
@@ -105,6 +105,8 @@ namespace Lucene.Net.Support
 
         public static int ToLowerCase(int codePoint)
         {
+            // LUCENENET TODO do we really need this? what's wrong with char.ToLower() ?
+
             var str = UnicodeUtil.NewString(new[] {codePoint}, 0, 1);
 
             str = str.ToLower();


Mime
View raw message