/// <summary> /// 添加数据集合 /// </summary> /// <param name="list">单向动态数组</param> /// <param name="values">数据集合</param> /// <returns>单向动态数组</returns> public unsafe static list </*Type[0]*/ ulong /*Type[0]*/> add (this list </*Type[0]*/ ulong /*Type[0]*/> list, System.Collections.Generic.ICollection </*Type[0]*/ ulong /*Type[0]*/> values) { if (list != null) { int count = values.count(); if (count != 0) { int index = list.Count; list.AddLength(count); fixed(/*Type[0]*/ ulong /*Type[0]*/ *valueFixed = list.Unsafer.Array) { /*Type[0]*/ ulong /*Type[0]*/ *write = valueFixed + index; foreach (/*Type[0]*/ ulong /*Type[0]*/ nextValue in values) { *write++ = nextValue; } } } return(list); } return(values.getList()); }
/// <summary> /// 移除数据 /// </summary> /// <param name="list">单向动态数组</param> /// <param name="index">数据位置</param> /// <returns>被移除的数据</returns> public static /*Type[0]*/ ulong /*Type[0]*/ getRemoveAt(this list </*Type[0]*/ ulong /*Type[0]*/> list, int index) { int count = list.count(); if ((uint)index < (uint)count) { list </*Type[0]*/ ulong /*Type[0]*/> .unsafer values = new list </*Type[0]*/ ulong /*Type[0]*/> .unsafer { List = list }; /*Type[0]*/ ulong /*Type[0]*/ value = values.Array[index]; unsafer.array.Move(values.Array, index + 1, index, --count - index); values.AddLength(-1); return(value); } log.Default.Throw(log.exceptionType.IndexOutOfRange); return(default(/*Type[0]*/ ulong /*Type[0]*/)); }
/// <summary> /// 超时检测 /// </summary> private void refreshTimeout() { DateTime time = date.NowSecond; int count = 0, isRefresh = 1; Monitor.Enter(dictionaryLock); try { if (refreshValues.Count < this.values.Count) { refreshValues.Empty(); refreshValues.AddLength(this.values.Count); } keyValue <keyType, valueType>[] refreshValueArray = refreshValues.UnsafeArray; foreach (KeyValuePair <keyType, value> values in this.values) { if (time >= values.Value.Timeout) { refreshValueArray[count++].Set(values.Key, values.Value.Value); } } if (count != 0) { foreach (keyValue <keyType, valueType> value in refreshValueArray) { remove(value.Key, value.Value); if (--count == 0) { break; } } } if (this.values.Count == 0) { isRefresh = this.isRefresh = 0; } } finally { Monitor.Exit(dictionaryLock); } if (isRefresh != 0) { timerTask.Default.Add(refresh, date.NowSecond.AddTicks(timeoutTicks)); } }
/// <summary> /// 获取建图初始节点集合 /// </summary> /// <param name="boot">根节点</param> /// <returns>建图初始节点集合</returns> private static unsafe list <int> getBuildGraphReader(ref node boot) { node[] pool = NodePool; list <int> reader = new list <int>(boot.Nodes.Count); fixed(int *readerFixed = reader.UnsafeArray) { int *write = readerFixed; foreach (int node in boot.Nodes.Values) { node nodeValue = pool[node]; if (nodeValue.Nodes != null && nodeValue.Nodes.Count != 0) { *write++ = node; } } reader.AddLength((int)(write - readerFixed)); } return(reader); }