20 namespace Lucene.Net.Util
32 internal System.String str;
35 internal Entry(System.String str,
int hash,
Entry next)
43 private Entry[] cache;
44 private int maxChainLength;
53 this.maxChainLength = System.Math.Max(2, maxChainLength);
57 public override System.String Intern(System.String s)
59 int h = s.GetHashCode();
62 int slot = h & (cache.Length - 1);
64 Entry first = this.cache[slot];
65 Entry nextToLast = null;
69 for (
Entry e = first; e != null; e = e.next)
71 if (e.hash == h && (ReferenceEquals(e.str, s) || String.CompareOrdinal(e.str, s) == 0))
86 this.cache[slot] =
new Entry(s, h, first);
87 if (chainLength >= maxChainLength)
90 nextToLast.next = null;