Esempio n. 1
0
 public void CopyTo(KeyValuePair <K, V>[] array, int arrayIndex)
 {
     using (IICLockRegion region = _innerLock.LockForRead()) {
         ICollection <KeyValuePair <K, V> > itf = _innerDic;
         itf.CopyTo(array, arrayIndex);
     }
 }
Esempio n. 2
0
 public bool Contains(KeyValuePair <K, V> item)
 {
     using (IICLockRegion region = _innerLock.LockForRead()) {
         ICollection <KeyValuePair <K, V> > itf = _innerDic;
         return(itf.Contains(item));
     }
 }
Esempio n. 3
0
        public void SetItem(object ownerSecret, int index, T item)
        {
            ValidateOwnerSecret(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                _innerList[index] = item;
            }
        }
Esempio n. 4
0
        public bool Remove(object ownerSecret, T item)
        {
            ValidateOwnerSecret(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                return(_innerList.Remove(item));
            }
        }
Esempio n. 5
0
        public void RemoveAt(object ownerSecret, int index)
        {
            ValidateOwnerSecret(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                _innerList.RemoveAt(index);
            }
        }
Esempio n. 6
0
        public void Insert(object ownerSecret, int index, T item)
        {
            ValidateOwnerSecret(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                _innerList.Insert(index, item);
            }
        }
Esempio n. 7
0
        public bool Remove(object ownerSecret, KeyValuePair <K, V> item)
        {
            Validate(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                return(_innerDic.Remove(item.Key));
            }
        }
Esempio n. 8
0
        public void Add(object ownerSecret, KeyValuePair <K, V> item)
        {
            Validate(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                _innerDic.Add(item.Key, item.Value);
            }
        }
Esempio n. 9
0
        public bool Remove(object ownerSecret, K key)
        {
            Validate(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                return(_innerDic.Remove(key));
            }
        }
Esempio n. 10
0
        public void SetValue(object ownerSecret, K key, V value)
        {
            Validate(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                _innerDic[key] = value;
            }
        }
Esempio n. 11
0
        public void Add(object ownerSecret, K key, V value)
        {
            Validate(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                _innerDic.Add(key, value);
            }
        }
Esempio n. 12
0
        public void Clear(object ownerSecret)
        {
            ValidateOwnerSecret(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                _innerList.Clear();
            }
        }
Esempio n. 13
0
        public void Add(object ownerSecret, T item)
        {
            ValidateOwnerSecret(ownerSecret);

            using (IICLockRegion region = _innerLock.LockForWrite()) {
                _innerList.Add(item);
            }
        }
Esempio n. 14
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     using (IICLockRegion region = _innerLock.LockForRead()) {
         foreach (KeyValuePair <K, V> k in _innerDic)
         {
             yield return(k);
         }
     }
 }
Esempio n. 15
0
 public IEnumerator <KeyValuePair <K, V> > GetEnumerator()
 {
     using (IICLockRegion region = _innerLock.LockForRead()) {
         foreach (KeyValuePair <K, V> item in _innerTable)
         {
             yield return(item);
         }
     }
 }
Esempio n. 16
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     using (IICLockRegion region = _innerLock.LockForRead()) {
         foreach (KeyValuePair <K, V> item in _innerTable)
         {
             yield return(new DictionaryEntry(item.Key, item.Value));
         }
     }
 }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
 public T this[int index]
 {
     get
     {
         using (IICLockRegion region = _innerLock.LockForRead()) {
             return(_innerList[index]);
         }
     }
     set
     {
         SetItem(null, index, value);
     }
 }
Esempio n. 19
0
 public V this[K key]
 {
     get
     {
         using (IICLockRegion region = _innerLock.LockForRead()) {
             return(_innerDic[key]);
         }
     }
     set
     {
         SetValue(null, key, value);
     }
 }
Esempio n. 20
0
 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));
         }
     }
 }
Esempio n. 21
0
 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);
             }
         }
     }
 }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        /*
         *      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);
                }
            }
        }
Esempio n. 24
0
 public IICLockRegion LockForWrite(int millisecondTimeout)
 {
     IICLockRegion region = new IICLockRegion(_innerLock, IICLockMode.WriterLock, millisecondTimeout);
     return region;
 }
Esempio n. 25
0
 public IICLockRegion LockForUpgradeableRead(int millisecondTimeout)
 {
     IICLockRegion region = new IICLockRegion(_innerLock, IICLockMode.UpgradeableReadLock, millisecondTimeout);
     return region;
 }
Esempio n. 26
0
        public IICLockRegion LockForWrite(int millisecondTimeout)
        {
            IICLockRegion region = new IICLockRegion(_innerLock, IICLockMode.WriterLock, millisecondTimeout);

            return(region);
        }
Esempio n. 27
0
        public IICLockRegion LockForUpgradeableRead(int millisecondTimeout)
        {
            IICLockRegion region = new IICLockRegion(_innerLock, IICLockMode.UpgradeableReadLock, millisecondTimeout);

            return(region);
        }
Esempio n. 28
0
        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));
        }
Esempio n. 29
0
 public void Clear()
 {
     using (IICLockRegion region = _lockSegs.LockForWrite()) {
         _searchEntrys.Clear();
     }
 }
Esempio n. 30
0
 public bool TryGetItem(K key, out V item)
 {
     using (IICLockRegion region = _innerLock.LockForRead()) {
         return(_innerTable.TryGetValue(key, out item));
     }
 }
Esempio n. 31
0
 public IEnumerator <T> GetEnumerator()
 {
     using (IICLockRegion region = _innerLock.LockForRead()) {
         return(_innerList.GetEnumerator());
     }
 }
Esempio n. 32
0
 public void CopyTo(T[] array, int arrayIndex)
 {
     using (IICLockRegion region = _innerLock.LockForRead()) {
         _innerList.CopyTo(array, arrayIndex);
     }
 }