- Timestamp:
- 06/25/19 23:14:06 (5 years ago)
- Location:
- branches/2435-alglib_3_15
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2435-alglib_3_15
- Property svn:mergeinfo changed
-
branches/2435-alglib_3_15/HeuristicLab.Core
- Property svn:mergeinfo changed
/branches/2931_OR-Tools_LP_MIP/HeuristicLab.Core (added) merged: 16373 /trunk/HeuristicLab.Core (added) merged: 16872,16907,16910,16933,16942,16945,16992,17009
- Property svn:mergeinfo changed
-
branches/2435-alglib_3_15/HeuristicLab.Core/3.3/Collections/CheckedItemList.cs
r16565 r17034 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Collections; 26 27 using HeuristicLab.Common; 27 using HEAL.Attic;28 28 29 29 namespace HeuristicLab.Core { … … 111 111 /// Sets the checked state of <paramref name="item"/> to <paramref name="checkedState"/>. 112 112 /// </summary> 113 /// <remarks> 114 /// This method is slower than <see cref="SetItemCheckedState(int, bool)"/>. 115 /// </remarks> 113 116 /// <param name="item">The item to set the checked state for.</param> 114 117 /// <param name="checkedState">The new checked state of <paramref name="item"/></param> 115 118 public void SetItemCheckedState(T item, bool checkedState) { 116 if (!this.checkedState.ContainsKey(item)) throw new ArgumentException(); 117 if (this.checkedState[item] != checkedState) { 118 this.checkedState[item] = checkedState; 119 OnCheckedItemsChanged(new IndexedItem<T>[] { new IndexedItem<T>(IndexOf(item), item) }); 120 } 119 SetItemCheckedState(IndexOf(item), checkedState); 120 } 121 122 /// <summary> 123 /// Sets the checked state of <paramref name="items"/> to <paramref name="checkedState"/>. 124 /// </summary> 125 /// <remarks> 126 /// This method is slower than <see cref="SetItemCheckedState(IEnumerable{int}, bool)"/>. 127 /// </remarks> 128 /// <param name="items">The items to set the checked state for.</param> 129 /// <param name="checkedState">The new checked state of <paramref name="item"/></param> 130 public void SetItemCheckedState(IEnumerable<T> items, bool checkedState) { 131 var changed = new List<IndexedItem<T>>(); 132 foreach (var item in items) { 133 if (!this.checkedState.TryGetValue(item, out bool currentState)) throw new ArgumentException(); 134 if (currentState != checkedState) { 135 this.checkedState[item] = checkedState; 136 changed.Add(new IndexedItem<T>(IndexOf(item), item)); 137 } 138 } 139 if (changed.Count > 0) OnCheckedItemsChanged(changed); 121 140 } 122 141 … … 127 146 /// <param name="checkedState">The new checked state of the item.</param> 128 147 public void SetItemCheckedState(int itemIndex, bool checkedState) { 129 SetItemCheckedState(this[itemIndex], checkedState); 148 var item = list[itemIndex]; 149 if (!this.checkedState.TryGetValue(item, out bool currentState)) throw new ArgumentException(); 150 if (currentState != checkedState) { 151 this.checkedState[item] = checkedState; 152 OnCheckedItemsChanged(new IndexedItem<T>[] { new IndexedItem<T>(itemIndex, item) }); 153 } 154 } 155 156 /// <summary> 157 /// Sets the checked state of all <paramref name="itemIndices"/> to <paramref name="checkedState"/>. 158 /// </summary> 159 /// <param name="itemIndices">The indices of all items to set the checked state for.</param> 160 /// <param name="checkedState">The new checked state of the item.</param> 161 public void SetItemCheckedState(IEnumerable<int> itemIndices, bool checkedState) { 162 var changed = new List<IndexedItem<T>>(); 163 foreach (var index in itemIndices) { 164 var item = list[index]; 165 if (!this.checkedState.TryGetValue(item, out bool currentState)) throw new ArgumentException(); 166 if (currentState != checkedState) { 167 this.checkedState[item] = checkedState; 168 changed.Add(new IndexedItem<T>(index, item)); 169 } 170 } 171 if (changed.Count > 0) OnCheckedItemsChanged(changed); 130 172 } 131 173
Note: See TracChangeset
for help on using the changeset viewer.