public bool Add(DictionarySet.IMember Item) { bool setChanged = false; InsertIndexInfo info = this.InsertIndex(Item.Key()); if (info.Found > 0) { DictionarySet.MemberResult result = this.m_List[info.Index].Union(Item); if ((result != null) && (result.NewObject != null)) { this.m_List[info.Index] = result.NewObject; setChanged = result.SetChanged; } return(setChanged); } setChanged = true; this.ResizeArray(this.m_Count + 1); int num2 = info.Index + 1; for (int i = this.m_Count - 1; i >= num2; i += -1) { this.m_List[i] = this.m_List[i - 1]; } this.m_List[info.Index] = Item; return(setChanged); }
private InsertIndexInfo InsertIndex(IComparable Key) { InsertIndexInfo info2 = new InsertIndexInfo(); info2.Found = 0; if (this.m_Count == 0) { info2.Index = 0; return(info2); } if (Key.CompareTo(this.m_List[0].Key()) < 0) { info2.Index = 0; return(info2); } if (Key.CompareTo(this.m_List[this.m_Count - 1].Key()) > 0) { info2.Index = this.m_Count; return(info2); } int num3 = this.m_Count - 1; int num = 0; bool flag = false; do { int index = (int)Math.Round((double)(((double)(num + num3)) / 2.0)); if (num > num3) { info2.Index = num; flag = true; } else if (this.m_List[index].Key().CompareTo(Key) == 0) { info2.Index = index; info2.Found = -1; flag = true; } else if (this.m_List[index].Key().CompareTo(Key) < 0) { num = index + 1; } else { num3 = index - 1; } }while (!flag); return(info2); }