public override FrugalMapStoreState InsertEntry(int key, object value) { for (int index = 0; index < (int)this._count; ++index) { if (this._entries[index].Key == key) { this._entries[index].Value = value; return(FrugalMapStoreState.Success); } } if ((ushort)15 <= this._count) { return(FrugalMapStoreState.SortedArray); } if (this._entries != null) { this._sorted = false; if (this._entries.Length <= (int)this._count) { FrugalMapBase.Entry[] entryArray = new FrugalMapBase.Entry[this._entries.Length + 3]; Array.Copy((Array)this._entries, 0, (Array)entryArray, 0, this._entries.Length); this._entries = entryArray; } } else { this._entries = new FrugalMapBase.Entry[9]; this._sorted = true; } this._entries[(int)this._count].Key = key; this._entries[(int)this._count].Value = value; ++this._count; return(FrugalMapStoreState.Success); }
private int Partition(int left, int right) { int num = right; int index1 = left - 1; int index2 = right; while (true) { do { ; }while (this.Compare(++index1, num) < 0); do { ; }while (this.Compare(num, --index2) < 0 && index2 != left); if (index1 < index2) { FrugalMapBase.Entry entry = this._entries[index2]; this._entries[index2] = this._entries[index1]; this._entries[index1] = entry; } else { break; } } FrugalMapBase.Entry entry1 = this._entries[right]; this._entries[right] = this._entries[index1]; this._entries[index1] = entry1; return(index1); }
public override void Sort() { if (this._sorted || this._count <= (ushort)1) { return; } if (this._entry0.Key > this._entry1.Key) { FrugalMapBase.Entry entry0 = this._entry0; this._entry0 = this._entry1; this._entry1 = entry0; } if (this._count > (ushort)2 && this._entry1.Key > this._entry2.Key) { FrugalMapBase.Entry entry1 = this._entry1; this._entry1 = this._entry2; this._entry2 = entry1; if (this._entry0.Key > this._entry1.Key) { FrugalMapBase.Entry entry0 = this._entry0; this._entry0 = this._entry1; this._entry1 = entry0; } } this._sorted = true; }
public override void RemoveEntry(int key) { switch (this._count) { case 1: if (this._entry0.Key != key) { break; } this._entry0.Key = int.MaxValue; this._entry0.Value = RadProperty.UnsetValue; --this._count; break; case 2: if (this._entry0.Key != key) { if (this._entry1.Key != key) { break; } this._entry1.Key = int.MaxValue; this._entry1.Value = RadProperty.UnsetValue; --this._count; break; } this._entry0 = this._entry1; this._entry1.Key = int.MaxValue; this._entry1.Value = RadProperty.UnsetValue; --this._count; break; case 3: if (this._entry0.Key != key) { if (this._entry1.Key == key) { this._entry1 = this._entry2; this._entry2.Key = int.MaxValue; this._entry2.Value = RadProperty.UnsetValue; --this._count; break; } if (this._entry2.Key != key) { break; } this._entry2.Key = int.MaxValue; this._entry2.Value = RadProperty.UnsetValue; --this._count; break; } this._entry0 = this._entry1; this._entry1 = this._entry2; this._entry2.Key = int.MaxValue; this._entry2.Value = RadProperty.UnsetValue; --this._count; break; } }
public override FrugalMapStoreState InsertEntry(int key, object value) { bool found; int insertIndex = this.FindInsertIndex(key, out found); if (found) { this._entries[insertIndex].Value = value; return FrugalMapStoreState.Success; } if (128 <= this._count) return FrugalMapStoreState.Hashtable; if (this._entries != null) { if (this._entries.Length <= this._count) { FrugalMapBase.Entry[] entryArray = new FrugalMapBase.Entry[this._entries.Length + 8]; Array.Copy((Array) this._entries, 0, (Array) entryArray, 0, this._entries.Length); this._entries = entryArray; } } else this._entries = new FrugalMapBase.Entry[16]; if (insertIndex < this._count) Array.Copy((Array) this._entries, insertIndex, (Array) this._entries, insertIndex + 1, this._count - insertIndex); else this._lastKey = key; this._entries[insertIndex].Key = key; this._entries[insertIndex].Value = value; ++this._count; return FrugalMapStoreState.Success; }
public override void Sort() { if (this._sorted || this._count <= (ushort)1) { return; } bool flag; do { flag = false; if (this._entry0.Key > this._entry1.Key) { FrugalMapBase.Entry entry0 = this._entry0; this._entry0 = this._entry1; this._entry1 = entry0; flag = true; } if (this._count > (ushort)2) { if (this._entry1.Key > this._entry2.Key) { FrugalMapBase.Entry entry1 = this._entry1; this._entry1 = this._entry2; this._entry2 = entry1; flag = true; } if (this._count > (ushort)3) { if (this._entry2.Key > this._entry3.Key) { FrugalMapBase.Entry entry2 = this._entry2; this._entry2 = this._entry3; this._entry3 = entry2; flag = true; } if (this._count > (ushort)4) { if (this._entry3.Key > this._entry4.Key) { FrugalMapBase.Entry entry3 = this._entry3; this._entry3 = this._entry4; this._entry4 = entry3; flag = true; } if (this._count > (ushort)5 && this._entry4.Key > this._entry5.Key) { FrugalMapBase.Entry entry4 = this._entry4; this._entry4 = this._entry5; this._entry5 = entry4; flag = true; } } } } }while (flag); this._sorted = true; }
public override FrugalMapStoreState InsertEntry(int key, object value) { bool found; int insertIndex = this.FindInsertIndex(key, out found); if (found) { this._entries[insertIndex].Value = value; return(FrugalMapStoreState.Success); } if (this._entries != null) { if (this._entries.Length <= this._count) { int length = this._entries.Length; FrugalMapBase.Entry[] entryArray = new FrugalMapBase.Entry[length + (length >> 1)]; Array.Copy((Array)this._entries, 0, (Array)entryArray, 0, this._entries.Length); this._entries = entryArray; } } else { this._entries = new FrugalMapBase.Entry[2]; } if (insertIndex < this._count) { Array.Copy((Array)this._entries, insertIndex, (Array)this._entries, insertIndex + 1, this._count - insertIndex); } else { this._lastKey = key; } this._entries[insertIndex].Key = key; this._entries[insertIndex].Value = value; ++this._count; return(FrugalMapStoreState.Success); }