public void CopyTo(KeyValuePair <K, V>[] array, int arrayIndex) { using (IICLockRegion region = _innerLock.LockForRead()) { ICollection <KeyValuePair <K, V> > itf = _innerDic; itf.CopyTo(array, arrayIndex); } }
public bool Contains(KeyValuePair <K, V> item) { using (IICLockRegion region = _innerLock.LockForRead()) { ICollection <KeyValuePair <K, V> > itf = _innerDic; return(itf.Contains(item)); } }
public void SetItem(object ownerSecret, int index, T item) { ValidateOwnerSecret(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerList[index] = item; } }
public bool Remove(object ownerSecret, T item) { ValidateOwnerSecret(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { return(_innerList.Remove(item)); } }
public void RemoveAt(object ownerSecret, int index) { ValidateOwnerSecret(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerList.RemoveAt(index); } }
public void Insert(object ownerSecret, int index, T item) { ValidateOwnerSecret(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerList.Insert(index, item); } }
public bool Remove(object ownerSecret, KeyValuePair <K, V> item) { Validate(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { return(_innerDic.Remove(item.Key)); } }
public void Add(object ownerSecret, KeyValuePair <K, V> item) { Validate(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerDic.Add(item.Key, item.Value); } }
public bool Remove(object ownerSecret, K key) { Validate(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { return(_innerDic.Remove(key)); } }
public void SetValue(object ownerSecret, K key, V value) { Validate(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerDic[key] = value; } }
public void Add(object ownerSecret, K key, V value) { Validate(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerDic.Add(key, value); } }
public void Clear(object ownerSecret) { ValidateOwnerSecret(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerList.Clear(); } }
public void Add(object ownerSecret, T item) { ValidateOwnerSecret(ownerSecret); using (IICLockRegion region = _innerLock.LockForWrite()) { _innerList.Add(item); } }
IEnumerator IEnumerable.GetEnumerator() { using (IICLockRegion region = _innerLock.LockForRead()) { foreach (KeyValuePair <K, V> k in _innerDic) { yield return(k); } } }
public IEnumerator <KeyValuePair <K, V> > GetEnumerator() { using (IICLockRegion region = _innerLock.LockForRead()) { foreach (KeyValuePair <K, V> item in _innerTable) { yield return(item); } } }
IEnumerator IEnumerable.GetEnumerator() { using (IICLockRegion region = _innerLock.LockForRead()) { foreach (KeyValuePair <K, V> item in _innerTable) { yield return(new DictionaryEntry(item.Key, item.Value)); } } }
public IList <T> FindKeys(int keyFieldCount, Func <T, bool> judgement, 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()) { for (int i = 0; i < _indexEntrys.Count; i++) { IICIndexObject keyObjects = _indexEntrys.Keys[i]; if (keyObjects.StartsWith(startObject)) { if (lastObject == null || !keyObjects.StartsWith(lastObject, keyFieldCount)) { if (judgement != null && judgement(_indexEntrys.Values[i])) { list.Add(_indexEntrys.Values[i]); lastObject = keyObjects; } } } } } return(list); }
public T this[int index] { get { using (IICLockRegion region = _innerLock.LockForRead()) { return(_innerList[index]); } } set { SetItem(null, index, value); } }
public V this[K key] { get { using (IICLockRegion region = _innerLock.LockForRead()) { return(_innerDic[key]); } } set { SetValue(null, key, value); } }
public void Add(K beginKey, K endKey, V value) { using (IICLockRegion region = _lockSegs.LockForWrite()) { KeyValueObject itemKey; if (_searchEntrys.TryGetValue(beginKey, out itemKey)) { throw new ArgumentException(string.Format("key already exists! {0}", beginKey)); //itemKey.beginKey = beginKey; //itemKey.endKey = endKey; //itemKey.obj = value; } else { _searchEntrys.Add(beginKey, new KeyValueObject(beginKey, endKey, value)); } } }
public V this[K key] { get { using (IICLockRegion region = _innerLock.LockForRead()) { V val; if (_innerTable.TryGetValue(key, out val)) { return(val); } else { throw new ConfigurationNotFoundException(TableName, key.ToString(), string.Empty); } } } }
public IList <T> Find(params IComparable[] startFields) { if (startFields.Length > _fields.Length) { throw new InvalidOperationException("Too many search field"); } IComparable[] values = new IComparable[_fields.Length]; for (int i = 0; i < startFields.Length; i++) { values[i] = startFields[i]; } List <T> list = new List <T>(); if (_indexEntrys.Count == 0) { return(list); } IICIndexObject startObject = new IICIndexObject(values, 0); 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++) { list.Add(_indexEntrys.Values[i]); } } return(list); }
/* * 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 IICLockRegion LockForWrite(int millisecondTimeout) { IICLockRegion region = new IICLockRegion(_innerLock, IICLockMode.WriterLock, millisecondTimeout); return region; }
public IICLockRegion LockForUpgradeableRead(int millisecondTimeout) { IICLockRegion region = new IICLockRegion(_innerLock, IICLockMode.UpgradeableReadLock, millisecondTimeout); return region; }
public IICLockRegion LockForWrite(int millisecondTimeout) { IICLockRegion region = new IICLockRegion(_innerLock, IICLockMode.WriterLock, millisecondTimeout); return(region); }
public IICLockRegion LockForUpgradeableRead(int millisecondTimeout) { IICLockRegion region = new IICLockRegion(_innerLock, IICLockMode.UpgradeableReadLock, millisecondTimeout); return(region); }
public V Search(K key, out int index) { if (_searchEntrys.Count == 0) { index = -1; return(default(V)); } using (IICLockRegion region = _lockSegs.LockForRead()) { int begin = 0; int end = _searchEntrys.Count - 1; KeyValueObject seg; while (end - begin > 1) { int middle = (end + begin) / 2; seg = _searchEntrys.Values[middle]; int compareResult = seg.beginKey.CompareTo(key); if (compareResult == 0) { index = middle; return(seg.obj); } else { if (key.CompareTo(seg.beginKey) > 0) { begin = middle; } else { end = middle; } } } if (end == begin) { index = begin; seg = _searchEntrys.Values[begin]; if (key.CompareTo(seg.beginKey) >= 0 && key.CompareTo(seg.endKey) <= 0) { return(seg.obj); } } else { seg = _searchEntrys.Values[begin]; if (key.CompareTo(seg.beginKey) >= 0 && key.CompareTo(seg.endKey) <= 0) { index = begin; return(seg.obj); } seg = _searchEntrys.Values[end]; if (key.CompareTo(seg.beginKey) >= 0 && key.CompareTo(seg.endKey) <= 0) { index = end; return(seg.obj); } } } index = -1; return(default(V)); }
public void Clear() { using (IICLockRegion region = _lockSegs.LockForWrite()) { _searchEntrys.Clear(); } }
public bool TryGetItem(K key, out V item) { using (IICLockRegion region = _innerLock.LockForRead()) { return(_innerTable.TryGetValue(key, out item)); } }
public IEnumerator <T> GetEnumerator() { using (IICLockRegion region = _innerLock.LockForRead()) { return(_innerList.GetEnumerator()); } }
public void CopyTo(T[] array, int arrayIndex) { using (IICLockRegion region = _innerLock.LockForRead()) { _innerList.CopyTo(array, arrayIndex); } }