public void Add(object ownerSecret, K key, V value) { Validate(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerDic.Add(key, value); } }
public void Insert(object ownerSecret, int index, T item) { ValidateOwnerSecret(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerList.Insert(index, item); } }
/* * public IList<T> FindKeys(int keyFieldCount, params IComparable[] startFields) * { * if (startFields.Length > _fields.Length) * throw new InvalidOperationException("Too many search fields: IICIndex<" + typeof(T).Name + ">"); * * if (keyFieldCount > _fields.Length) * throw new InvalidOperationException("Too many key fields: IICIndex<" + typeof(T).Name + "> key:" + keyFieldCount); * * if (keyFieldCount < startFields.Length) * throw new InvalidOperationException("KeyFieldCount can not less than startFields: IICIndex<" + typeof(T).Name + "> key:" + keyFieldCount); * * List<T> list = new List<T>(); * if (_indexEntrys.Count == 0) * return list; * * IComparable[] values = new IComparable[_fields.Length]; * for (int i = 0; i < startFields.Length; i++) { * values[i] = startFields[i]; * } * * IICIndexObject startObject = new IICIndexObject(values, 0); * IICIndexObject lastObject = null; * * using (IICLockRegion region = _innerLock.LockForRead()) { * int start = SearchFirstItem(startObject); * if (start < 0) * return list; * * if (!_indexEntrys.Keys[start].StartsWith(startObject)) * start++; * * for (int i = start; i < _indexEntrys.Count && _indexEntrys.Keys[i].StartsWith(startObject); i++) { * IICIndexObject keyObjects = _indexEntrys.Keys[i]; * if (keyObjects.StartsWith(lastObject)) { * } * * list.Add(_indexEntrys.Values[i]); * } * } * return list; * } */ public void BuildIndex(IEnumerable <T> items) { int serial = 0; using (IICLockRegion region = _innerLock.LockForWrite()) { _indexEntrys.Clear(); foreach (T item in items) { IComparable[] vals = new IComparable[_fields.Length]; for (int i = 0; i < _fields.Length; i++) { vals[i] = (IComparable)_fields[i].GetValue(item); } IICIndexObject indexObj = new IICIndexObject(vals, 0); if (_indexEntrys.ContainsKey(indexObj)) { serial++; indexObj.SerialNo = serial; } _indexEntrys.Add(indexObj, item); } } }
public void Clear() { using (IICLockRegion region = _lockSegs.LockForWrite()) { _searchEntrys.Clear(); } }