public override void Promote(FrugalMapBase newMap) { if (newMap.InsertEntry(_entry0.Key, _entry0.Value) != FrugalMapStoreState.Success) { throw new ArgumentException(nameof(newMap)); } if (newMap.InsertEntry(_entry1.Key, _entry1.Value) != FrugalMapStoreState.Success) { throw new ArgumentException(nameof(newMap)); } if (newMap.InsertEntry(_entry2.Key, _entry2.Value) != FrugalMapStoreState.Success) { throw new ArgumentException(nameof(newMap)); } }
public override void Promote(FrugalMapBase newMap) { for (int index = 0; index < _entries.Length; ++index) { if (newMap.InsertEntry(_entries[index].Key, _entries[index].Value) != FrugalMapStoreState.Success) { throw new ArgumentException(nameof(newMap)); } } }
public object this[int key] { get { if (MapStore != null) { return(MapStore.Search(key)); } return(DependencyProperty.UnsetValue); } set { if (value != DependencyProperty.UnsetValue) { if (MapStore == null) { MapStore = new SingleObjectMap(); } var state = MapStore.InsertEntry(key, value); if (state == FrugalMapStoreState.Success) { return; } FrugalMapBase newMap; if (FrugalMapStoreState.ThreeObjectMap == state) { newMap = new ThreeObjectMap(); } else if (FrugalMapStoreState.SixObjectMap == state) { newMap = new SixObjectMap(); } else if (FrugalMapStoreState.Array == state) { newMap = new ArrayObjectMap(); } else if (FrugalMapStoreState.SortedArray == state) { newMap = new SortedObjectMap(); } else { if (FrugalMapStoreState.Hashtable != state) { throw new InvalidOperationException(); } newMap = new HashObjectMap(); } MapStore.Promote(newMap); MapStore = newMap; int num = (int)MapStore.InsertEntry(key, value); } else { if (MapStore == null) { return; } MapStore.RemoveEntry(key); if (MapStore.Count != 0) { return; } MapStore = null; } } }