private BTree <string> m_btree = null; // ordered by "Length(distance),OriginalString" /// <summary> /// O(log n) /// </summary> public void Add(string originalString) { if (m_arrayNode != null) { if (m_arrayNode.Count < SWITCH_TO_BTREE_THRESHOLD) { m_arrayNode.Add(originalString); return; } else { var arrayNode = m_arrayNode; m_arrayNode = null; m_btree = new BTree <string>(new ItemComparer(), SWITCH_TO_BTREE_THRESHOLD); m_btree.AddRangeOrdered(arrayNode); } } m_btree.Add(originalString); }